@univerjs/engine-render 0.16.1 → 0.17.0

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,4 +1,4 @@
1
- import { IKeyValue, ITransformState, Nullable, Disposable, EventSubject } from '@univerjs/core';
1
+ import { IGroupBaseBound, IKeyValue, ITransformState, Nullable, Disposable, EventSubject } from '@univerjs/core';
2
2
  import { IDragEvent, IMouseEvent, IPointerEvent, IWheelEvent } from './basics/i-events';
3
3
  import { IObjectFullState, ITransformChangeState } from './basics/interfaces';
4
4
  import { ITransformerConfig } from './basics/transformer-config';
@@ -22,6 +22,7 @@ export declare enum ObjectType {
22
22
  export declare abstract class BaseObject extends Disposable {
23
23
  groupKey?: string;
24
24
  isInGroup: boolean;
25
+ isDrawingObject: boolean;
25
26
  objectType: ObjectType;
26
27
  onTransformChange$: EventSubject<ITransformChangeState>;
27
28
  onPointerDown$: EventSubject<IMouseEvent | IPointerEvent>;
@@ -146,6 +147,7 @@ export declare abstract class BaseObject extends Disposable {
146
147
  isRender(bounds?: IViewportInfo): boolean | undefined;
147
148
  getParent(): any;
148
149
  getState(): ITransformState;
150
+ getRealBound(): IGroupBaseBound;
149
151
  hide(): void;
150
152
  show(): void;
151
153
  render(ctx: UniverRenderingContext, bounds: IViewportInfo): void;
@@ -1,4 +1,4 @@
1
- import { ITransformState } from '@univerjs/core';
1
+ import { IGroupBaseBound, ITransformState, Nullable } from '@univerjs/core';
2
2
  export declare function getGroupState(parentLeft: number, parentTop: number, objectStates: ITransformState[]): {
3
3
  left: number;
4
4
  top: number;
@@ -8,8 +8,67 @@ export declare function getGroupState(parentLeft: number, parentTop: number, obj
8
8
  scaleX: number;
9
9
  scaleY: number;
10
10
  };
11
- export declare function transformObjectOutOfGroup(child: ITransformState, parent: ITransformState, groupOriginWidth: number, groupOriginHeight: number): {
11
+ export declare function getDrawingGroupState(parentLeft: number, parentTop: number, objectStates: ITransformState[]): {
12
12
  left: number;
13
13
  top: number;
14
+ width: number;
15
+ height: number;
16
+ angle: number;
17
+ scaleX: number;
18
+ scaleY: number;
19
+ };
20
+ /**
21
+ * Transform a child object out of a group, computing its absolute position, angle, and flip state.
22
+ *
23
+ * When a DrawingGroup has a baseBound (chOff/chExt in OOXML), children store their positions
24
+ * in the baseBound coordinate space. This method first maps the child's position from baseBound
25
+ * space to the actual parent bound space, then applies group flip mirroring and rotation.
26
+ *
27
+ * @param child - The child's transform state (position in baseBound space if baseBound is provided)
28
+ * @param parent - The parent group's transform state (absolute position, angle, flip)
29
+ * @param groupOriginWidth - The original width of the group (used to compute group center)
30
+ * @param groupOriginHeight - The original height of the group (used to compute group center)
31
+ * @param baseBound - Optional. The group's baseBound (chOff/chExt). If provided, child coordinates
32
+ * are mapped from this space to the parent's actual bound space before transforming.
33
+ *
34
+ * @example
35
+ * // in excel, the group off & ext is the real position and size of the group, and the child position is relative to the group chOff/chExt. For example:
36
+ * ```xml
37
+ * <a:xfrm>
38
+ * <a:off x="1212850" y="889000"/>
39
+ * <a:ext cx="6813550" cy="4883150"/>
40
+ * <a:chOff x="1212850" y="889000"/>
41
+ * <a:chExt cx="6813550" cy="4883150"/>
42
+ * </a:xfrm>
43
+ * ```
44
+ */
45
+ export declare function transformObjectOutOfGroup(child: ITransformState, parent: ITransformState, groupOriginWidth: number, groupOriginHeight: number, baseBound: Nullable<IGroupBaseBound>): {
46
+ left: number;
47
+ top: number;
48
+ width: number;
49
+ height: number;
14
50
  angle: number;
51
+ flipX: boolean;
52
+ flipY: boolean;
15
53
  };
54
+ /**
55
+ * Get the rendered position and size of an object based on the group's baseBound and the parent's bound.
56
+ * @param baseBound The group's baseBound defining the coordinate space for its children,In Excel, this corresponds to chOff (child offset) and chExt (child extent) in OOXML.
57
+ * @param parentBound The bounding box of the parent context (e.g., the group or canvas) within which the object is rendered.
58
+ * @param objectBound The original bounding box of the object in the group's coordinate space.
59
+ * @returns {IGroupBaseBound} The transformed bound for rendering the object within the group context
60
+ */
61
+ export declare function getRenderTransformBaseOnParentBound(baseBound: IGroupBaseBound, parentBound: IGroupBaseBound, objectBound: IGroupBaseBound): IGroupBaseBound;
62
+ /**
63
+ * In Excel, a rotated shape's bounding box for group calculations uses major axis switching.
64
+ * The axis-aligned bound depends on which 90° increment the rotation angle is closest to:
65
+ *
66
+ * [-45°, 45°) → 0° horizontal (original width/height)
67
+ * [45°, 135°) → 90° vertical (width/height swapped)
68
+ * [135°, 225°) → 180° horizontal (original width/height)
69
+ * [225°, 315°) → 270° vertical (width/height swapped)
70
+ *
71
+ * @param bound - The original axis-aligned bound { left, top, width, height }
72
+ * @param angle - The rotation angle in degrees
73
+ */
74
+ export declare function getRotatedBoundInGroup(bound: IGroupBaseBound, angle: number): IGroupBaseBound;
@@ -1,6 +1,6 @@
1
1
  import { ITransformState } from '@univerjs/core';
2
- import { Vector2 } from './vector2';
3
2
  import { IRect } from './interfaces';
3
+ import { Vector2 } from './vector2';
4
4
  export declare const INITIAL_MATRIX: number[];
5
5
  export declare class Transform {
6
6
  dirty: boolean;
@@ -1,8 +1,8 @@
1
1
  import { Nullable } from '@univerjs/core';
2
- import { Break } from '../break';
3
- import { IBreakPoints, LineBreaker } from '../line-breaker';
4
2
  import { Hyphen } from '../../hyphenation/hyphen';
5
3
  import { Lang } from '../../hyphenation/lang';
4
+ import { IBreakPoints, LineBreaker } from '../line-breaker';
5
+ import { Break } from '../break';
6
6
  export declare class LineBreakerHyphenEnhancer implements IBreakPoints {
7
7
  private _lineBreaker;
8
8
  private _hyphen;
@@ -0,0 +1,37 @@
1
+ import { IGroupBaseBound } from '@univerjs/core';
2
+ import { BaseObject } from './base-object';
3
+ import { IViewportInfo, Vector2, Transform } from './basics';
4
+ import { UniverRenderingContext } from './context';
5
+ import { Group } from './group';
6
+ export declare class DrawingGroupObject extends Group {
7
+ protected _selfSizeMode: boolean;
8
+ /**
9
+ * Corresponds to chOff (child offset) and chExt (child extent) in OOXML.
10
+ * Describes the coordinate space of children within this group.
11
+ * Children store their absolute positions in this coordinate space.
12
+ * When rendering, positions are mapped from baseBound space to the group's current transform.
13
+ */
14
+ private _baseBound;
15
+ /**
16
+ * Set the baseBound (chOff/chExt in OOXML) for this group.
17
+ * This defines the coordinate space of children within the group.
18
+ * When set, the group automatically enters selfSizeMode so its dimensions
19
+ * are tracked independently of children.
20
+ */
21
+ setBaseBound(bound: IGroupBaseBound): void;
22
+ /**
23
+ * Get the baseBound (chOff/chExt in OOXML) for this group.
24
+ */
25
+ getBaseBound(): IGroupBaseBound;
26
+ /**
27
+ * Override ancestorTransform to use the same render transform as render(),
28
+ * which uses [m[0], m[1], m[2], m[3], centerX, centerY] from realBound
29
+ * instead of the standard transform translation.
30
+ * This ensures children (e.g., Image.isHit) that compose with
31
+ * parent.ancestorTransform get the correct coordinate space.
32
+ */
33
+ get ancestorTransform(): Transform;
34
+ render(ctx: UniverRenderingContext, bounds: IViewportInfo): void;
35
+ addObjects(...objects: BaseObject[]): void;
36
+ isHit(coord: Vector2): boolean;
37
+ }
@@ -3,8 +3,8 @@ import { IViewportInfo } from './basics/vector2';
3
3
  import { UniverRenderingContext } from './context';
4
4
  import { BaseObject } from './base-object';
5
5
  export declare class Group extends BaseObject {
6
- private _objects;
7
- private _selfSizeMode;
6
+ protected _objects: BaseObject[];
7
+ protected _selfSizeMode: boolean;
8
8
  constructor(key?: string, ...objects: BaseObject[]);
9
9
  get classType(): RENDER_CLASS_TYPE;
10
10
  set cursor(val: CURSOR_TYPE);
@@ -34,9 +34,10 @@ export { DocumentViewModel } from './components/docs/view-model/document-view-mo
34
34
  export { DocumentEditArea } from './components/docs/view-model/document-view-model';
35
35
  export { parseDataStreamToTree } from './components/docs/view-model/document-view-model';
36
36
  export { DEFAULT_PADDING_DATA } from './components/sheets/sheet.render-skeleton';
37
+ export type { IUniverEngineRenderConfig } from './config/config';
37
38
  export * from './context';
38
- export type { IUniverEngineRenderConfig } from './controllers/config.schema';
39
39
  export * from './custom';
40
+ export { DrawingGroupObject } from './drawing-group';
40
41
  export * from './engine';
41
42
  export * from './group';
42
43
  export * from './layer';
@@ -1,4 +1,4 @@
1
- import { IUniverEngineRenderConfig } from './controllers/config.schema';
1
+ import { IUniverEngineRenderConfig } from './config/config';
2
2
  import { IConfigService, Injector, Plugin } from '@univerjs/core';
3
3
  import { Engine } from './engine';
4
4
  /**
@@ -12,6 +12,8 @@ export declare class UniverRenderEnginePlugin extends Plugin {
12
12
  readonly _injector: Injector;
13
13
  private readonly _configService;
14
14
  static pluginName: string;
15
+ static packageName: string;
16
+ static version: string;
15
17
  constructor(_config: Partial<IUniverEngineRenderConfig> | undefined, _injector: Injector, _configService: IConfigService);
16
18
  onStarting(): void;
17
19
  }
@@ -24,6 +24,7 @@ export declare class Image extends Shape<IImageProps> {
24
24
  private _renderByCropper;
25
25
  private _transformCalculateSrcRect;
26
26
  objectType: ObjectType;
27
+ isDrawingObject: boolean;
27
28
  constructor(id: string, config: IImageProps);
28
29
  get srcRect(): Nullable<ISrcRect>;
29
30
  get prstGeom(): Nullable<PresetGeometryType>;
@@ -52,7 +53,7 @@ export declare class Image extends Shape<IImageProps> {
52
53
  };
53
54
  private _transformBySrcRect;
54
55
  render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this;
55
- protected _draw(ctx: UniverRenderingContext): void;
56
+ protected _draw(ctx: UniverRenderingContext, _bounds?: IViewportInfo, renderWidth?: number, renderHeight?: number): void;
56
57
  private _init;
57
58
  private _updateSrcRectByTransform;
58
59
  isHit(coord: Vector2): boolean;
@@ -97,12 +97,23 @@ export declare class ScrollBar extends Disposable {
97
97
  get miniThumbRatioY(): number;
98
98
  hasHorizonThumb(): boolean;
99
99
  hasVerticalThumb(): boolean;
100
+ /**
101
+ * The horizontal scroll thumb thickness.
102
+ */
100
103
  get scrollHorizonThumbThickness(): number;
104
+ /**
105
+ * The vertical scroll thumb thickness.
106
+ */
101
107
  get scrollVerticalThumbThickness(): number;
108
+ /**
109
+ * The scroll track thickness.
110
+ * trackThickness = scrollTrackSize(horizonScrollTrack.height/verticalScrollTrack.width) + trackBorderThickness
111
+ */
102
112
  set barSize(v: number);
103
113
  get barSize(): number;
104
114
  set trackThickness(v: number);
105
115
  get trackThickness(): number;
116
+ get totalSize(): number;
106
117
  static attachTo(view: Viewport, props?: IScrollBarProps): ScrollBar;
107
118
  dispose(): void;
108
119
  render(ctx: UniverRenderingContext, left?: number, top?: number): void;
@@ -147,6 +147,13 @@ export declare class Viewport {
147
147
  private _paddingEndX;
148
148
  private _paddingStartY;
149
149
  private _paddingEndY;
150
+ /**
151
+ * The viewMain viewport's marginLeft and marginTop is used to calculate the scrollBar position.
152
+ * marginLeft = rowHeaderWidthAndMarginLeft;
153
+ * marginTop = columnHeaderHeightAndMarginTop;
154
+ */
155
+ private _marginLeft;
156
+ private _marginTop;
150
157
  /**
151
158
  * viewbound of cache area, cache area is slightly bigger than viewbound.
152
159
  */
@@ -243,6 +250,7 @@ export declare class Viewport {
243
250
  resizeWhenFreezeChange(position: IViewPosition): void;
244
251
  setPadding(param: IPosition): void;
245
252
  resetPadding(): void;
253
+ setMargin(marginLeft: number, marginTop: number): void;
246
254
  /**
247
255
  * ScrollBar scroll to certain position.
248
256
  * @param pos position of scrollBar