import type { ICxnShapeData, IShapeRelationItem, ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeTypeEnum } from '@univerjs-pro/engine-shape'; import type { Injector } from '@univerjs/core'; import type { IShapeBuilderInfo } from './f-shape'; import { FShape } from './f-shape'; /** * The connector shape builder. It extends `FShape` and adds connector-specific properties * such as start/end arrow types and sizes. Use `fWorksheet.newConnector()` to create a new connector builder. * * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * * // Create a straight connector with arrows * const connectorInfo = fWorksheet.newConnector() * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1) * .setPosition(1, 1, 0, 0) * .setWidth(200) * .setHeight(100) * .setStartArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow) * .setEndArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow) * .setStrokeColor('#000000') * .setStrokeWidth(2) * .build(); * await fWorksheet.insertShape(connectorInfo); * ``` */ export declare class FConnectorShape extends FShape { /** * @property {ICxnShapeData} shapeData The connector shape data containing line styles, arrow settings, and connection info. */ shapeData: ICxnShapeData; constructor(unitId: string, subUnitId: string, drawingId: string, injector: Injector); setShapeType(shapeType: ShapeTypeEnum): this; /** * Sets the start arrow type of the connector line. * @param {ShapeArrowTypeEnum} arrowType The arrow type for the start point. Which can be found from `univerAPI.Enum.ShapeArrowTypeEnum`. * @returns {FConnectorShape} this builder, for chaining. * * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * * const connectorInfo = fWorksheet.newConnector() * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1) * .setStartArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow) * .setPosition(1, 1, 0, 0) * .build(); * await fWorksheet.insertShape(connectorInfo); * ``` */ setStartArrowType(arrowType: ShapeArrowTypeEnum): this; /** * Sets the end arrow type of the connector line. * @param {ShapeArrowTypeEnum} arrowType The arrow type for the end point. Which can be found from `univerAPI.Enum.ShapeArrowTypeEnum`. * @returns {FConnectorShape} this builder, for chaining. * * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * * const connectorInfo = fWorksheet.newConnector() * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1) * .setEndArrowType(univerAPI.Enum.ShapeArrowTypeEnum.StealthArrow) * .setPosition(1, 1, 0, 0) * .build(); * await fWorksheet.insertShape(connectorInfo); * ``` */ setEndArrowType(arrowType: ShapeArrowTypeEnum): this; /** * Sets the start arrow size of the connector line. * @param {ShapeArrowSizeEnum} arrowSize The arrow size for the start point. * @returns {FConnectorShape} this builder, for chaining. * * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * * const connectorInfo = fWorksheet.newConnector() * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1) * .setStartArrowType(univerAPI.Enum.ShapeArrowTypeEnum.OvalArrow) * .setStartArrowSize(univerAPI.Enum.ShapeArrowSizeEnum.Large) * .setPosition(1, 1, 0, 0) * .setWidth(200) * .build(); * await fWorksheet.insertShape(connectorInfo); * ``` */ setStartArrowSize(arrowSize: ShapeArrowSizeEnum): this; /** * Sets the end arrow size of the connector line. * @param {ShapeArrowSizeEnum} arrowSize The arrow size for the end point. * @returns {FConnectorShape} this builder, for chaining. * * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * * const connectorInfo = fWorksheet.newConnector() * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1) * .setEndArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow) * .setEndArrowSize(univerAPI.Enum.ShapeArrowSizeEnum.Large) * .setStrokeWidth(3) * .setPosition(1, 1, 0, 0) * .build(); * await fWorksheet.insertShape(connectorInfo); * ``` */ setEndArrowSize(arrowSize: ShapeArrowSizeEnum): this; /** * Builds the connector shape builder info. This method does not automatically draw the connector on top of the spreadsheet. * A new connector must be inserted via `fWorksheet.insertShape(shapeInfo)`. * @returns {IShapeBuilderInfo} The shape builder info containing all the accumulated properties. * * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * * const connectorInfo = fWorksheet.newConnector() * .setShapeType(univerAPI.Enum.ShapeTypeEnum.StraightConnector1) * .setPosition(1, 1, 0, 0) * .setWidth(200) * .setHeight(100) * .setStartArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow) * .setEndArrowType(univerAPI.Enum.ShapeArrowTypeEnum.Arrow) * .setStrokeColor('#000000') * .setStrokeWidth(2) * .build(); * await fWorksheet.insertShape(connectorInfo); * ``` */ build(): IShapeBuilderInfo; /** * Returns the end connection info for this connector shape. * If this connector's end point is connected to a basic shape, returns the target shape id and connection site index. * @returns {IShapeRelationItem | null} The end connection info, or `null` if not connected. * * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * const shapes = fWorksheet.getShapes(); * const connector = shapes.find((s) => s.isLineShape()); * * if (connector) { * const endInfo = connector.getEndConnectInfo(); * if (endInfo) { * console.log(`End connected to shape ${endInfo.shapeId} at site ${endInfo.cxnIndex}`); * } * } * ``` */ getEndConnectInfo(): IShapeRelationItem | null; /** * Returns the start connection info for this connector shape. * If this connector's start point is connected to a basic shape, returns the target shape id and connection site index. * @returns {IShapeRelationItem | null} The start connection info, or `null` if not connected. * * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * const shapes = fWorksheet.getShapes(); * const connector = shapes.find((s) => s.isLineShape()); * * if (connector) { * const startInfo = connector.getStartConnectInfo(); * if (startInfo) { * console.log(`Start connected to shape ${startInfo.shapeId} at site ${startInfo.cxnIndex}`); * } * } * ``` */ getStartConnectInfo(): IShapeRelationItem | null; }