@univerjs/engine-render 0.7.0 → 0.8.0-beta.1

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.
@@ -42,7 +42,7 @@ export declare function precisionTo(num: number, accurate: number): number;
42
42
  * var time = performance.now(); for(let i=0;i<100000000;i++){ fixLineWidthByScale(i, 0.666); }; console.log(performance.now()-time);
43
43
  */
44
44
  export declare function fixLineWidthByScale(num: number, scale: number): number;
45
- export declare function getFontStyleString(textStyle?: IStyleBase): IDocumentSkeletonFontStyle;
45
+ export declare function getFontStyleString(textStyle?: Nullable<IStyleBase>): IDocumentSkeletonFontStyle;
46
46
  export declare function hasCJKText(text: string): boolean;
47
47
  export declare function hasCJK(text: string): boolean;
48
48
  export declare function hasCJKPunctuation(text: string): boolean;
@@ -0,0 +1,38 @@
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
+ export interface ILineInfo {
17
+ text: string;
18
+ width: number;
19
+ height: number;
20
+ baseline: number;
21
+ }
22
+ export declare class DocSimpleSkeleton {
23
+ private _text;
24
+ private _fontStyle;
25
+ private _warp;
26
+ private _width;
27
+ private _height;
28
+ private _lineBreaker;
29
+ private _lines;
30
+ private _dirty;
31
+ private _lastBreakLength;
32
+ constructor(_text: string, _fontStyle: string, _warp: boolean, _width: number, _height: number);
33
+ calculate(): ILineInfo[];
34
+ getLines(): ILineInfo[];
35
+ getTotalHeight(): number;
36
+ getTotalWidth(): number;
37
+ makeDirty(): void;
38
+ }
@@ -51,6 +51,7 @@ export declare class Font extends SheetExtension {
51
51
  * @param fontCache
52
52
  */
53
53
  private _clipByRenderBounds;
54
+ private _renderText;
54
55
  private _renderDocuments;
55
56
  private _clipRectangleForOverflow;
56
57
  }
@@ -1,4 +1,4 @@
1
- import { BorderStyleTypes, HorizontalAlign, ICellDataForSheetInterceptor, ICellWithCoord, ImageCacheMap, Nullable, ObjectMatrix, VerticalAlign, WrapStrategy } from '@univerjs/core';
1
+ import { BorderStyleTypes, HorizontalAlign, ICellDataForSheetInterceptor, ICellWithCoord, ImageCacheMap, IStyleData, Nullable, ObjectMatrix, VerticalAlign, WrapStrategy } from '@univerjs/core';
2
2
  import { BORDER_TYPE as BORDER_LTRB } from '../../basics/const';
3
3
  import { Canvas } from '../../canvas';
4
4
  import { UniverRenderingContext } from '../../context';
@@ -12,7 +12,7 @@ export interface BorderCacheItem {
12
12
  color: string;
13
13
  }
14
14
  export interface IFontCacheItem {
15
- documentSkeleton: DocumentSkeleton;
15
+ documentSkeleton?: DocumentSkeleton;
16
16
  vertexAngle?: number;
17
17
  centerAngle?: number;
18
18
  verticalAlign: VerticalAlign;
@@ -20,12 +20,13 @@ export interface IFontCacheItem {
20
20
  wrapStrategy: WrapStrategy;
21
21
  imageCacheMap: ImageCacheMap;
22
22
  cellData: Nullable<ICellDataForSheetInterceptor>;
23
+ fontString: string;
24
+ style?: Nullable<IStyleData>;
23
25
  }
24
26
  type colorString = string;
25
27
  export interface IStylesCache {
26
28
  background?: Record<colorString, ObjectMatrix<string>>;
27
29
  backgroundPositions?: ObjectMatrix<ICellWithCoord>;
28
- font?: Record<string, ObjectMatrix<IFontCacheItem>>;
29
30
  /**
30
31
  * Get value from getCell in skeleton and this value is used in font extension
31
32
  */
@@ -1,4 +1,4 @@
1
- import { DocumentDataModel, ICellData, ICellDataForSheetInterceptor, ICellInfo, ICellWithCoord, IColAutoWidthInfo, IColumnRange, IGetRowColByPosOptions, IPaddingData, IRange, IRowAutoHeightInfo, IRowRange, ISize, IStyleData, ITextRotation, Nullable, Styles, VerticalAlign, Worksheet, BooleanNumber, HorizontalAlign, IConfigService, IContextService, Injector, LocaleService, ObjectMatrix, SheetSkeleton, WrapStrategy } from '@univerjs/core';
1
+ import { DocumentDataModel, ICellData, ICellDataForSheetInterceptor, ICellInfo, ICellWithCoord, IColAutoWidthInfo, IColumnRange, IGetRowColByPosOptions, IPaddingData, IRange, IRowAutoHeightInfo, IRowRange, ISize, IStyleData, ITextRotation, Nullable, Styles, Worksheet, BooleanNumber, HorizontalAlign, IConfigService, IContextService, Injector, LocaleService, ObjectMatrix, SheetSkeleton, VerticalAlign, WrapStrategy } from '@univerjs/core';
2
2
  import { IBoundRectNoAngle, IPoint, IViewportInfo } from '../../basics/vector2';
3
3
  import { Scene } from '../../scene';
4
4
  import { IFontCacheItem, IStylesCache, SHEET_VIEWPORT_KEY } from './interfaces';
@@ -44,10 +44,10 @@ export declare class SpreadsheetSkeleton extends SheetSkeleton {
44
44
  private _visibleRangeMap;
45
45
  private _overflowCache;
46
46
  private _stylesCache;
47
+ private _clearTaskId;
47
48
  /** A matrix to store if a (row, column) position has render cache. */
48
49
  private _handleBgMatrix;
49
50
  private _handleBorderMatrix;
50
- private _handleFontMatrix;
51
51
  private _showGridlines;
52
52
  private _gridlinesColor;
53
53
  private _scene;
@@ -83,6 +83,10 @@ export declare class SpreadsheetSkeleton extends SheetSkeleton {
83
83
  updateVisibleRange(vpInfo?: IViewportInfo): boolean;
84
84
  getVisibleRangeByViewport(viewportKey: SHEET_VIEWPORT_KEY): IRowColumnRange | undefined;
85
85
  getVisibleRanges(): Map<SHEET_VIEWPORT_KEY, IRowColumnRange>;
86
+ /**
87
+ * Clear cache out of visible range when browser are free.
88
+ */
89
+ private _clearCacheOutOfVisibleRange;
86
90
  /**
87
91
  * Set border background and font to this._stylesCache by visible range, which derives from bounds)
88
92
  * @param vpInfo viewBounds
@@ -93,7 +97,8 @@ export declare class SpreadsheetSkeleton extends SheetSkeleton {
93
97
  * @param ranges
94
98
  * @returns {IRowAutoHeightInfo[]} result
95
99
  */
96
- calculateAutoHeightInRange(ranges: Nullable<IRange[]>): IRowAutoHeightInfo[];
100
+ calculateAutoHeightInRange(ranges: Nullable<IRange[]>, currentCellHeights?: ObjectMatrix<number>): IRowAutoHeightInfo[];
101
+ calculateAutoHeightForCell(row: number, col: number): number | undefined;
97
102
  private _calculateRowAutoHeight;
98
103
  calculateAutoWidthInRange(ranges: Nullable<IRange[]>): IColAutoWidthInfo[];
99
104
  /**
@@ -110,7 +115,7 @@ export declare class SpreadsheetSkeleton extends SheetSkeleton {
110
115
  * @param cell
111
116
  * @returns {number} currColWidth
112
117
  */
113
- _getMeasuredWidthByCell(cell: ICellDataForSheetInterceptor, currColWidth: number): number;
118
+ _getMeasuredWidthByCell(cell: ICellDataForSheetInterceptor, row: number, column: number, currColWidth: number): number;
114
119
  /**
115
120
  * @deprecated use `getRangeByViewport` instead.
116
121
  * @param bounds
@@ -225,7 +230,7 @@ export declare class SpreadsheetSkeleton extends SheetSkeleton {
225
230
  mergeRange?: IRange;
226
231
  cacheItem?: ICacheItem;
227
232
  } | undefined): void;
228
- _setFontStylesCache(row: number, col: number, cellData: Nullable<ICellDataForSheetInterceptor>): void;
233
+ _setFontStylesCache(row: number, col: number, cellData: Nullable<ICellDataForSheetInterceptor>, style: IStyleData): void;
229
234
  /**
230
235
  * Set border background and font to this._stylesCache cell by cell.
231
236
  * @param row {number}
@@ -15,6 +15,7 @@
15
15
  */
16
16
  export * from './base-object';
17
17
  export * from './basics';
18
+ export * from './components/docs/layout/doc-simple-skeleton';
18
19
  export { getOffsetRectForDom } from './basics/position';
19
20
  export * from './canvas';
20
21
  export * from './components';
@@ -25,3 +25,4 @@ export * from './regular-polygon';
25
25
  export * from './rich-text';
26
26
  export * from './scroll-bar';
27
27
  export * from './shape';
28
+ export * from './text';
@@ -6,28 +6,30 @@ import { Viewport } from '../viewport';
6
6
  import { Rect } from './rect';
7
7
  export interface IScrollBarProps {
8
8
  mainScene?: Scene;
9
+ /** Margin between the track to the edge of the scrollable area. Default is 2px. */
9
10
  thumbMargin?: number;
10
11
  thumbLengthRatio?: number;
12
+ /** Background color of the thumb. */
11
13
  thumbBackgroundColor?: string;
14
+ /** Background color of the thumb on hover. */
12
15
  thumbHoverBackgroundColor?: string;
16
+ /** Background color of the thumb when active. */
13
17
  thumbActiveBackgroundColor?: string;
14
- /**
15
- * The thickness of a scrolling track(not scrolling thumb).
16
- */
18
+ /** Background color of the track. */
19
+ trackBackgroundColor?: string;
20
+ /** Background color of the track border. */
21
+ trackBorderColor?: string;
22
+ /** The thickness of a scrolling track (not scrolling thumb). */
17
23
  barSize?: number;
18
- /**
19
- * The thickness of track border.
20
- */
24
+ /** The thickness of track border. */
21
25
  barBorder?: number;
26
+ /** Enable the horizontal scroll bar. True by default. */
22
27
  enableHorizontal?: boolean;
28
+ /** Enable the vertical scroll bar. True by default. */
23
29
  enableVertical?: boolean;
24
- /**
25
- * The min width of horizon thumb
26
- */
30
+ /** The min width of horizon thumb. Default is 17 px. */
27
31
  minThumbSizeH?: number;
28
- /**
29
- * The min height of vertical thumb
30
- */
32
+ /** The min height of vertical thumb. Default is 17 px. */
31
33
  minThumbSizeV?: number;
32
34
  }
33
35
  export declare class ScrollBar extends Disposable {
@@ -1,6 +1,36 @@
1
+ import { Nullable, HorizontalAlign, VerticalAlign } from '@univerjs/core';
2
+ import { UniverRenderingContext } from '../context';
1
3
  import { IShapeProps, Shape } from './shape';
4
+ import { DocSimpleSkeleton } from '../components/docs/layout/doc-simple-skeleton';
2
5
  export interface ITextProps extends IShapeProps {
3
6
  width: number;
7
+ height: number;
8
+ text: string;
9
+ fontStyle: string;
10
+ warp?: boolean;
11
+ hAlign?: HorizontalAlign;
12
+ vAlign?: VerticalAlign;
13
+ color?: Nullable<string>;
14
+ strokeLine?: boolean;
15
+ underline?: boolean;
4
16
  }
17
+ export declare const TEXT_OBJECT_ARRAY: string[];
5
18
  export declare class Text extends Shape<ITextProps> {
19
+ text: string;
20
+ fontStyle: string;
21
+ warp: boolean;
22
+ hAlign: HorizontalAlign;
23
+ vAlign: VerticalAlign;
24
+ skeleton: DocSimpleSkeleton;
25
+ constructor(key: string, props: ITextProps);
26
+ static drawWith(ctx: UniverRenderingContext, props: ITextProps, _skeleton?: DocSimpleSkeleton): number;
27
+ /**
28
+ * Draw text decoration lines (underline, strikethrough, etc.)
29
+ */
30
+ private static _drawTextDecoration;
31
+ protected _draw(ctx: UniverRenderingContext): void;
32
+ makeDirty(state?: boolean): this | undefined;
33
+ toJson(): {
34
+ [x: string]: any;
35
+ };
6
36
  }