UNPKG

@plait/draw

Version:

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

1,388 lines (1,335 loc) 59.6 kB
import * as _plait_core from '@plait/core'; import { PlaitElement, PlaitBoard, RectangleClient, Point, PointOfRectangle, Direction, Vector, WithPluginOptions, Path, ThemeColorMode, Selection, SnapRef, DirectionFactors, OnContextChanged, PlaitPluginElementContext } from '@plait/core'; import * as _plait_common from '@plait/common'; import { ParagraphElement, TextManageChangeData, TextManage, StrokeStyle, Alignment, ElbowLineRouteOptions, ResizeState, CustomText, ResizeRef, Generator, ActiveGeneratorExtraData, CommonElementFlavour, ActiveGenerator } from '@plait/common'; import { Options } from 'roughjs/bin/core'; import * as slate from 'slate'; import { Element, BaseOperation, BaseEditor } from 'slate'; import * as _plait_draw from '@plait/draw'; interface DrawTextInfo extends TextRectangleOptions { text: ParagraphElement; } interface TextGeneratorOptions<T> { onChange: (element: T, textChangeRef: TextManageChangeData, text: DrawTextInfo) => void; getRenderRectangle?: (element: T, text: DrawTextInfo) => RectangleClient; getMaxWidth?: () => number; } declare const KEY_TO_TEXT_MANAGE: WeakMap<PlaitBoard, { [key: string]: TextManage; }>; declare const setTextManage: (board: PlaitBoard, element: PlaitElement, text: DrawTextInfo, textManage: TextManage) => WeakMap<PlaitBoard, { [key: string]: TextManage; }>; declare const getTextManage: (board: PlaitBoard, element: PlaitElement | undefined, text: Pick<DrawTextInfo, "id">) => TextManage; declare const deleteTextManage: (board: PlaitBoard, key: string) => void; declare class TextGenerator<T extends PlaitElement = PlaitGeometry> { protected board: PlaitBoard; protected element: T; protected texts: DrawTextInfo[]; protected options: TextGeneratorOptions<T>; textManages: TextManage[]; get shape(): DrawShapes; constructor(board: PlaitBoard, element: T, texts: DrawTextInfo[], options: TextGeneratorOptions<T>); initialize(): void; draw(elementG: SVGElement): void; update(element: T, previousDrawShapeTexts: DrawTextInfo[], currentDrawShapeTexts: DrawTextInfo[], elementG: SVGElement): void; private createTextManage; getRectangle(text: DrawTextInfo): { height: number; width: number; x: any; y: number; }; getMaxWidth(text: DrawTextInfo): number; destroy(): void; } declare enum BasicShapes { rectangle = "rectangle", ellipse = "ellipse", diamond = "diamond", roundRectangle = "roundRectangle", parallelogram = "parallelogram", text = "text", triangle = "triangle", leftArrow = "leftArrow", trapezoid = "trapezoid", rightArrow = "rightArrow", cross = "cross", star = "star", pentagon = "pentagon", hexagon = "hexagon", octagon = "octagon", pentagonArrow = "pentagonArrow", processArrow = "processArrow", twoWayArrow = "twoWayArrow", comment = "comment", roundComment = "roundComment", cloud = "cloud" } declare enum FlowchartSymbols { process = "process", decision = "decision", data = "data", connector = "connector", terminal = "terminal", manualInput = "manualInput", preparation = "preparation", manualLoop = "manualLoop", merge = "merge", delay = "delay", storedData = "storedData", or = "or", summingJunction = "summingJunction", predefinedProcess = "predefinedProcess", offPage = "offPage", document = "document", multiDocument = "multiDocument", database = "database", hardDisk = "hardDisk", internalStorage = "internalStorage", noteCurlyRight = "noteCurlyRight", noteCurlyLeft = "noteCurlyLeft", noteSquare = "noteSquare", display = "display" } declare enum UMLSymbols { actor = "actor", useCase = "useCase", container = "container", note = "note", simpleClass = "simpleClass", activityClass = "activityClass", branchMerge = "branchMerge", port = "port", package = "package", combinedFragment = "combinedFragment", class = "class", interface = "interface", object = "object", component = "component", componentBox = "componentBox", template = "template", activation = "activation", deletion = "deletion", assembly = "assembly", providedInterface = "providedInterface", requiredInterface = "requiredInterface" } declare enum GeometryCommonTextKeys { name = "name", content = "content" } type GeometryShapes = BasicShapes | FlowchartSymbols | UMLSymbols; type SwimlaneDirection = 'horizontal' | 'vertical'; interface PlaitBaseGeometry<T extends string = 'geometry', P extends Point[] = [Point, Point], S extends string = GeometryShapes> extends PlaitElement { type: T; points: P; shape: S; } interface PlaitCommonGeometry<T extends string = 'geometry', P extends Point[] = [Point, Point], S extends string = GeometryShapes> extends PlaitBaseGeometry<T, P, S> { fill?: string; strokeColor?: string; strokeWidth?: number; strokeStyle?: StrokeStyle; angle?: number; opacity?: number; } interface PlaitCustomGeometry<T extends string = string, P extends Point[] = Point[], S extends string = string> extends PlaitBaseGeometry<T, P, S> { } interface PlaitMultipleTextGeometry extends PlaitCommonGeometry { texts: DrawTextInfo[]; } interface PlaitRectangle extends PlaitGeometry { shape: BasicShapes.rectangle; } interface PlaitEllipse extends PlaitGeometry { shape: BasicShapes.ellipse; } interface PlaitDiamond extends PlaitGeometry { shape: BasicShapes.diamond; } interface PlaitGeometry extends PlaitCommonGeometry { text?: ParagraphElement; } declare const PlaitGeometry: {}; interface PlaitCommonImage extends PlaitElement { points: [Point, Point]; type: 'image'; angle: number; } interface PlaitImage extends PlaitCommonImage { url: string; } 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" } declare enum ArrowLineShape { straight = "straight", curve = "curve", elbow = "elbow" } declare enum ArrowLineHandleKey { source = "source", target = "target" } interface ArrowLineText { text: Element; position: number; } interface ArrowLineHandle { boundId?: string; connection?: PointOfRectangle; marker: ArrowLineMarkerType; } interface ArrowLineHandleRef { key: ArrowLineHandleKey; direction: Direction; point: PointOfRectangle; vector: Vector; boundElement?: PlaitShapeElement; } interface ArrowLineHandleRefPair { source: ArrowLineHandleRef; target: ArrowLineHandleRef; } interface PlaitStraightArrowLine extends PlaitArrowLine { shape: ArrowLineShape.straight; } interface PlaitCurveArrowLine extends PlaitArrowLine { shape: ArrowLineShape.curve; } interface PlaitElbowArrowLine extends PlaitArrowLine { shape: ArrowLineShape.elbow; } 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; } 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[]; }; interface DrawOptions { element: PlaitElement; } interface TextRectangleOptions { id: string; board?: PlaitBoard; } interface ShapeEngine<T extends PlaitElement = PlaitGeometry, P extends DrawOptions = DrawOptions, K extends TextRectangleOptions = TextRectangleOptions> { isInsidePoint: (rectangle: RectangleClient, point: Point) => boolean; getNearestPoint: (rectangle: RectangleClient, point: Point) => Point; getNearestCrossingPoint?: (rectangle: RectangleClient, point: Point) => Point; getConnectorPoints: (rectangle: RectangleClient) => Point[]; getCornerPoints: (rectangle: RectangleClient) => Point[]; getEdgeByConnectionPoint?: (rectangle: RectangleClient, point: PointOfRectangle) => [Point, Point] | null; getTangentVectorByConnectionPoint?: (rectangle: RectangleClient, point: PointOfRectangle) => Vector | null; draw: (board: PlaitBoard, rectangle: RectangleClient, roughOptions: Options, options?: P) => SVGGElement; getTextRectangle?: (board: PlaitBoard, element: T, options?: K) => RectangleClient; } declare enum TableSymbols { table = "table" } interface PlaitTableBoard extends PlaitBoard { buildTable: (element: PlaitBaseTable) => PlaitBaseTable; } interface PlaitBaseTable extends PlaitElement { id: string; points: Point[]; rows: { id: string; height?: number; }[]; columns: { id: string; width?: number; }[]; cells: PlaitTableCell[]; groupId?: string; } interface PlaitTable extends PlaitBaseTable { type: 'table'; } interface PlaitTableCell { id: string; rowId: string; columnId: string; colspan?: number; rowspan?: number; text?: PlaitTableCellParagraph; fill?: string; } interface PlaitTableDrawOptions extends DrawOptions { element: PlaitTable; } interface PlaitTableCellWithPoints extends PlaitTableCell { points: [Point, Point]; } interface PlaitTableCellParagraph extends ParagraphElement { direction?: 'vertical' | 'horizontal'; } declare const PlaitTableElement: { isTable: (value: any) => value is PlaitTable; isVerticalText: (value: PlaitTableCell) => value is PlaitTableCell; }; declare enum SwimlaneSymbols { swimlaneVertical = "swimlaneVertical", swimlaneHorizontal = "swimlaneHorizontal" } declare enum SwimlaneDrawSymbols { swimlaneVertical = "swimlaneVertical", swimlaneHorizontal = "swimlaneHorizontal", swimlaneVerticalWithHeader = "swimlaneVerticalWithHeader", swimlaneHorizontalWithHeader = "swimlaneHorizontalWithHeader" } interface PlaitSwimlane extends PlaitBaseTable { type: 'swimlane'; shape: SwimlaneSymbols; header?: boolean; } interface PlaitSwimlaneVertical extends PlaitSwimlane { shape: SwimlaneSymbols.swimlaneVertical; } interface PlaitSwimlaneHorizontal extends PlaitSwimlane { shape: SwimlaneSymbols.swimlaneHorizontal; } interface PlaitText extends PlaitGeometry { shape: BasicShapes.text; autoSize: boolean; } declare enum VectorLinePointerType { vectorLine = "vectorLine" } declare enum VectorLineShape { straight = "straight", curve = "curve" } interface PlaitVectorLine extends PlaitElement { type: 'vector-line'; shape: VectorLineShape; points: Point[]; strokeColor?: string; strokeWidth?: number; strokeStyle?: StrokeStyle; fill?: string; opacity: number; } type PlaitLine = PlaitArrowLine | PlaitVectorLine; declare enum MemorizeKey { basicShape = "basicShape", flowchart = "flowchart", text = "text", arrowLine = "arrow-line", UML = "UML" } interface WithDrawOptions extends WithPluginOptions { customGeometryTypes: string[]; } type PlaitShapeElement = PlaitGeometry | PlaitImage | PlaitTable | PlaitSwimlane; type DrawShapes = GeometryShapes | TableSymbols | SwimlaneSymbols; type PlaitDrawElement = PlaitGeometry | PlaitArrowLine | PlaitVectorLine | PlaitImage | PlaitBaseTable | PlaitSwimlane; declare const PlaitDrawElement: { isGeometry: (value: any) => value is PlaitGeometry; isArrowLine: (value: any) => value is PlaitArrowLine; isVectorLine: (value: any) => value is PlaitVectorLine; isLine: (value: any) => value is PlaitLine; isText: (value: any) => value is PlaitText; isImage: (value: any) => value is PlaitImage; isTable: (value: any) => value is PlaitTable; isDrawElement: (value: any) => value is PlaitDrawElement; isCustomGeometryElement: (board: PlaitBoard, value: any) => value is PlaitCustomGeometry; isShapeElement: (value: any) => value is PlaitShapeElement; isBasicShape: (value: any) => boolean; isFlowchart: (value: any) => boolean; isUML: (value: any) => boolean; isSwimlane: (value: any) => value is PlaitSwimlane; isVerticalSwimlane: (value: any) => boolean; isHorizontalSwimlane: (value: any) => boolean; isUMLClassOrInterface: (value: any) => boolean; isGeometryByTable: (value: any) => value is PlaitBaseTable; isElementByTable: (value: any) => value is PlaitBaseTable; }; declare const withDraw: (board: PlaitBoard) => PlaitBoard; declare const WithArrowLineAutoCompletePluginKey = "plait-arrow-line-auto-complete-plugin-key"; interface ArrowLineAutoCompleteOptions { afterComplete: (element: PlaitArrowLine) => {}; } type PreCommitRef = { temporaryArrowLineElement: PlaitArrowLine; temporaryShapeElement: PlaitGeometry; }; declare const BOARD_TO_PRE_COMMIT: WeakMap<PlaitBoard, PreCommitRef>; declare const withArrowLineAutoComplete: (board: PlaitBoard) => PlaitBoard; declare const WithDrawPluginKey = "plait-draw-plugin-key"; declare enum DrawI18nKey { lineText = "line-text", geometryText = "geometry-text" } declare const ShapeDefaultSpace: { rectangleAndText: number; }; declare const DefaultDrawStyle: { strokeWidth: number; defaultRadius: number; strokeColor: string; fill: string; }; declare const DefaultDrawActiveStyle: { strokeWidth: number; selectionStrokeWidth: number; }; declare const DefaultBasicShapeProperty: { width: number; height: number; strokeColor: string; strokeWidth: number; }; declare const DefaultPentagonArrowProperty: { width: number; height: number; }; declare const DefaultTwoWayArrowProperty: { width: number; height: number; }; declare const DefaultArrowProperty: { width: number; height: number; }; declare const DefaultCloudProperty: { width: number; height: number; }; declare const DefaultTextProperty: { width: number; height: number; text: string; }; declare const GeometryThreshold: { defaultTextMaxWidth: number; }; declare const DefaultConnectorProperty: { width: number; height: number; }; declare const DefaultFlowchartProperty: { width: number; height: number; }; declare const DefaultDataBaseProperty: { width: number; height: number; }; declare const DefaultInternalStorageProperty: { width: number; height: number; }; declare const DefaultDecisionProperty: { width: number; height: number; }; declare const DefaultDataProperty: { width: number; height: number; }; declare const DefaultDocumentProperty: { width: number; height: number; }; declare const DefaultNoteProperty: { width: number; height: number; }; declare const DefaultMultiDocumentProperty: { width: number; height: number; }; declare const DefaultManualInputProperty: { width: number; height: number; }; declare const DefaultMergeProperty: { width: number; height: number; }; declare const DefaultActorProperty: { width: number; height: number; }; declare const DefaultContainerProperty: { width: number; height: number; }; declare const DefaultPackageProperty: { width: number; height: number; texts: { id: GeometryCommonTextKeys; text: string; align: Alignment; }[]; }; declare const DefaultActivationProperty: { width: number; height: number; }; declare const DefaultObjectProperty: { width: number; height: number; }; declare const DefaultComponentBoxProperty: { width: number; height: number; }; declare const DefaultDeletionProperty: { width: number; height: number; }; declare const DefaultPortProperty: { width: number; height: number; }; declare const DefaultRequiredInterfaceProperty: { width: number; height: number; }; declare const DefaultAssemblyProperty: { width: number; height: number; }; declare const DefaultProvidedInterfaceProperty: { width: number; height: number; }; declare const DefaultCombinedFragmentProperty: { width: number; height: number; texts: { id: GeometryCommonTextKeys; text: string; align: Alignment; }[]; }; declare const DefaultClassProperty: { width: number; height: number; texts: { text: string; align: Alignment; }[]; }; declare const DefaultInterfaceProperty: { width: number; height: number; texts: { text: string; align: Alignment; }[]; }; declare const DefaultBasicShapePropertyMap: Record<string, { width: number; height: number; }>; declare const DefaultFlowchartPropertyMap: { connector: { width: number; height: number; }; process: { width: number; height: number; }; decision: { width: number; height: number; }; data: { width: number; height: number; }; terminal: { width: number; height: number; }; manualInput: { width: number; height: number; }; preparation: { width: number; height: number; }; manualLoop: { width: number; height: number; }; merge: { width: number; height: number; }; delay: { width: number; height: number; }; storedData: { width: number; height: number; }; or: { width: number; height: number; }; summingJunction: { width: number; height: number; }; predefinedProcess: { width: number; height: number; }; offPage: { width: number; height: number; }; document: { width: number; height: number; }; multiDocument: { width: number; height: number; }; database: { width: number; height: number; }; hardDisk: { width: number; height: number; }; internalStorage: { width: number; height: number; }; noteCurlyLeft: { width: number; height: number; }; noteCurlyRight: { width: number; height: number; }; noteSquare: { width: number; height: number; }; display: { width: number; height: number; }; }; declare const DefaultUMLPropertyMap: { actor: { width: number; height: number; }; useCase: { width: number; height: number; }; container: { width: number; height: number; }; note: { width: number; height: number; }; package: { width: number; height: number; texts: { id: GeometryCommonTextKeys; text: string; align: Alignment; }[]; }; combinedFragment: { width: number; height: number; texts: { id: GeometryCommonTextKeys; text: string; align: Alignment; }[]; }; class: { width: number; height: number; texts: { text: string; align: Alignment; }[]; }; interface: { width: number; height: number; texts: { text: string; align: Alignment; }[]; }; activation: { width: number; height: number; }; object: { width: number; height: number; }; deletion: { width: number; height: number; }; activityClass: { width: number; height: number; }; simpleClass: { width: number; height: number; }; component: { width: number; height: number; }; template: { width: number; height: number; }; componentBox: { width: number; height: number; }; port: { width: number; height: number; }; branchMerge: { width: number; height: number; }; assembly: { width: number; height: number; }; providedInterface: { width: number; height: number; }; requiredInterface: { width: number; height: number; }; }; declare const MultipleTextGeometryTextKeys: { [key in GeometryShapes]?: string[]; }; declare const LINE_HIT_GEOMETRY_BUFFER = 4; declare const LINE_SNAPPING_BUFFER = 4; declare const LINE_SNAPPING_CONNECTOR_BUFFER = 4; declare const LINE_ALIGN_TOLERANCE = 4; declare const GEOMETRY_WITHOUT_TEXT: GeometryShapes[]; declare const GEOMETRY_WITH_MULTIPLE_TEXT: UMLSymbols[]; declare const GEOMETRY_NOT_CLOSED: GeometryShapes[]; type DrawPointerType = BasicShapes | ArrowLineShape | FlowchartSymbols | SwimlaneDrawSymbols | TableSymbols | UMLSymbols | VectorLinePointerType; declare const getGeometryPointers: () => string[]; declare const getSwimlanePointers: () => string[]; declare const getSwimlaneShapes: () => string[]; declare const getBasicPointers: () => string[]; declare const getFlowchartPointers: () => string[]; declare const getUMLPointers: () => string[]; declare const getArrowLinePointers: () => string[]; declare const getVectorLinePointers: () => string[]; declare const DEFAULT_IMAGE_WIDTH = 1000; declare const DrawThemeColors: { default: { strokeColor: string; fill: string; }; colorful: { strokeColor: string; fill: string; }; soft: { strokeColor: string; fill: string; }; retro: { strokeColor: string; fill: string; }; dark: { strokeColor: string; fill: string; }; starry: { strokeColor: string; fill: string; }; }; declare const SWIMLANE_HEADER_SIZE = 42; declare const DefaultSwimlaneVerticalWithHeaderProperty: { width: number; height: number; }; declare const DefaultSwimlaneHorizontalWithHeaderProperty: { width: number; height: number; }; declare const DefaultSwimlaneVerticalProperty: { width: number; height: number; }; declare const DefaultSwimlaneHorizontalProperty: { width: number; height: number; }; declare const DefaultSwimlanePropertyMap: Record<string, { width: number; height: number; }>; declare const MIN_TEXT_WIDTH = 5; declare const DefaultLineStyle: { strokeWidth: number; strokeColor: string; }; declare const LINE_TEXT_SPACE = 4; declare const LINE_AUTO_COMPLETE_DIAMETER = 6; declare const LINE_AUTO_COMPLETE_OPACITY = 1; declare const LINE_AUTO_COMPLETE_HOVERED_OPACITY = 1; declare const LINE_AUTO_COMPLETE_HOVERED_DIAMETER = 12; declare const LINE_TEXT = "\u6587\u672C"; declare const isSelfLoop: (element: PlaitArrowLine) => boolean | "" | undefined; declare const isUseDefaultOrthogonalRoute: (element: PlaitArrowLine, options: ElbowLineRouteOptions) => boolean; declare const getElbowPoints: (board: PlaitBoard, element: PlaitArrowLine) => Point[]; declare const getNextSourceAndTargetPoints: (board: PlaitBoard, element: PlaitArrowLine) => Point[]; declare const getSourceAndTargetRectangle: (board: PlaitBoard, element: PlaitArrowLine, handleRefPair: ArrowLineHandleRefPair) => { sourceRectangle: RectangleClient; targetRectangle: RectangleClient; }; declare function getNextRenderPoints(board: PlaitBoard, element: PlaitArrowLine, renderPoints?: Point[]): Point[]; declare const drawArrowLineArrow: (element: PlaitArrowLine, points: Point[], options: Options) => SVGGElement | null; declare const createArrowLineElement: (shape: ArrowLineShape, points: [Point, Point], source: ArrowLineHandle, target: ArrowLineHandle, texts?: ArrowLineText[], options?: Pick<PlaitArrowLine, "strokeColor" | "strokeWidth">) => PlaitArrowLine; declare const getArrowLinePoints: (board: PlaitBoard, element: PlaitArrowLine) => Point[]; declare const getCurvePoints: (board: PlaitBoard, element: PlaitArrowLine) => Point[]; declare const drawArrowLine: (board: PlaitBoard, element: PlaitArrowLine) => SVGGElement; declare const getHitConnection: (board: PlaitBoard, point: Point, hitElement: PlaitShapeElement) => Point; declare const getHitConnectionFromConnectionPoint: (connectionPoint: Point, hitElement: PlaitShapeElement) => Point; declare const getHitConnectorPoint: (point: Point, hitElement: PlaitShapeElement) => Point | undefined; declare const getArrowLineTextRectangle: (board: PlaitBoard, element: PlaitArrowLine, index: number) => RectangleClient; declare const getArrowLines: (board: PlaitBoard) => PlaitArrowLine[]; declare const Q2C: (points: Point[]) => Point[]; declare const handleArrowLineCreating: (board: PlaitBoard, lineShape: ArrowLineShape, sourcePoint: Point, movingPoint: Point, sourceElement: PlaitShapeElement | null, lineShapeG: SVGGElement, options?: Pick<PlaitArrowLine, "strokeColor" | "strokeWidth">) => PlaitArrowLine; declare const getArrowLineHandleRefPair: (board: PlaitBoard, element: PlaitArrowLine) => ArrowLineHandleRefPair; declare const getConnectionPoint: (geometry: PlaitShapeElement, connection: Point, direction?: Direction, delta?: number) => Point; declare const getVectorByConnection: (boundElement: PlaitShapeElement, connection: PointOfRectangle) => Vector; declare const getElbowLineRouteOptions: (board: PlaitBoard, element: PlaitArrowLine, handleRefPair?: ArrowLineHandleRefPair) => { sourcePoint: PointOfRectangle; nextSourcePoint: Point; sourceRectangle: RectangleClient; sourceOuterRectangle: { x: number; y: number; width: number; height: number; }; targetPoint: PointOfRectangle; nextTargetPoint: Point; targetRectangle: RectangleClient; targetOuterRectangle: { x: number; y: number; width: number; height: number; }; }; declare const collectArrowLineUpdatedRefsByGeometry: (board: PlaitBoard, element: PlaitShapeElement, refs: { property: Partial<PlaitArrowLine>; path: Path; }[]) => void; declare const alignPoint: (basePoint: Point, movingPoint: Point) => Point; declare const alignPoints: (basePoints: Point[], movingPoint: Point, targetIndex?: number) => Point; declare function getResizedPreviousAndNextPoint(nextRenderPoints: Point[], sourcePoint: Point, targetPoint: Point, handleIndex: number): { previous: Point | null; next: Point | null; }; declare function alignElbowSegment(startKeyPoint: Point, endKeyPoint: Point, resizeState: ResizeState, resizedPreviousAndNextPoint: { previous: Point | null; next: Point | null; }): Point[]; declare function getIndexAndDeleteCountByKeyPoint(board: PlaitBoard, element: PlaitArrowLine, dataPoints: Point[], nextRenderPoints: Point[], handleIndex: number): { index: null; deleteCount: null; } | { index: number; deleteCount: number | null; }; declare function getMirrorDataPoints(board: PlaitBoard, nextDataPoints: Point[], nextKeyPoints: Point[], params: ElbowLineRouteOptions): Point[]; declare function isUpdatedHandleIndex(board: PlaitBoard, element: PlaitArrowLine, dataPoints: Point[], nextRenderPoints: Point[], handleIndex: number): boolean; declare function getMidKeyPoints(simplifiedNextKeyPoints: Point[], startPoint: Point, endPoint: Point): Point[]; declare const hasIllegalElbowPoint: (midDataPoints: Point[]) => boolean; type GeometryStyleOptions = Pick<PlaitGeometry, 'fill' | 'strokeColor' | 'strokeWidth'>; type TextProperties = Partial<CustomText> & { align?: Alignment; }; declare const createGeometryElement: (shape: GeometryShapes, points: [Point, Point], text: string | Element, options?: GeometryStyleOptions, textProperties?: TextProperties) => PlaitGeometry; declare const createGeometryElementWithText: (shape: GeometryShapes, points: [Point, Point], text: string | Element, options?: GeometryStyleOptions, textProperties?: TextProperties) => PlaitGeometry; declare const createGeometryElementWithoutText: (shape: GeometryShapes, points: [Point, Point], options?: GeometryStyleOptions) => PlaitGeometry; declare const drawGeometry: (board: PlaitBoard, outerRectangle: RectangleClient, shape: GeometryShapes, roughOptions: Options) => SVGGElement; declare const getNearestPoint: (element: PlaitShapeElement, point: Point) => Point; declare const getCenterPointsOnPolygon: (points: Point[]) => Point[]; declare const getDefaultFlowchartProperty: (symbol: FlowchartSymbols) => { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; }; declare const getDefaultBasicShapeProperty: (shape: BasicShapes) => { width: number; height: number; }; declare const getDefaultUMLProperty: (shape: UMLSymbols) => { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; texts: { id: _plait_draw.GeometryCommonTextKeys; text: string; align: Alignment; }[]; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; } | { width: number; height: number; texts: { id: _plait_draw.GeometryCommonTextKeys; text: string; align: Alignment; }[]; } | { width: number; height: number; texts: { text: string; align: Alignment; }[]; } | { width: number; height: number; texts: { text: string; align: Alignment; }[]; }; declare const getAutoCompletePoints: (board: PlaitBoard, element: PlaitShapeElement, isToActive?: boolean) => [Point, Point, Point, Point]; declare const getHitIndexOfAutoCompletePoint: (movingPoint: Point, points: Point[]) => number; declare const getDrawDefaultStrokeColor: (theme: ThemeColorMode) => string; declare const getFlowchartDefaultFill: (theme: ThemeColorMode) => string; declare const getTextShapeProperty: (board: PlaitBoard, text: string | Element, fontSize?: number | string) => { width: number; height: number; }; declare const getDefaultGeometryPoints: (pointer: DrawPointerType, centerPoint: Point) => [Point, Point]; declare const getDefaultGeometryProperty: (pointer: DrawPointerType) => { width: number; height: number; }; declare const getDefaultTextPoints: (board: PlaitBoard, centerPoint: Point, fontSize?: number | string) => [Point, Point]; declare const createTextElement: (board: PlaitBoard, points: [Point, Point], text: string | Element) => PlaitGeometry; declare const createDefaultGeometry: (board: PlaitBoard, points: [Point, Point], shape: GeometryShapes) => _plait_draw.PlaitCommonGeometry<"geometry", [Point, Point], GeometryShapes>; declare const editText: (board: PlaitBoard, element: PlaitGeometry, text?: DrawTextInfo) => void; declare const isGeometryIncludeText: (element: PlaitGeometry) => boolean; declare const isSingleTextShape: (shape: GeometryShapes) => boolean; declare const isSingleTextGeometry: (element: PlaitGeometry) => boolean; declare const isGeometryClosed: (element: PlaitGeometry) => boolean; declare const isMultipleTextShape: (shape: GeometryShapes) => boolean; declare const isMultipleTextGeometry: (geometry: PlaitElement) => geometry is PlaitMultipleTextGeometry; declare const getMultipleTextGeometryTextKeys: (shape: GeometryShapes) => string[] | undefined; declare const createMultipleTextGeometryElement: (shape: GeometryShapes, points: [Point, Point], options?: GeometryStyleOptions) => PlaitMultipleTextGeometry; declare const buildDefaultTextsByShape: (shape: GeometryShapes) => DrawTextInfo[]; declare const getHitMultipleGeometryText: (board: PlaitBoard, element: PlaitMultipleTextGeometry, point: Point) => DrawTextInfo | undefined; declare const createUMLClassOrInterfaceGeometryElement: (board: PlaitBoard, shape: GeometryShapes, points: [Point, Point]) => PlaitCommonGeometry; declare const getSelectedDrawElements: (board: PlaitBoard, elements?: PlaitElement[]) => PlaitDrawElement[]; declare const getSelectedGeometryElements: (board: PlaitBoard) => PlaitGeometry[]; declare const getSelectedCustomGeometryElements: (board: PlaitBoard) => PlaitCustomGeometry<string, _plait_core.Point[], string>[]; declare const getSelectedArrowLineElements: (board: PlaitBoard) => PlaitArrowLine[]; declare const getSelectedVectorLineElements: (board: PlaitBoard) => PlaitVectorLine[]; declare const getSelectedImageElements: (board: PlaitBoard) => PlaitImage[]; declare const isSingleSelectSwimlane: (board: PlaitBoard) => boolean; declare const isSingleSelectLine: (board: PlaitBoard) => boolean; declare const getSelectedSwimlane: (board: PlaitBoard) => PlaitSwimlane; declare const getStrokeColorByElement: (board: PlaitBoard, element: PlaitElement) => any; declare const getFillByElement: (board: PlaitBoard, element: PlaitElement) => any; declare const getStrokeStyleByElement: (board: PlaitBoard, element: PlaitElement) => any; declare const isHitArrowLineText: (board: PlaitBoard, element: PlaitArrowLine, point: Point) => boolean; declare const isHitPolyLine: (pathPoints: Point[], point: Point) => boolean; declare const isHitArrowLine: (board: PlaitBoard, element: PlaitArrowLine, point: Point) => boolean; declare const isHitVectorLine: (board: PlaitBoard, element: PlaitVectorLine, point: Point) => boolean; declare const isRectangleHitElementText: (board: PlaitBoard, element: PlaitCommonGeometry, rectangle: RectangleClient) => boolean; declare const isHitElementText: (board: PlaitBoard, element: PlaitCommonGeometry, point: Point) => boolean; declare const isEmptyTextElement: (element: PlaitCommonGeometry) => boolean; declare const isRectangleHitDrawElement: (board: PlaitBoard, element: PlaitElement, selection: Selection) => boolean | null; declare const isRectangleHitRotatedElement: (board: PlaitBoard, rectangle: RectangleClient, element: PlaitElement & { points: Point[]; }) => boolean; declare const isRectangleHitRotatedPoints: (rectangle: RectangleClient, points: Point[], angle: number | undefined) => boolean; declare const getHitDrawElement: (board: PlaitBoard, elements: (PlaitDrawElement | PlaitCustomGeometry)[]) => PlaitElement; declare const getFirstFilledDrawElement: (board: PlaitBoard, elements: (PlaitDrawElement | PlaitCustomGeometry)[]) => PlaitGeometry | PlaitCustomGeometry<string, Point[], string> | null; declare const isFilledDrawElement: (board: PlaitBoard, element: PlaitDrawElement | PlaitCustomGeometry) => boolean; declare const getSolidElements: (elements: PlaitElement[]) => (_plait_draw.PlaitImage | PlaitLine | _plait_draw.PlaitText)[] | null; declare const isHitDrawElement: (board: PlaitBoard, element: PlaitElement, point: Point, isStrict?: boolean) => boolean | null; declare const isHitEdgeOfShape: (board: PlaitBoard, element: PlaitShapeElement, point: Point, hitDistanceBuffer: number) => boolean; declare const isInsideOfShape: (board: PlaitBoard, element: PlaitShapeElement, point: Point, hitDistanceBuffer: number) => boolean; declare const isHitElementInside: (board: PlaitBoard, element: PlaitElement, point: Point) => boolean | null; declare const getMemorizeKey: (element: PlaitElement) => string; declare const getLineMemorizedLatest: () => { [key: string]: any; id: string; children?: PlaitElement[]; points?: _plait_core.Point[]; type?: string; groupId?: string; angle?: number; }; declare const getMemorizedLatestByPointer: (pointer: DrawPointerType) => { textProperties: any; geometryProperties: { [key: string]: any; id: string; children?: PlaitElement[]; points?: _plait_core.Point[]; type?: string; groupId?: string; angle?: number; }; }; declare const memorizeLatestText: <T extends PlaitElement = PlaitDrawElement>(element: T, operations: BaseOperation[]) => void; declare const memorizeLatestShape: (board: PlaitBoard, shape: GeometryShapes) => void; declare const getMemorizedLatestShape: (board: PlaitBoard) => GeometryShapes[] | undefined; declare const getTextRectangle: <T extends PlaitElement = PlaitGeometry>(board: PlaitBoard, element: T) => { height: number; width: number; x: any; y: number; }; declare const getCustomTextRectangle: <T extends PlaitElement = PlaitGeometry>(board: PlaitBoard, element: T, widthRatio: number) => { height: number; width: number; x: number; y: number; }; declare const getStrokeWidthByElement: (element: PlaitElement) => any; declare const insertElement: (board: PlaitBoard, element: PlaitBaseGeometry | PlaitBaseTable) => void; declare const isDrawElementIncludeText: (element: PlaitDrawElement) => boolean; declare const isDrawElementsIncludeText: (elements: PlaitDrawElement[]) => boolean; declare const isClosedDrawElement: (element: PlaitElement) => boolean; declare const isClosedCustomGeometry: (board: PlaitBoard, value: PlaitElement) => value is PlaitCustomGeometry; declare const getSnappingShape: (board: PlaitBoard, point: Point) => PlaitShapeElement | null; declare const getSnappingRef: (board: PlaitBoard, hitElement: PlaitShapeElement, point: Point) => { isHitEdge: boolean; isHitConnector: boolean; connectorPoint: Point | undefined; edgePoint: Point; }; declare const getHitShape: (board: PlaitBoard, point: Point, offset?: number) => PlaitShapeElement | null; declare const traverseDrawShapes: (board: PlaitBoard, callback: (element: PlaitShapeElement) => void) => void; declare const drawShape: (board: PlaitBoard, outerRectangle: RectangleClient, shape: DrawShapes, roughOptions: Options, drawOptions?: DrawOptions) => SVGGElement; declare const drawBoundReaction: (board: PlaitBoard, element: PlaitShapeElement, roughOptions?: { hasMask: boolean; hasConnector: boolean; }) => SVGGElement; declare const getTextKey: (element: PlaitElement | undefined, text: Pick<DrawTextInfo, "id">) => string; declare const getGeometryAlign: (board: PlaitBoard, element: PlaitCommonGeometry | PlaitBaseTable) => Alignment; declare const isClosedPoints: (points: Point[]) => boolean; declare const getDefaultGeometryText: (board: PlaitBoard) => string; declare const debugGenerator: _plait_core.DebugGenerator; interface ResizeSnapRef extends SnapRef { xZoom: number; yZoom: number; activePoints: Point[]; } interface ResizeSnapOptions { resizePoints: Point[]; activeRectangle: RectangleClient; directionFactors: DirectionFactors; isFromCorner: boolean; isAspectRatio: boolean; resizeOriginPoint?: Point[]; originPoint?: Point; handlePoint?: Point; isCreate?: boolean; } declare function getSnapResizingRefOptions(board: PlaitBoard, resizeRef: ResizeRef<PlaitDrawElement | PlaitCustomGeometry | (PlaitDrawElement | PlaitCustomGeometry)[]>, resizeState: ResizeState, resizeOriginPointAndHandlePoint: { originPoint: Point; handlePoint: Point; }, isAspectRatio: boolean, isFromCorner: boolean): ResizeSnapOptions; declare function getSnapResizingRef(board: PlaitBoard, activeElements: PlaitElement[], resizeSnapOptions: ResizeSnapOptions): ResizeSnapRef; declare function getCellsWithPoints(board: PlaitBoard, element: PlaitBaseTable): PlaitTableCellWithPoints[]; declare function getCellWithPoints(board: PlaitBoard, table: PlaitBaseTable, cellId: string): PlaitTableCellWithPoints; declare function getHitCell(board: PlaitTableBoard, element: PlaitBaseTable, point: Point): PlaitTableCell | null | undefined; declare function editCell(board: PlaitBoard, cell: PlaitTableCell): void; declare function getTextManageByCell(board: PlaitBoard, cell: PlaitTableCell): _plait_common.TextManage; declare const updateColumns: (table: PlaitBaseTable, columnId: string, width: number, offset: number) => { columns: { id: string; width?: number; }[]; points: Point[]; }; declare const updateRows: (table: PlaitBaseTable, rowId: string, height: number, offset: number) => { rows: { id: string; height?: number; }[]; points: Point[]; }; declare function updateCellIdsByRowOrColumn(cells: PlaitTableCell[], oldId: string, newId: string, type: 'row' | 'column'): void; declare function updateRowOrColumnIds(element: PlaitTable, type: 'row' | 'column'): void; declare function updateCellIds(cells: PlaitTableCell[]): void; declare function isCellIncludeText(cell: PlaitTableCell): _plait_draw.PlaitTableCellParagraph | undefined; declare function getCellsRectangle(board: PlaitTableBoard, element: PlaitTable, cells: PlaitTableCell[]): RectangleClient; declare const createCell: (rowId: string, columnId: string, text?: string | null) => PlaitTableCell; declare const getSelectedTableCellsEditor: (board: PlaitBoard) => BaseEditor[] | undefined; declare const isSingleSelectTable: (board: PlaitBoard) => boolean; declare const getSelectedTableElements: (board: PlaitBoard, elements?: PlaitElement[]) => PlaitTable[]; declare const SELECTED_CELLS: WeakMap<PlaitBaseTable, PlaitTableCell[]>; declare function getSelectedCells(element: PlaitBaseTable): PlaitTableCell[] | undefined; declare function setSelectedCells(element: PlaitBaseTable, cells: PlaitTableCell[]): WeakMap<PlaitBaseTable, PlaitTableCell[]>; declare function clearSelectedCells(element: PlaitBaseTable): boolean; declare function buildSwimlaneTable(element: PlaitSwimlane): { [key: string]: any; type: "swimlane"; shape: SwimlaneSymbols; header?: boolean; id: string; points: Point[]; rows: { id: string; height?: number; }[]; columns: { id: string; width?: number; }[]; cells: PlaitTableCell[]; groupId?: string; children?: _plait_core.PlaitElement[]; angle?: number; }; declare const getDefaultSwimlanePoints: (pointer: SwimlaneDrawSymbols, centerPoint: Point) => [Point, Point]; declare const createDefaultSwimlane: (shape: SwimlaneDrawSymbols, points: [Point, Point]) => PlaitSwimlane; declare const createDefaultRowsOrColumns: (shape: SwimlaneSymbols, type: "row" | "column", header: boolean, size: number) => { id: string; }[]; declare const createDefaultCells: (shape: SwimlaneSymbols, rows: { id: string; height?: number; }[], columns: { id: string; width?: number; }[], header: boolean) => PlaitTableCell[]; declare const getSwimlaneCount: (swimlane: PlaitSwimlane) => number; declare const isSwimlaneWithHeader: (shape: SwimlaneDrawSymbols) => boolean; declare const isSwimlaneShape: (shape: SwimlaneSymbols) => boolean; declare const adjustSwimlaneShape: (shape: SwimlaneDrawSymbols) => SwimlaneSymbols; declare const isSwimlanePointers: (board: PlaitBoard, pointer?: string) => boolean; declare function getMiddlePoints(board: PlaitBoard, element: PlaitLine): Point[]; declare const getVectorLinePoints: (board: PlaitBoard, element: PlaitVectorLine) => Point[] | null; declare const createVectorLineElement: (shape: VectorLineShape, points: Point[], options?: Pick<PlaitVectorLine, "strokeColor" | "strokeWidth" | "fill">) => PlaitVectorLine; declare const vectorLineCreating: (board: PlaitBoard, lineShape: VectorLineShape, points: Point[], movingPoint: Point, lineShapeG: SVGGElement) => PlaitVectorLine; declare const drawVectorLine: (board: PlaitBoard, element: PlaitVectorLine) => SVGGElement; declare const buildClipboardData: (board: PlaitBoard, elements: PlaitDrawElement[], startPoint: Point) => (PlaitElement | { points: number[][]; id: string; children?: PlaitElement[]; type?: string; groupId?: string; angle?: number; })[]; declare const insertClipboardData: (board: PlaitBoard, elements: PlaitDrawElement[], startPoint: Point) => void; interface ShapeData { } declare class GeometryShapeGenerator extends Generator<PlaitGeometry, ShapeData> { canDraw(element: PlaitGeometry, data: ShapeData): boolean; draw(element: PlaitGeometry, data: ShapeData): SVGGElement | undefined; } declare class ArrowLineAutoCompleteGenerator<T extends PlaitShapeElement = PlaitGeometry> extends Generator<T, ActiveGeneratorExtraData> { board: PlaitBoard; static key: string; autoCompleteG: SVGGElement; hoverElement: SVGGElement | null; constructor(board: PlaitBoard); canDraw(element: PlaitShapeElement, data: ActiveGeneratorExtraData): boolean; draw(element: T, data: ActiveGeneratorExtraData): SVGGElement; removeAutoCompleteG(index: number): void; recoverAutoCompleteG(): void; } declare class SingleTextGenerator<T extends PlaitElement = PlaitGeometry> extends TextGenerator<T> { get textManage(): _plait_common.TextManage; constructor(board: PlaitBoard, element: T, text: ParagraphElement, options: TextGeneratorOptions<T>); update(element: T, previousDrawShapeTexts: DrawTextInfo[], currentDrawShapeTexts: DrawTextInfo[], elementG: SVGElement): void; update(element: T, previousText: ParagraphElement, currentText: ParagraphElement, elementG: SVGElement): void; } declare class GeometryComponent extends CommonElementFlavour<PlaitCommonGeometry, PlaitBoard> implements OnContextChanged<PlaitCommonGeometry, PlaitBoard> { activeGenerator: ActiveGenerator<PlaitCommonGeometry>; lineAutoCompleteGenerator: ArrowLineAutoCompleteGenerator; shapeGenerator: GeometryShapeGenerator; textGenerator: TextGenerator<PlaitMultipleTextGeometry> | SingleTextGenerator; constructor(); initializeGenerator(): void; initialize(): void; onContextChanged(value: PlaitPluginElementContext<PlaitCommonGeometry, PlaitBoard>, previous: PlaitPluginElementContext<PlaitCommonGeometry, PlaitBoard>): void; updateText(previousElement: PlaitCommonGeometry, currentElement: PlaitCommonGeometry): void; initializeTextManage(): void; destroy(): void; } interface ActiveData { selected: boolean; linePoints: Point[]; } declare class LineActiveGenerator extends Generator<PlaitLine, ActiveData> { protected board: PlaitBoard; onlySelectedCurrentLine: boolean; constructor(board: PlaitBoard, options?: { active: boolean; }); canDraw(element: PlaitLine, data: ActiveData): boolean; draw(element: PlaitLine, data: ActiveData): SVGGElement; needUpdate(): boolean; } declare class ArrowLineShapeGenerator extends Generator<PlaitArrowLine> { canDraw(element: PlaitArrowLine): boolean; draw(element: PlaitArrowLine): SVGGElement; } interface BoundedElements { source?: PlaitGeometry; target?: PlaitGeometry; } declare class ArrowLineComponent extends CommonElementFlavour<PlaitArrowLine, PlaitBoard> implements OnContextChanged<PlaitArrowLine, PlaitBoard> { shapeGenerator: ArrowLineShapeGenerator; activeGenerator: LineActiveGenerator; boundedElements: BoundedElements; constructor(); initializeGenerator(): void; initialize(): void; getBoundedElements(): BoundedElements; onContextChanged(value: PlaitPluginElementContext<PlaitArrowLine, PlaitBoard>, previous: PlaitPluginElementContext<PlaitArrowLine, PlaitBoard>): void; initializeTextManages(): void; drawText(): void; createTextManage(text: ArrowLineText, index: number): TextManage; updateText(previousTexts: ArrowLineText[], currentTexts: ArrowLineText[]): void; updateTextRectangle(): void; destroy(): void; } declare class VectorLineShapeGenerator extends Generator<PlaitVectorLine> { canDraw(element: PlaitVectorLine): boolean; draw(element: PlaitVectorLine): SVGGElement; } declare class VectorLineComponent extends CommonElementFlavour<PlaitVectorLine, PlaitBoard> implements OnContextChanged<PlaitVectorLine, PlaitBoard> { shapeGenerator: VectorLineShapeGenerator; activeGenerator: LineActiveGenerator; constructor(); initializeGenerator(): void; initialize(): void; onContextChanged(value: PlaitPluginElementContext<PlaitVectorLine, PlaitBoard>, previous: PlaitPluginElementContext<PlaitVectorLine, PlaitBoard>): void; destroy(): void; } declare const DrawTransforms: { setText: (board: _plait_core.PlaitBoard, element: _plait_draw.PlaitGeometry, text: slate.Element, width: number, height: number) => void; setDrawTexts: (board: _plait_core.PlaitBoard, element: _plait_draw.PlaitMultipleTextGeometry, text: _plait_draw.DrawTextInfo) => void; insertGeometry: (board: _plait_core.PlaitBoard, points: [_plait_core.Point, _plait_core.Point], shape: _plait_draw.GeometryShapes) => _plait_draw.PlaitCommonGeometry<"geometry", [_plait_core.Point, _plait_core.Point], _plait_draw.GeometryShapes>; resizeGeometry: (board: _plait_core.PlaitBoard, points: [_plait_core.Point, _plait_core.Point], path: _plait_core.Path) => void; insertText: (board: _plait_core.PlaitBoard, point: _plait_core.Point, text: st