@univerjs/engine-render 1.4.0 → 1.5.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.
Files changed (45) hide show
  1. package/README.md +17 -5
  2. package/lib/cjs/{worker-dzyTVvQi.js → doc-skeleton-xHfOLvcR.js} +105 -263
  3. package/lib/cjs/index.js +3070 -1374
  4. package/lib/cjs/worker.js +239 -4
  5. package/lib/{es/worker-BlCdBXpV.js → doc-skeleton-h5WFPD-i.js} +88 -258
  6. package/lib/{worker-BlCdBXpV.js → es/doc-skeleton-h5WFPD-i.js} +88 -258
  7. package/lib/es/index.js +2198 -502
  8. package/lib/es/worker.js +236 -1
  9. package/lib/index.js +2198 -502
  10. package/lib/types/base-object.d.ts +5 -0
  11. package/lib/types/basics/draw.d.ts +1 -1
  12. package/lib/types/basics/interfaces.d.ts +1 -0
  13. package/lib/types/components/component.d.ts +1 -0
  14. package/lib/types/components/docs/document-layout-presentation.d.ts +1 -0
  15. package/lib/types/components/docs/layout/shaping-engine/font-cache.d.ts +2 -0
  16. package/lib/types/components/docs/layout/tools.d.ts +2 -0
  17. package/lib/types/components/docs/view-model/document-view-model.d.ts +2 -1
  18. package/lib/types/components/extension.d.ts +5 -1
  19. package/lib/types/components/sheets/extensions/background.d.ts +1 -0
  20. package/lib/types/components/sheets/extensions/border-row-cache.d.ts +27 -0
  21. package/lib/types/components/sheets/extensions/border.d.ts +9 -1
  22. package/lib/types/components/sheets/extensions/column-header-layout.d.ts +1 -0
  23. package/lib/types/components/sheets/extensions/custom.d.ts +1 -0
  24. package/lib/types/components/sheets/extensions/font.d.ts +6 -0
  25. package/lib/types/components/sheets/extensions/marker.d.ts +1 -0
  26. package/lib/types/components/sheets/extensions/render-primitive-cache.d.ts +37 -0
  27. package/lib/types/components/sheets/extensions/row-header-layout.d.ts +1 -0
  28. package/lib/types/components/sheets/interfaces.d.ts +1 -0
  29. package/lib/types/components/sheets/sheet-cell-document-view-model.d.ts +2 -0
  30. package/lib/types/components/sheets/sheet-component.d.ts +3 -0
  31. package/lib/types/components/sheets/sheet.render-skeleton.d.ts +9 -0
  32. package/lib/types/components/sheets/spreadsheet.d.ts +25 -3
  33. package/lib/types/context.d.ts +3 -0
  34. package/lib/types/index.d.ts +0 -3
  35. package/lib/types/layer.d.ts +8 -1
  36. package/lib/types/scene.d.ts +13 -1
  37. package/lib/types/scene.transformer.d.ts +21 -1
  38. package/lib/types/shape/control.d.ts +1 -0
  39. package/lib/types/shape/scroll-bar.d.ts +2 -2
  40. package/lib/types/shape/text.d.ts +6 -1
  41. package/lib/types/transformer-rotation.d.ts +42 -0
  42. package/lib/types/viewport.d.ts +3 -2
  43. package/lib/umd/index.js +5 -5
  44. package/lib/worker.js +236 -1
  45. package/package.json +6 -6
@@ -14,11 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { Nullable } from '@univerjs/core';
17
+ import { Disposable } from '@univerjs/core';
17
18
  import type { Vector2 } from '../basics/vector2';
18
19
  import type { UniverRenderingContext } from '../context';
19
20
  import type { Scene } from '../scene';
20
21
  import type { Viewport } from '../viewport';
21
- import { Disposable } from '@univerjs/core';
22
22
  import { Rect } from './rect';
23
23
  export interface IScrollBarProps {
24
24
  mainScene?: Scene;
@@ -162,7 +162,7 @@ export declare class ScrollBar extends Disposable {
162
162
  * @param contentHeight
163
163
  */
164
164
  resize(viewportWidth?: number, viewportHeight?: number, contentWidth?: number, contentHeight?: number): void;
165
- makeDirty(state: boolean): void;
165
+ makeDirty(state: boolean, viewportScroll?: boolean): void;
166
166
  makeViewDirty(state: boolean): void;
167
167
  pick(coord: Vector2): Rect<import("./rect").IRectProps> | null;
168
168
  private _initialScrollRect;
@@ -14,9 +14,9 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { Nullable } from '@univerjs/core';
17
+ import { CellValueType, HorizontalAlign, TextDecoration, VerticalAlign } from '@univerjs/core';
17
18
  import type { UniverRenderingContext } from '../context';
18
19
  import type { IShapeProps } from './shape';
19
- import { CellValueType, HorizontalAlign, TextDecoration, VerticalAlign } from '@univerjs/core';
20
20
  import { DocSimpleSkeleton } from '../components/docs/layout/doc-simple-skeleton';
21
21
  import { Shape } from './shape';
22
22
  export interface ITextProps extends IShapeProps {
@@ -48,6 +48,11 @@ export declare class Text extends Shape<ITextProps> {
48
48
  constructor(key: string, props: ITextProps);
49
49
  static drawWith(ctx: UniverRenderingContext, props: ITextProps, _skeleton?: DocSimpleSkeleton): number;
50
50
  static drawPlainWith(ctx: UniverRenderingContext, props: ITextProps): number;
51
+ /** Ink bounds of the same uncropped layout used by drawPlainWith, before any canvas transform. */
52
+ static getPlainTextVerticalBounds(props: Pick<ITextProps, 'text' | 'fontStyle' | 'height' | 'top' | 'vAlign'>): {
53
+ top: number;
54
+ bottom: number;
55
+ };
51
56
  private static _getCachedLayout;
52
57
  /**
53
58
  * Draw text decoration lines (underline, strikethrough, etc.)
@@ -0,0 +1,42 @@
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
+ import type { IBoundRectNoAngle, IPoint } from './basics/vector2';
17
+ export interface IRotationHandleCandidate {
18
+ center: IPoint;
19
+ attachment: IPoint;
20
+ side: 'top' | 'bottom';
21
+ }
22
+ export interface IRotationHandlePlacement {
23
+ center: IPoint;
24
+ attachment: IPoint;
25
+ side: 'top' | 'bottom' | 'inset';
26
+ adjusted: boolean;
27
+ }
28
+ export interface IRotationHandleObstacle extends IPoint {
29
+ radius: number;
30
+ }
31
+ export interface IRotationHandleLayout {
32
+ bounds: IBoundRectNoAngle;
33
+ radius: number;
34
+ artworkRadius: number;
35
+ preferred: IRotationHandleCandidate;
36
+ opposite: IRotationHandleCandidate;
37
+ corners: IPoint[];
38
+ obstacles: IRotationHandleObstacle[];
39
+ previousSide?: IRotationHandlePlacement['side'];
40
+ }
41
+ /** Keep the complete interaction target inside the viewport; all distances are screen pixels. */
42
+ export declare function placeRotationHandle(layout: IRotationHandleLayout): IRotationHandlePlacement | undefined;
@@ -14,14 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { EventState, IPosition, Nullable } from '@univerjs/core';
17
+ import { EventSubject } from '@univerjs/core';
18
+ import { Subject } from 'rxjs';
17
19
  import type { BaseObject } from './base-object';
18
20
  import type { IWheelEvent } from './basics/i-events';
19
21
  import type { IBoundRectNoAngle, IViewportInfo } from './basics/vector2';
20
22
  import type { UniverRenderingContext } from './context';
21
23
  import type { Scene } from './scene';
22
24
  import type { ScrollBar } from './shape/scroll-bar';
23
- import { EventSubject } from '@univerjs/core';
24
- import { Subject } from 'rxjs';
25
25
  import { Transform } from './basics/transform';
26
26
  import { Vector2 } from './basics/vector2';
27
27
  import { Canvas as UniverCanvas } from './canvas';
@@ -345,6 +345,7 @@ export declare class Viewport {
345
345
  * @param isMaxLayer
346
346
  */
347
347
  render(parentCtx?: UniverRenderingContext, objects?: BaseObject[], isMaxLayer?: boolean, viewportInfo?: IViewportInfo): void;
348
+ reuseCachedRender(objects: BaseObject[], viewportInfo?: IViewportInfo): void;
348
349
  private _makeDefaultViewport;
349
350
  calcViewportInfo(): IViewportInfo;
350
351
  /**