@univerjs/engine-render 1.0.0-alpha.8 → 1.0.0-beta.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.
@@ -0,0 +1,67 @@
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 IAlignmentRect {
17
+ left: number;
18
+ top: number;
19
+ width: number;
20
+ height: number;
21
+ }
22
+ export type AlignmentSnapAxis = 'x' | 'y';
23
+ export interface IAlignmentSnapGuide {
24
+ id: string;
25
+ axis: AlignmentSnapAxis;
26
+ position: number;
27
+ }
28
+ export interface IAlignmentSnapSessionConfig {
29
+ enterThreshold?: number;
30
+ exitThreshold?: number;
31
+ breakawayThreshold?: number;
32
+ softThreshold?: number;
33
+ hardThreshold?: number;
34
+ softMaxStrength?: number;
35
+ cooldownMs?: number;
36
+ }
37
+ export interface IAlignmentSnapAxisOptions {
38
+ axis: AlignmentSnapAxis;
39
+ value: number;
40
+ guide: IAlignmentSnapGuide | null;
41
+ now?: number;
42
+ }
43
+ export interface IAlignmentSnapAxisResult {
44
+ snapped: boolean;
45
+ value: number;
46
+ guide: IAlignmentSnapGuide | null;
47
+ }
48
+ export declare function normalizeAlignmentRect(rect: IAlignmentRect): IAlignmentRect;
49
+ export declare function getAlignmentRectXAnchors(rect: IAlignmentRect): [number, number, number];
50
+ export declare function getAlignmentRectYAnchors(rect: IAlignmentRect): [number, number, number];
51
+ export declare function getClosestAlignmentOffset(activeAnchors: readonly number[], targetAnchors: readonly number[], threshold: number): number;
52
+ export declare class AlignmentSnapSession {
53
+ private readonly _enterThreshold;
54
+ private readonly _exitThreshold;
55
+ private readonly _breakawayThreshold;
56
+ private readonly _softThreshold;
57
+ private readonly _hardThreshold;
58
+ private readonly _softMaxStrength;
59
+ private readonly _cooldownMs;
60
+ private _activeGuideId;
61
+ private _activeGuideStartValue;
62
+ private _releasedUntil;
63
+ constructor(config?: IAlignmentSnapSessionConfig);
64
+ reset(): void;
65
+ resolveAxisSnap(options: IAlignmentSnapAxisOptions): IAlignmentSnapAxisResult;
66
+ private _resolveSnappedValue;
67
+ }
@@ -164,6 +164,14 @@ export declare abstract class BaseObject extends Disposable {
164
164
  isRender(bounds?: IViewportInfo): boolean | undefined;
165
165
  getParent(): any;
166
166
  getState(): ITransformState;
167
+ /**
168
+ * Returns the flip state after composing this object with every ancestor
169
+ * drawing group whose transform participates in rendering.
170
+ */
171
+ getEffectiveFlipState(): {
172
+ flipX: boolean;
173
+ flipY: boolean;
174
+ };
167
175
  getRealBound(): IGroupBaseBound;
168
176
  hide(): void;
169
177
  show(): void;
@@ -13,8 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import type { IGlowEffect, IShadowEffect } from '@univerjs/core';
16
17
  import type { IBoundRectNoAngle } from './vector2';
17
- import { type IGlowEffect, type IShadowEffect } from '@univerjs/core';
18
18
  export interface IResolvedDrawingShadow {
19
19
  color: string;
20
20
  blurRadius: number;
@@ -209,6 +209,7 @@ export interface IDocumentSkeletonGlyph {
209
209
  url?: string;
210
210
  featureId?: string;
211
211
  drawingId?: string;
212
+ fauxBoldStrokeWidth?: number;
212
213
  }
213
214
  export interface IDocumentSkeletonBullet {
214
215
  listId: string;
@@ -216,9 +217,13 @@ export interface IDocumentSkeletonBullet {
216
217
  ts: ITextStyle;
217
218
  fontStyle?: IDocumentSkeletonFontStyle;
218
219
  startIndexItem: number;
220
+ startNumber?: number;
219
221
  nestingLevel?: INestingLevel;
220
222
  bulletAlign?: BulletAlignment;
221
223
  bulletType?: boolean;
224
+ compactSpacing?: boolean;
225
+ preserveTextLineHeight?: boolean;
226
+ imageSource?: string;
222
227
  paragraphProperties?: IParagraphProperties;
223
228
  }
224
229
  export interface IDocumentSkeletonDrawing {
@@ -241,6 +246,8 @@ export interface IDocumentSkeletonDrawing {
241
246
  contentHeight?: number;
242
247
  contentWidth?: number;
243
248
  height?: number;
249
+ pageContentWidth?: number;
250
+ viewScale?: number;
244
251
  viewportHeight?: number;
245
252
  };
246
253
  }
@@ -94,6 +94,15 @@ export interface IParagraphConfig {
94
94
  paragraphIndex: number;
95
95
  documentCompatibilityPolicy?: IDocumentCompatibilityPolicy;
96
96
  useWordStyleLineHeight?: boolean;
97
+ usePptxFontSizeLineHeight?: boolean;
98
+ usePptxNominalFontLineHeight?: boolean;
99
+ usePptxCompatibleLineSpacing?: boolean;
100
+ usePptxPercentageLineSpacing?: boolean;
101
+ pptxPercentageFontSize?: number;
102
+ usePptxNormAutofitLineHeight?: boolean;
103
+ pptxEmptyParagraphFontSize?: number;
104
+ pptxHasExplicitEndParaFontSize?: boolean;
105
+ sumPptxParagraphSpacing?: boolean;
97
106
  docxFallbackAnchorLeft?: IParagraphStyle['indentStart'];
98
107
  paragraphNonInlineSkeDrawings?: Map<string, IDocumentSkeletonDrawing>;
99
108
  paragraphInlineSkeDrawings?: Map<string, IDocumentSkeletonDrawing>;
@@ -16,6 +16,7 @@
16
16
  import type { IPosition, IRange, IRangeWithCoord, IScale, IStyleBase, Nullable } from '@univerjs/core';
17
17
  import type { IDocumentSkeletonFontStyle } from './i-document-skeleton-cached';
18
18
  import type { IBoundRectNoAngle } from './vector2';
19
+ export declare function hasScrollableOverflow(contentSize: number, viewportSize: number): boolean;
19
20
  export declare const getColor: (RgbArray: number[], opacity?: number) => string;
20
21
  export declare const toPx: (num: number | string, ReferenceValue: Nullable<number>) => number;
21
22
  /**
@@ -29,6 +29,8 @@ export interface IDocsCustomBlockRenderViewport {
29
29
  height: number;
30
30
  layoutWidth?: number;
31
31
  offsetLeft?: number;
32
+ pageContentWidth?: number;
33
+ viewScale?: number;
32
34
  viewportHeight?: number;
33
35
  width: number;
34
36
  }
@@ -15,17 +15,21 @@
15
15
  */
16
16
  import type { IScale } from '@univerjs/core';
17
17
  import type { IDocumentSkeletonGlyph } from '../../../basics/i-document-skeleton-cached';
18
+ import type { IBoundRectNoAngle } from '../../../basics/vector2';
18
19
  import type { UniverRenderingContext } from '../../../context';
20
+ import type { IDrawInfo } from '../../extension';
19
21
  import { docExtension } from '../doc-extension';
20
22
  export declare class Line extends docExtension {
21
23
  uKey: string;
22
24
  Z_INDEX: number;
23
25
  private _preBackgroundColor;
24
- draw(ctx: UniverRenderingContext, parentScale: IScale, glyph: IDocumentSkeletonGlyph): void;
26
+ draw(ctx: UniverRenderingContext, parentScale: IScale, glyph: IDocumentSkeletonGlyph, _diff?: IBoundRectNoAngle, more?: IDrawInfo): void;
25
27
  clearCache(): void;
26
28
  private _drawLine;
27
29
  private _drawLineTo;
28
30
  private _setLineType;
29
31
  private _isWave;
30
32
  private _isDouble;
33
+ private _isAccounting;
34
+ private _isFirstAccountingGlyph;
31
35
  }
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IBullet, ILists, LocaleService, Nullable } from '@univerjs/core';
16
+ import type { IBullet, ILists, ITextStyle, LocaleService, Nullable } from '@univerjs/core';
17
17
  import type { IDocumentSkeletonBullet } from '../../../../../basics/i-document-skeleton-cached';
18
- export declare function dealWithBullet(bullet?: IBullet, lists?: ILists, listLevelAncestors?: Array<Nullable<IDocumentSkeletonBullet>>, localeService?: LocaleService): IDocumentSkeletonBullet | undefined;
18
+ export declare function dealWithBullet(bullet?: IBullet, lists?: ILists, listLevelAncestors?: Array<Nullable<IDocumentSkeletonBullet>>, localeService?: LocaleService, compactSpacing?: boolean, paragraphTextStyle?: ITextStyle): IDocumentSkeletonBullet | undefined;
19
19
  export declare function getDefaultBulletSke(listId: string, startIndex?: number): IDocumentSkeletonBullet;
@@ -18,7 +18,7 @@ import type { IParagraphConfig, IParagraphTableCache, ISectionBreakConfig } from
18
18
  import type { IFloatObject, ILayoutContext } from '../../tools';
19
19
  import { BooleanNumber, GridType, SpacingRule } from '@univerjs/core';
20
20
  import { BreakPointType } from '../../line-breaker/break';
21
- declare function isGlyphGroupBeyondDivideWidth(glyphGroup: IDocumentSkeletonGlyph[], offsetLeft: number, divideWidth: number): boolean;
21
+ declare function isGlyphGroupBeyondDivideWidth(glyphGroup: IDocumentSkeletonGlyph[], offsetLeft: number, divideWidth: number, hangingPunctuation?: boolean): boolean;
22
22
  export declare function layoutParagraph(ctx: ILayoutContext, glyphGroup: IDocumentSkeletonGlyph[], pages: IDocumentSkeletonPage[], sectionBreakConfig: ISectionBreakConfig, paragraphConfig: IParagraphConfig, isParagraphFirstShapedText: boolean, breakPointType?: BreakPointType): IDocumentSkeletonPage[];
23
23
  declare function __avoidFlowAffectingDrawingsForTable(table: IDocumentSkeletonTable, page: IDocumentSkeletonPage, column: IDocumentSkeletonColumn): void;
24
24
  declare function _updateAndPositionTable(ctx: ILayoutContext, lineTop: number, lineHeight: number, page: IDocumentSkeletonPage, column: IDocumentSkeletonColumn, section: IDocumentSkeletonSection, skeTablesInParagraph: IParagraphTableCache[], paragraphIndex: number, sectionBreakConfig: ISectionBreakConfig, drawingAnchorTop?: number): boolean;
@@ -27,6 +27,11 @@ export declare function measureDocumentNoWrapTextRangeWidth(documentData: IDocum
27
27
  * details such as CJK-Latin spacing.
28
28
  */
29
29
  export declare function measureDocumentNoWrapTextWidth(documentData: IDocumentData | null | undefined): number;
30
+ /**
31
+ * Measures the widest line after applying the docs Unicode break policy
32
+ * within a fixed-width host.
33
+ */
34
+ export declare function measureDocumentWrappedTextWidth(documentData: IDocumentData | null | undefined, maxLineWidth: number): number;
30
35
  /**
31
36
  * Measures the widest segment that docs line breaking keeps together. This is
32
37
  * useful when a host may wrap normally but still needs enough width to avoid
@@ -13,5 +13,5 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- declare const whiteListKeyForPt: Set<string>;
17
- declare function isNotEmpty(value: unknown): boolean;
16
+ import type { LineBreaker } from '../line-breaker';
17
+ export declare function eastAsianQuoteLineBreakExtension(breaker: LineBreaker): void;
@@ -21,4 +21,6 @@ export * from './row-header';
21
21
  export * from './sheet-component';
22
22
  export * from './sheet.render-skeleton';
23
23
  export * from './spreadsheet';
24
+ export { calculateCellImageRect } from './util';
25
+ export type { ICellImageRectConfig } from './util';
24
26
  export * from './watermark';
@@ -40,6 +40,7 @@ export declare const DEFAULT_PADDING_DATA: {
40
40
  };
41
41
  export declare const RENDER_RAW_FORMULA_KEY = "RENDER_RAW_FORMULA";
42
42
  export declare function getShrinkToFitScale(contentWidth: number, availableWidth: number, fontSize: number): number;
43
+ export declare function getGeneralNumberDisplayText(value: number, displayText: string, fontString: string, availableWidth: number): string;
43
44
  export declare function scaleDocumentDataForShrinkToFit(documentData: IDocumentData, scale: number, fallbackFontSize: number): IDocumentData;
44
45
  export interface ICacheItem {
45
46
  bg: boolean;
@@ -177,6 +178,7 @@ export declare class SpreadsheetSkeleton extends SheetSkeleton {
177
178
  _setBorderStylesCache(row: number, col: number, style: Nullable<IStyleData>, options: ISetStylesCacheForOneCellOptions | undefined): void;
178
179
  _setBgStylesCache(row: number, col: number, style: Nullable<IStyleData>, options: ISetStylesCacheForOneCellOptions | undefined): void;
179
180
  private _applyShrinkToFit;
181
+ private _applyGeneralNumberDisplay;
180
182
  _setFontStylesCache(row: number, col: number, cellData: Nullable<ICellDataForSheetInterceptor>, style: IStyleData, hasMergeData?: boolean): void;
181
183
  /**
182
184
  * Set border background and font to this._stylesCache cell by cell.
@@ -48,7 +48,7 @@ export declare class Spreadsheet extends SheetComponent {
48
48
  * @param ctx
49
49
  * @param viewportInfo
50
50
  */
51
- draw(ctx: UniverRenderingContext2D, viewportInfo: IViewportInfo): void;
51
+ draw(ctx: UniverRenderingContext2D, viewportInfo: IViewportInfo, isMergeRepair?: boolean): void;
52
52
  addRenderFrameTimeMetricToScene(timeKey: string, val: number, scene: Scene): void;
53
53
  addRenderTagToScene(renderKey: string, val: any, scene?: Scene): void;
54
54
  /**
@@ -77,7 +77,9 @@ export declare class Spreadsheet extends SheetComponent {
77
77
  makeDirty(state?: boolean): this;
78
78
  setDirtyArea(dirtyBounds: IBoundRectNoAngle[]): void;
79
79
  renderByViewports(mainCtx: UniverRenderingContext2D, viewportInfo: IViewportInfo, spreadsheetSkeleton: SpreadsheetSkeleton): void;
80
- paintNewAreaForScrolling(viewportInfo: IViewportInfo, param: IPaintForScrolling): void;
80
+ private _getMergeRepairBounds;
81
+ private _getRepaintBounds;
82
+ paintNewAreaForScrolling(viewportInfo: IViewportInfo, param: IPaintForScrolling, mergeRepairBounds?: IBoundRectNoAngle[]): void;
81
83
  /**
82
84
  * Redraw the entire viewport.
83
85
  */
@@ -14,7 +14,17 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { CellValueType, IPaddingData, IStyleBase, IStyleData, ITextRotation, ITextStyle, Nullable, TextDirection } from '@univerjs/core';
17
+ import type { IBoundRectNoAngle } from '../../basics';
17
18
  import { DocumentDataModel, HorizontalAlign, VerticalAlign, WrapStrategy } from '@univerjs/core';
19
+ export interface ICellImageRectConfig {
20
+ cellRect: IBoundRectNoAngle;
21
+ imageWidth: number;
22
+ imageHeight: number;
23
+ horizontalAlign: HorizontalAlign;
24
+ verticalAlign: VerticalAlign;
25
+ padding?: Nullable<IPaddingData>;
26
+ }
27
+ export declare function calculateCellImageRect(config: ICellImageRectConfig): IBoundRectNoAngle;
18
28
  export interface ICellStyle {
19
29
  textRotation?: ITextRotation;
20
30
  textDirection?: Nullable<TextDirection>;
@@ -34,7 +34,7 @@ export declare class DrawingGroupObject extends Group {
34
34
  * When rendering, positions are mapped from baseBound space to the group's current transform.
35
35
  */
36
36
  private _baseBound;
37
- private _outerShadow?;
37
+ protected _outerShadow?: IDrawingGroupShadow;
38
38
  private _glow?;
39
39
  setOuterShadow(shadow?: IDrawingGroupShadow): void;
40
40
  setGlow(glow?: IGlowEffect): void;
@@ -13,6 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ export { AlignmentSnapSession, getAlignmentRectXAnchors, getAlignmentRectYAnchors, getClosestAlignmentOffset, normalizeAlignmentRect, } from './alignment-snap';
17
+ export type { AlignmentSnapAxis, IAlignmentRect, IAlignmentSnapAxisOptions, IAlignmentSnapAxisResult, IAlignmentSnapGuide, IAlignmentSnapSessionConfig, } from './alignment-snap';
16
18
  export * from './base-object';
17
19
  export * from './basics';
18
20
  export { combineDrawingEffectFilter, createDrawingEffectFilter, expandDrawingEffectBounds, resolveDrawingEffectMasks, resolveGlowEffect, resolveOuterShadowEffect, } from './basics/drawing-effect';
@@ -27,7 +29,7 @@ export { Documents } from './components/docs/document';
27
29
  export type { IPageRenderConfig } from './components/docs/document';
28
30
  export type { IDocumentOffsetConfig } from './components/docs/document';
29
31
  export { getTableIdAndSliceIndex } from './components/docs/layout/block/table';
30
- export { measureDocumentNoWrapTextRangeWidth, measureDocumentNoWrapTextWidth, measureDocumentUnbreakableTextWidth, } from './components/docs/layout/doc-no-wrap-measure';
32
+ export { measureDocumentNoWrapTextRangeWidth, measureDocumentNoWrapTextWidth, measureDocumentUnbreakableTextWidth, measureDocumentWrappedTextWidth, } from './components/docs/layout/doc-no-wrap-measure';
31
33
  export * from './components/docs/layout/doc-simple-skeleton';
32
34
  export { DocumentSkeleton } from './components/docs/layout/doc-skeleton';
33
35
  export type { IFindNodeRestrictions } from './components/docs/layout/doc-skeleton';
@@ -43,14 +43,18 @@ export interface IScrollBarProps {
43
43
  enableHorizontal?: boolean;
44
44
  /** Enable the vertical scroll bar. True by default. */
45
45
  enableVertical?: boolean;
46
+ /** Hide the track when the corresponding content axis does not overflow. False by default. */
47
+ hideTrackWhenUnscrollable?: boolean;
46
48
  /** The min width of horizon thumb. Default is 17 px. */
47
49
  minThumbSizeH?: number;
48
50
  /** The min height of vertical thumb. Default is 17 px. */
49
51
  minThumbSizeV?: number;
50
52
  }
51
53
  export declare class ScrollBar extends Disposable {
54
+ static readonly DEFAULT_TOTAL_SIZE: number;
52
55
  _enableHorizontal: boolean;
53
56
  _enableVertical: boolean;
57
+ private _hideTrackWhenUnscrollable;
54
58
  horizontalThumbSize: number;
55
59
  horizontalMinusMiniThumb: number;
56
60
  horizontalTrackWidth: number;
@@ -109,6 +113,8 @@ export declare class ScrollBar extends Disposable {
109
113
  set enableHorizontal(val: boolean);
110
114
  get enableVertical(): boolean;
111
115
  set enableVertical(val: boolean);
116
+ get hideTrackWhenUnscrollable(): boolean;
117
+ set hideTrackWhenUnscrollable(val: boolean);
112
118
  get limitX(): number;
113
119
  get limitY(): number;
114
120
  get ratioScrollX(): number;