@univerjs/engine-render 0.1.14 → 0.1.15

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.
@@ -14,6 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export declare function getCurrentScrollXY(scrollTimer: any): {
17
- scrollX: any;
18
- scrollY: any;
17
+ scrollX: number;
18
+ scrollY: number;
19
19
  };
@@ -1,4 +1,4 @@
1
- import { IRange, IRangeWithCoord, IScale, ISelectionCell, ISelectionCellWithCoord, IStyleBase, LocaleService, Nullable } from '@univerjs/core';
1
+ import { IRange, IRangeWithCoord, IScale, ISelectionCellWithCoord, IStyleBase, LocaleService, Nullable } from '@univerjs/core';
2
2
  import { IBoundRectNoAngle } from './vector2';
3
3
  import { IDocumentSkeletonFontStyle } from './i-document-skeleton-cached';
4
4
 
@@ -73,10 +73,6 @@ export declare function getCellPositionByIndex(row: number, column: number, rowH
73
73
  endX: number;
74
74
  };
75
75
  export declare function getCellByIndex(row: number, column: number, rowHeightAccumulation: number[], columnWidthAccumulation: number[], mergeData: IRange[]): ISelectionCellWithCoord;
76
- /**
77
- * Determines whether the cell(row, column) is within the range of the merged cells.
78
- */
79
- export declare function getCellInfoInMergeData(row: number, column: number, mergeData?: IRange[]): ISelectionCell;
80
76
  /**
81
77
  * Determine whether there are any cells in a row that are not in the merged cells, mainly used for the calculation of auto height
82
78
  */
@@ -1,4 +1,4 @@
1
- import { BooleanNumber, DocumentDataModel, HorizontalAlign, IContextService, LocaleService, ObjectMatrix, VerticalAlign, WrapStrategy, ICellData, IPaddingData, IRange, ISelectionCellWithCoord, ITextRotation, IWorksheetData, Nullable, Styles, Worksheet } from '@univerjs/core';
1
+ import { BooleanNumber, DocumentDataModel, HorizontalAlign, IContextService, LocaleService, ObjectMatrix, VerticalAlign, WrapStrategy, ICellData, IPaddingData, IRange, IRowAutoHeightInfo, ISelectionCellWithCoord, ITextRotation, IWorksheetData, Nullable, Styles, Worksheet } from '@univerjs/core';
2
2
  import { IBoundRectNoAngle, IViewportInfo } from '../../basics/vector2';
3
3
  import { DocumentSkeleton } from '../docs/layout/doc-skeleton';
4
4
  import { Skeleton } from '../skeleton';
@@ -13,10 +13,6 @@ export declare function getDocsSkeletonPageSize(documentSkeleton: DocumentSkelet
13
13
  width: number;
14
14
  height: number;
15
15
  } | undefined;
16
- export interface IRowAutoHeightInfo {
17
- row: number;
18
- autoHeight?: number;
19
- }
20
16
  interface IRowColumnSegment {
21
17
  startRow: number;
22
18
  endRow: number;
@@ -63,7 +63,9 @@ export declare class Spreadsheet extends SheetComponent {
63
63
  endColumn: number;
64
64
  } | undefined;
65
65
  /**
66
+ * Since multiple controllers, not just the sheet-render.controller, invoke spreadsheet.makeDirty() — for instance, the cf.render-controller — it's essential to also call viewport.markDirty() whenever spreadsheet.makeDirty() is triggered.
66
67
  * @param state
68
+ * @returns
67
69
  */
68
70
  makeDirty(state?: boolean): this;
69
71
  setDirtyArea(dirtyBounds: IBoundRectNoAngle[]): void;
@@ -22,7 +22,7 @@ export declare class SceneViewer extends BaseObject {
22
22
  enableSelectedClipElement(): void;
23
23
  disableSelectedClipElement(): void;
24
24
  allowSelectedClipElement(): boolean;
25
- pick(coord: Vector2): Nullable<BaseObject | ThinScene>;
25
+ pick(coord: Vector2): Nullable<ThinScene | BaseObject>;
26
26
  dispose(): void;
27
27
  private _initialProps;
28
28
  }
@@ -47,14 +47,23 @@ export declare class Scene extends ThinScene {
47
47
  setCursor(val: CURSOR_TYPE): void;
48
48
  setDefaultCursor(val: CURSOR_TYPE): void;
49
49
  resize(width?: number, height?: number): this;
50
+ setScaleValue(scaleX: number, scaleY: number): void;
50
51
  /**
51
52
  * scale to value, absolute
53
+ * setTransform ---> viewport._updateScrollBarPosByViewportScroll ---> scrollTo
52
54
  */
53
55
  scale(scaleX?: number, scaleY?: number): this;
54
56
  /**
55
57
  * current scale plus offset, relative
56
58
  */
57
59
  scaleBy(scaleX?: number, scaleY?: number): this;
60
+ /**
61
+ * This sequence will initiate a series of updates:
62
+ * scene._setTransForm --> viewport@resetCanvasSizeAndUpdateScrollBar ---> scrollTo ---> limitedScroll ---> onScrollBeforeObserver ---> setScrollInfo
63
+ * scrollInfo needs accurate scene width & height, limitedScroll depends on scene & engine's width & height
64
+ * @param state
65
+ * @returns
66
+ */
58
67
  transformByState(state: ISceneTransformState): void;
59
68
  getParent(): ThinEngine<Scene> | SceneViewer;
60
69
  getEngine(): Nullable<ThinEngine<Scene>>;
@@ -39,8 +39,8 @@ export interface IScrollObserverParam {
39
39
  /**
40
40
  * scrollX for viewport
41
41
  */
42
- actualScrollX?: number;
43
- actualScrollY?: number;
42
+ viewportScrollX?: number;
43
+ viewportScrollY?: number;
44
44
  limitX?: number;
45
45
  limitY?: number;
46
46
  isTrigger?: boolean;
@@ -56,18 +56,23 @@ export declare class Viewport {
56
56
  */
57
57
  scrollX: number;
58
58
  scrollY: number;
59
- _preScrollX: number;
60
- _preScrollY: number;
59
+ private _preScrollX;
60
+ private _preScrollY;
61
61
  /**
62
- * The actual scroll offset equals the distance from the content area position to the top, and there is a conversion relationship with scrollX and scrollY
63
- * use getActualScroll to get scrolling value for spreadsheet.
62
+ * The viewport scroll offset equals the distance from the content area position to the top, and there is a conversion relationship with scrollX and scrollY
63
+ * use transScroll2ViewportScrollValue to get scrolling value for spreadsheet.
64
64
  */
65
- viewportScrollX: number;
66
- viewportScrollY: number;
67
- preViewportScrollX: number;
68
- preViewportScrollY: number;
69
- _deltaViewportScrollX: number;
70
- _deltaViewportScrollY: number;
65
+ private _viewportScrollX;
66
+ private _viewportScrollY;
67
+ private _preViewportScrollX;
68
+ private _preViewportScrollY;
69
+ private _deltaViewportScrollX;
70
+ private _deltaViewportScrollY;
71
+ /**
72
+ * physcal scene size (scene width * scale)
73
+ */
74
+ private _physicalSceneWidth;
75
+ private _physicalSceneHeight;
71
76
  onMouseWheelObserver: Observable<IWheelEvent>;
72
77
  onScrollAfterObserver: Observable<IScrollObserverParam>;
73
78
  onScrollBeforeObserver: Observable<IScrollObserverParam>;
@@ -155,6 +160,10 @@ export declare class Viewport {
155
160
  set width(w: Nullable<number>);
156
161
  set height(h: Nullable<number>);
157
162
  get isActive(): boolean;
163
+ set viewportScrollX(val: number);
164
+ get viewportScrollX(): number;
165
+ set viewportScrollY(val: number);
166
+ get viewportScrollY(): number;
158
167
  private set top(value);
159
168
  private set left(value);
160
169
  private set bottom(value);
@@ -167,43 +176,56 @@ export declare class Viewport {
167
176
  enable(): void;
168
177
  disable(): void;
169
178
  /**
170
- * 物理 canvas 大小改变时调用(调整 window 大小时触发)
179
+ * invoked when canvas element size change
180
+ * engineResizeObserver --> engine.resizeBySize --> scene._setTransForm
171
181
  */
172
- resetSizeAndScrollBar(): void;
182
+ resetCanvasSizeAndUpdateScrollBar(): void;
173
183
  setScrollBar(instance: BaseScrollBar): void;
174
184
  removeScrollBar(): void;
175
185
  /**
176
- * resetSizeAndScrollBar 不同
177
- * 此方法是调整冻结行列设置时 & 初始化时触发, resize window 时并不会触发
186
+ * NOT same as resetCanvasSizeAndScrollbar
187
+ * This method is triggered when adjusting the frozen row & col settings, and during initialization,
188
+ * it is not triggered when resizing the window.
178
189
  *
179
- * 注意参数 position 不一定有 height & width 对于 viewMain 只有 left top bottom right
180
- * this.width this.height 也有可能是 undefined
181
- * 因此应通过 _getViewPortSize 获取宽高
190
+ * Note that the 'position' parameter may not always have 'height' and 'width' properties. For the 'viewMain' element, it only has 'left', 'top', 'bottom', and 'right' properties.
191
+ * Additionally, 'this.width' and 'this.height' may also be 'undefined'.
192
+ * Therefore, you should use the '_getViewPortSize' method to retrieve the width and height.
182
193
  * @param position
183
194
  */
184
- resize(position: IViewPosition): void;
195
+ resizeWhenFreezeChange(position: IViewPosition): void;
185
196
  setPadding(param: IPosition): void;
186
197
  resetPadding(): void;
187
198
  /**
199
+ * set scrollXY and viewportScrollXY, and update scrollInfo without notify listeners of scrollInfo$
200
+ * mainly call by scroll.render-controller and viewport.resize ...
201
+ * only viewMain would call scrollTo, other views did not call scroll, see scroll.render-controller
202
+ * @param pos
203
+ *
204
+ * when scrolling:
188
205
  *
189
- * 改动 scrollbar 的位置,不是 viewport content 滚动
190
- * scroll to position, absolute
191
- * 只有 viewMain 才会被调用 scrollTo 其他 viewport 都不会调用此方法
192
- * 具体在 scroll.controller
206
+ * scroll.render-controller@_scrollManagerService.scrollInfo$.subscribe --> scrollTo
207
+ *
208
+ * when change skelenton:
209
+ * _currentSkeletonBefore$ ---> scroll.render-controller@_updateSceneSize --> setSearchParam --> scene@_setTransForm ---> viewport.resetCanvasSizeAndUpdateScrollBar ---> scrollTo ---> _scroll
210
+ * --> onScrollAfterObserver.notifyObservers --> scroll.render-controller@onScrollAfterObserver ---> setScrollInfoToCurrSheetWithoutNotify ---> sms._setScrollInfo
211
+ *
212
+ * _currentSkeleton$ ---> selection.render-controller ---> formula@_autoScroll ---> viewport.resize ---> get scrollXY by viewportScrollXY ---> scrollTo
213
+ * _currentSkeleton$ ---> selection.render-controller ---> setCurrentSelection ---> formula@_autoScroll ---> scrollTo
214
+ * _currentSkeleton$ ---> freeze.render-controller@_refreshFreeze --> viewport.resize ---> scrollTo ---> _scroll
215
+ *
216
+ * TODO: @lumix many side effects in scrollTo, it would update scrollXY & viewportScrollXY, and notify listeners of scrollInfo$
193
217
  *
194
218
  * Debug
195
219
  * window.scene.getViewports()[0].scrollTo({x: 14.2, y: 1.8}, true)
196
- * @param pos
197
- * @returns
198
220
  */
199
- scrollTo(pos: IScrollBarPosition, isTrigger?: boolean): {
221
+ scrollTo(pos: IScrollBarPosition): {
200
222
  isLimitedX: boolean;
201
223
  isLimitedY: boolean;
202
224
  } | undefined;
203
225
  /**
204
226
  * current position plus offset, relative
205
227
  * @param pos
206
- * @returns
228
+ * @returns isLimited
207
229
  */
208
230
  scrollBy(pos: IScrollBarPosition, isTrigger?: boolean): {
209
231
  isLimitedX: boolean;
@@ -222,11 +244,11 @@ export declare class Viewport {
222
244
  isLimitedX: boolean;
223
245
  isLimitedY: boolean;
224
246
  } | undefined;
225
- getBarScroll(actualX: number, actualY: number): {
247
+ transViewportScroll2ScrollValue(viewportScrollX: number, viewportScrollY: number): {
226
248
  x: number;
227
249
  y: number;
228
250
  };
229
- getActualScroll(scrollX: number, scrollY: number): {
251
+ transScroll2ViewportScrollValue(scrollX: number, scrollY: number): {
230
252
  x: number;
231
253
  y: number;
232
254
  };
@@ -234,12 +256,12 @@ export declare class Viewport {
234
256
  * get actual scroll value by scrollXY
235
257
  * @returns
236
258
  */
237
- getTransformedScroll(): {
259
+ getViewportScrollByScroll(): {
238
260
  x: number;
239
261
  y: number;
240
262
  };
241
263
  getScrollBar(): Nullable<BaseScrollBar>;
242
- updateScroll(param: IScrollObserverParam): this;
264
+ updateScroll(current: IScrollObserverParam): this;
243
265
  getScrollBarTransForm(): Transform;
244
266
  shouldIntoRender(): boolean;
245
267
  /**
@@ -272,20 +294,31 @@ export declare class Viewport {
272
294
  markForceDirty(state?: boolean): void;
273
295
  resetPrevCacheBounds(): void;
274
296
  get isForceDirty(): boolean;
297
+ /**
298
+ * resize canvas & use viewportScrollXY to scrollTo
299
+ */
275
300
  private _resizeCacheCanvas;
301
+ /**
302
+ * This method will be invoked whenever the viewport is resized.
303
+ */
304
+ private _updateScrollBarPosByViewportScroll;
276
305
  private _getViewPortSize;
277
- private _scrollRendered;
306
+ /**
307
+ * update pre scroll value has handled in updateScroll()
308
+ */
309
+ private _afterRender;
278
310
  private _triggerScrollStop;
279
311
  /**
280
312
  * Scroll Viewport
281
313
  * Only the 'viewMain' will enter this function, other viewports will not.
282
314
  *
283
- * caller: scroll.controller viewportMain.proscrollTo(config)
315
+ * caller: scroll.render-controller viewportMain.scrollTo({x, y}))
316
+ * this._scrollManagerService.scrollInfo$.subscribe --> scrollTo --> _scroll
284
317
  * @param scrollType
285
- * @param pos viewMain 滚动条的位置
318
+ * @param scrollBarPos viewMain 滚动条的位置
286
319
  * @param isTrigger
287
320
  */
288
- private _scroll;
321
+ private _scrollToScrollbarPos;
289
322
  expandBounds(value: {
290
323
  top: number;
291
324
  left: number;
@@ -297,7 +330,7 @@ export declare class Viewport {
297
330
  private _diffViewBound;
298
331
  private _calcDiffCacheBound;
299
332
  private _drawScrollbar;
300
- private _setWithAndHeight;
333
+ private _setViewportWidthAndHeight;
301
334
  private _getBoundScale;
302
335
  /**
303
336
  * main canvas element resize