@univerjs-pro/engine-shape 0.24.0 → 0.25.0-insiders.20260608-e4336f7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- export { BasicShapeModel as ShapeModel } from '../src/model/shape-model';
1
+ export { BasicShapeModel as ShapeModel } from '../src/models/shape-model';
2
2
  export { LineShapeRenderModel } from '../src/render-engine/line-shape-render-model';
3
3
  export { BaseShapeRenderModel } from '../src/render-engine/shape-render-model';
4
4
  export { BasicShapeEnum, ImageFillModeEnum, ImageSourceTypeEnum, ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeFillEnum, ShapeGradientTypeEnum, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeLineTypeEnum, ShapeOperatorEnum, ShapeRenderModeEnum, ShapeSketchTypeEnum, ShapeTypeEnum } from '../src/shape-enum';
5
- export type { IBasicShapeData, IConnectorLayoutResult, IConnectorRouteLayoutResult, IConnectPointInfo, ICustomShapeTextData, ICxnShapeData, IDrawingRect, IGdContext, IGdContextBase, ILineType, IPathCommand, IPresetShapeConfig, IShapeAdjustItem, IShapeAdjustItemResolved, IShapeContextOptions, IShapeData, IShapeHitTestResult, IShapeJSONData, IShapeLineStyle, IShapeModel, IShapePath, IShapePoint, IShapePointWithAdjName, IShapeRect, IShapeRelation, IShapeRelationItem, IShapeRenderParameters, IShapeText, ShapeAdjustHandleTypeEnum, ShapeHitTestHitTypeEnum, } from '../src/shape-type';
5
+ export type { IBasicShapeData, IConnectorLayoutResult, IConnectorRouteLayoutResult, IConnectPointInfo, ICustomShapeTextData, ICxnShapeData, IDrawingRect, IGdContext, IGdContextBase, ILineType, IPathCommand, IPresetShapeConfig, IShapeAdjustItem, IShapeAdjustItemResolved, IShapeContextOptions, IShapeData, IShapeHitTestResult, IShapeJSONData, IShapeLineStyle, IShapeModel, IShapePath, IShapePoint, IShapePointWithAdjName, IShapeRect, IShapeRelation, IShapeRelationItem, IShapeRenderParameters, IShapeText, ShapeAdjustHandleTypeEnum, ShapeHitTestHitTypeEnum, ShapeTextDirection, } from '../src/shape-type';
6
6
  export { AccentBorderCallout1Shape } from '../src/shapes/accent-border-callout1-shape';
7
7
  export { AccentBorderCallout2Shape } from '../src/shapes/accent-border-callout2-shape';
8
8
  export { AccentBorderCallout3Shape } from '../src/shapes/accent-border-callout3-shape';
@@ -117,4 +117,5 @@ export declare class BasicShapeModel implements IShapeModel {
117
117
  dispose(): void;
118
118
  toJSON(): IShapeJSONData;
119
119
  fromJSON(json: IShapeJSONData): void;
120
+ private _createRenderModel;
120
121
  }
@@ -0,0 +1,7 @@
1
+ import type { IPresetShapeConfig } from '../shape-type';
2
+ import { BaseShapeRenderModel } from './shape-render-model';
3
+ export declare class CustomShapeRenderModel extends BaseShapeRenderModel {
4
+ readonly name: string;
5
+ readonly presetShapeConfig: IPresetShapeConfig;
6
+ constructor(name: string, presetShapeConfig: IPresetShapeConfig);
7
+ }
@@ -1,21 +1,14 @@
1
- /**
2
- * Copyright 2023-present DreamNum Co., Ltd.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
1
  import type { IShapeData, IShapePoint, IShapeRect, IShapeRenderParameters } from '../shape-type';
17
2
  import type { BaseShapeContext } from './base-shape-context';
18
3
  import { BaseShapeRenderModel } from './shape-render-model';
4
+ /**
5
+ * Interface for storing complete path command information for line shapes
6
+ * Used to preserve bezier curve data when redrawing with arrow adjustments
7
+ */
8
+ export interface ILinePathCommand {
9
+ command: string;
10
+ points: number[];
11
+ }
19
12
  /**
20
13
  * Base class for line-type shapes (connectors, lines).
21
14
  *
@@ -28,6 +21,11 @@ import { BaseShapeRenderModel } from './shape-render-model';
28
21
  */
29
22
  export declare abstract class LineShapeRenderModel extends BaseShapeRenderModel {
30
23
  protected _isLineShape: boolean;
24
+ static toRoundedPolylineCommands(commands: ILinePathCommand[], cornerRadius: number): ILinePathCommand[];
25
+ private static _cloneLinePathCommands;
26
+ private static _isLineOnlyPolyline;
27
+ private static _getPolylineCommandPoint;
28
+ private static _getRoundedCorner;
31
29
  /**
32
30
  * Check if a point is near a line segment.
33
31
  *
@@ -99,8 +97,10 @@ export declare abstract class LineShapeRenderModel extends BaseShapeRenderModel
99
97
  render(canvasContext: CanvasRenderingContext2D, rect: IShapeRect, shapeContext: BaseShapeContext, shapeData: IShapeData, renderOption: IShapeRenderParameters): void;
100
98
  private _scalePoints;
101
99
  private _executePathCommand;
100
+ private _drawLinePathCommands;
102
101
  private _applyFill;
103
102
  private _applyStrokeWithArrows;
103
+ private _getLineCornerRadius;
104
104
  /**
105
105
  * Extract start and end points with tangent direction points for arrow rendering
106
106
  * For bezier curves, uses control points to get correct tangent direction
@@ -104,6 +104,7 @@ export interface IGdContextBase {
104
104
  lsd32: number;
105
105
  }
106
106
  export interface IGdContext extends IGdContextBase {
107
+ [key: string]: number | undefined;
107
108
  x0?: number;
108
109
  x1?: number;
109
110
  x2?: number;
@@ -550,8 +551,10 @@ export interface IShapePath {
550
551
  /** Parsed path data array (alternative to data string) */
551
552
  dataArray?: IPathCommand[];
552
553
  }
554
+ export type ShapeTextDirection = 'horz' | 'vert' | 'vert270' | 'wordArtVert' | 'eaVert' | 'mongolianVert' | 'wordArtVertRtl';
553
555
  export interface IShapeTextAlign {
554
556
  isHorizontal: boolean;
557
+ textDirection?: ShapeTextDirection;
555
558
  }
556
559
  export interface IShapeText extends IShapeTextAlign {
557
560
  isRichText: false;
@@ -571,6 +574,7 @@ export interface ICustomShapeTextData extends IShapeTextAlign {
571
574
  */
572
575
  export interface IBasicShapeData {
573
576
  shapeType?: ShapeTypeEnum;
577
+ isTextBox?: boolean;
574
578
  fill?: {
575
579
  color?: string;
576
580
  fillType?: ShapeFillEnum;
@@ -580,6 +584,7 @@ export interface IBasicShapeData {
580
584
  gradientStops?: Array<{
581
585
  position: number;
582
586
  color: string;
587
+ opacity?: number;
583
588
  }>;
584
589
  /**
585
590
  * Image fill source, can be a URL or base64 data URI. When fillType is 'image', this specifies the image to use for filling the shape.
@@ -630,6 +635,8 @@ export interface IBasicShapeData {
630
635
  };
631
636
  stroke?: IShapeLineStyle;
632
637
  adjustValues?: Record<string, number>;
638
+ isCustom?: boolean;
639
+ customGeometry?: IPresetShapeConfig;
633
640
  shapeText?: IShapeText | ICustomShapeTextData;
634
641
  }
635
642
  export interface ICxnShapeData extends IBasicShapeData {
@@ -812,6 +819,7 @@ export interface IShapeLineStyle {
812
819
  color?: string;
813
820
  width?: number;
814
821
  opacity?: number;
822
+ cornerRadius?: number;
815
823
  dashType?: ShapeLineDashEnum;
816
824
  capType?: ShapeLineCapEnum;
817
825
  lineJoinType?: ShapeLineJoinEnum;