UNPKG

@plait/draw

Version:

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

42 lines (41 loc) 1.9 kB
import { ParagraphElement, TextManage, TextManageChangeData } from '@plait/common'; import { PlaitBoard, PlaitElement, RectangleClient } from '@plait/core'; import { DrawShapes, PlaitGeometry, TextRectangleOptions } from '../interfaces'; export interface DrawTextInfo extends TextRectangleOptions { text: ParagraphElement; textHeight: number; } export interface TextGeneratorOptions<T> { onChange: (element: T, textChangeRef: TextManageChangeData, text: DrawTextInfo) => void; getRenderRectangle?: (element: T, text: DrawTextInfo) => RectangleClient; getMaxWidth?: () => number; } export declare const KEY_TO_TEXT_MANAGE: WeakMap<PlaitBoard, { [key: string]: TextManage; }>; export declare const setTextManage: (board: PlaitBoard, element: PlaitElement, text: DrawTextInfo, textManage: TextManage) => WeakMap<PlaitBoard, { [key: string]: TextManage; }>; export declare const getTextManage: (board: PlaitBoard, element: PlaitElement | undefined, text: Pick<DrawTextInfo, "id">) => TextManage; export declare const deleteTextManage: (board: PlaitBoard, key: string) => void; export 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: any; width: number; x: any; y: number; }; getMaxWidth(text: DrawTextInfo): number; destroy(): void; }