@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.
- package/README.md +17 -5
- package/lib/cjs/{worker-dzyTVvQi.js → doc-skeleton-xHfOLvcR.js} +105 -263
- package/lib/cjs/index.js +3070 -1374
- package/lib/cjs/worker.js +239 -4
- package/lib/{es/worker-BlCdBXpV.js → doc-skeleton-h5WFPD-i.js} +88 -258
- package/lib/{worker-BlCdBXpV.js → es/doc-skeleton-h5WFPD-i.js} +88 -258
- package/lib/es/index.js +2198 -502
- package/lib/es/worker.js +236 -1
- package/lib/index.js +2198 -502
- package/lib/types/base-object.d.ts +5 -0
- package/lib/types/basics/draw.d.ts +1 -1
- package/lib/types/basics/interfaces.d.ts +1 -0
- package/lib/types/components/component.d.ts +1 -0
- package/lib/types/components/docs/document-layout-presentation.d.ts +1 -0
- package/lib/types/components/docs/layout/shaping-engine/font-cache.d.ts +2 -0
- package/lib/types/components/docs/layout/tools.d.ts +2 -0
- package/lib/types/components/docs/view-model/document-view-model.d.ts +2 -1
- package/lib/types/components/extension.d.ts +5 -1
- package/lib/types/components/sheets/extensions/background.d.ts +1 -0
- package/lib/types/components/sheets/extensions/border-row-cache.d.ts +27 -0
- package/lib/types/components/sheets/extensions/border.d.ts +9 -1
- package/lib/types/components/sheets/extensions/column-header-layout.d.ts +1 -0
- package/lib/types/components/sheets/extensions/custom.d.ts +1 -0
- package/lib/types/components/sheets/extensions/font.d.ts +6 -0
- package/lib/types/components/sheets/extensions/marker.d.ts +1 -0
- package/lib/types/components/sheets/extensions/render-primitive-cache.d.ts +37 -0
- package/lib/types/components/sheets/extensions/row-header-layout.d.ts +1 -0
- package/lib/types/components/sheets/interfaces.d.ts +1 -0
- package/lib/types/components/sheets/sheet-cell-document-view-model.d.ts +2 -0
- package/lib/types/components/sheets/sheet-component.d.ts +3 -0
- package/lib/types/components/sheets/sheet.render-skeleton.d.ts +9 -0
- package/lib/types/components/sheets/spreadsheet.d.ts +25 -3
- package/lib/types/context.d.ts +3 -0
- package/lib/types/index.d.ts +0 -3
- package/lib/types/layer.d.ts +8 -1
- package/lib/types/scene.d.ts +13 -1
- package/lib/types/scene.transformer.d.ts +21 -1
- package/lib/types/shape/control.d.ts +1 -0
- package/lib/types/shape/scroll-bar.d.ts +2 -2
- package/lib/types/shape/text.d.ts +6 -1
- package/lib/types/transformer-rotation.d.ts +42 -0
- package/lib/types/viewport.d.ts +3 -2
- package/lib/umd/index.js +5 -5
- package/lib/worker.js +236 -1
- package/package.json +6 -6
package/lib/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as UniverRenderingContext2D, $n as DRAWING_OBJECT_UPPER_LAYER_INDEX, $t as getTextWithCaps, A as getDocsTableViewportLeft, An as ptToPixel, At as getRotatedBoundInGroup, B as CheckboxShape, Bn as FontCache, Bt as degToRad, C as glyphIterator, Cn as isRectIntersect, Ct as ObjectType, D as measureTextWithCharacterSpacing, Dn as pixelToPt, Dt as getDrawingGroupState, E as getTextHorizontalScale, En as mergeInfoOffset, Et as TRANSFORM_CHANGE_OBSERVABLE_TYPE, F as getDocumentCompatibilityPolicy, Fn as radToDeg, Ft as cancelRequestFrame, G as getDocsCustomBlockRenderViewport, Gn as DEFAULT_DOCUMENT_FONTSIZE, Gt as getColor, H as isCheckboxGlyph, Hn as BORDER_TYPE, Ht as fixLineWidthByScale, I as getSmallCapsFontStyle, In as requestNewFrame, It as checkStyle, J as CanvasRenderMode, Jn as DEFAULT_SKELETON_FOOTER, Jt as getFontStyleString, K as setDocsCustomBlockRenderViewportProvider, Kn as DEFAULT_FONTFACE_PLANE, Kt as getDPI, L as Liquid, Ln as startWithEmoji, Lt as clampRange, M as setDocsTableRenderViewportProvider, Mn as pxToInch, Mt as Vector2, N as getDocumentLayoutPresentation, Nn as pxToNum, Nt as offsetRotationAxis, O as getDocsTableLayoutViewportWidth, On as precisionTo, Ot as getGroupState, P as registerDocumentLayoutPresentation, Pn as pxToPt, Pt as IsSafari, Q as UniverRenderingContext, Qn as DRAWING_OBJECT_LOWER_LAYER_INDEX, Qt as getSystemHighlightColor, R as LineBreaker, Rn as toPx, Rt as createCanvasElement, S as getPageFromPath, Sn as isObject, St as BaseObject, T as getPairKerningAdjustment, Tn as isString, Tt as Transform, U as SHAPE_OBJECT_ARRAY, Un as COLOR_BLACK_RGB, Ut as generateRandomKey, V as getCheckboxShapeSize, Vn as invalidateDocumentFontMetrics, Vt as expandRangeIfIntersects, W as Shape, Wn as CURSOR_TYPE, Wt as getCellPositionByIndex, X as SceneCanvas, Xn as DOCUMENT_CONTEXT_CLIP_TYPE, Xt as getScale, Y as HitCanvas, Yn as DEFAULT_SKELETON_HEADER, Yt as getPointerPrefix, Z as UniverPrintingContext, Zn as DRAWING_OBJECT_LAYER_INDEX, Zt as getSizeForDom, _ as getDocumentSkeletonColumnPagePathInfo, _n as isCjkRightAlignedPunctuation, _t as LineType, a as DocumentEditArea, an as hasLatinExtendedA, ar as MIN_COL_WIDTH, at as drawLineByBorderType, b as getLastLine, bn as isFunction, bt as cjk, c as DataStreamTreeNode, cn as hasScrollableOverflow, cr as SHAPE_TYPE, ct as getLineWidth, d as resolveHeaderFooterFieldGlyph, dn as hasTibetan, dt as getRotateOrientation, en as getValueType, er as FIX_ONE_PIXEL_BLUR_OFFSET, et as INITIAL_Path2, f as columnIterator, fn as inViewRanges, ft as getTranslateInSpreadContextWithPixelRatio, g as getCharSpaceApply, gn as isCjkLeftAlignedPunctuation, gt as GlyphType, h as documentSkeletonTableIterator, hn as isCjkCenterAlignedPunctuation, ht as DocumentSkeletonPageType, in as hasBasicLatin, ir as MIDDLE_CELL_POS_MAGIC_NUMBER, it as drawDiagonalLineByBorderType, j as hasDocsTableHorizontalViewport, jn as ptToPx, jt as transformObjectOutOfGroup, k as getDocsTableRenderViewport, kn as ptToMM, kt as getRenderTransformBaseOnParentBound, l as createDocumentLineBreaker, ln as hasSpace, lr as _defineProperty, lt as getLineWith, m as documentSkeletonLineIterator, mn as isArray, mt as BreakType, nn as hasAllLatin, nr as MAXIMUM_COL_WIDTH, nt as calculateRectRotate, o as DocumentViewModel, on as hasLatinExtendedB, or as ORIENTATION_TYPE, ot as getDevicePixelRatio, p as compareDocumentSkeletonNestedPagePathOrder, pn as injectStyle, pt as setLineType, q as Canvas, qn as DEFAULT_OFFSET_SPACING, qt as getFirstGrapheme, rn as hasArabic, rr as MAXIMUM_ROW_HEIGHT, rt as clearLineByBorderType, s as parseDataStreamToTree, sn as hasLatinOneSupplement, sr as RENDER_CLASS_TYPE, st as getLineOffset, t as DocumentSkeleton, tn as graphemeSegmenter, tr as LINK_VIEW_PORT_TYPE, tt as Path2, u as getTableIdAndSliceIndex, un as hasThai, ut as getRotateOffsetAndFarthestHypotenuse, v as getDocumentSkeletonNestedPageOffset, vn as isDate, vt as PageLayoutType, w as lineIterator, wn as isRegExp, wt as INITIAL_MATRIX, x as getNumberUnitValue, xn as isNumber, xt as BASE_OBJECT_ARRAY, y as getLastColumn, yn as isEmojiGrapheme, yt as SkeletonType, z as CHECK_OBJECT_ARRAY, zn as DEFAULT_MEASURE_TEXT, zt as createImageElement } from "./doc-skeleton-h5WFPD-i.js";
|
|
2
2
|
import { BaselineOffset, BooleanNumber, BorderStyleTypes, CellValueType, ColorKit, ColumnSeparatorType, DEFAULT_STYLES, DashStyleType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentDataModel, DocumentFlavor, EventSubject, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, LocaleService, LookUp, MOVE_BUFFER_VALUE, ObjectMatrix, Plugin, Range, Rectangle, Registry, SHEET_TEXT_LINE_GAP, SheetSkeleton, TabStopAlignment, TableTextWrapType, TextDecoration, ThemeService, Tools, UniverInstanceType, VerticalAlign, WrapStrategy, checkParagraphHasIndentByStyle, createIdentifier, getColorStyle, getDisplayValueFromCell, invertColorByMatrix, isCellCoverable, isClassDependencyItem, isDefaultFormat, isNullCell, isWhiteColor, merge, noop, numberToABC, numfmt, registerDependencies, remove, requestImmediateMacroTask, resolveDocumentParagraphStyle, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
|
|
3
3
|
import { BehaviorSubject, Observable, Subject, Subscription, distinctUntilChanged, merge as merge$1, shareReplay, startWith } from "rxjs";
|
|
4
4
|
import { getOverflowAncestors } from "@floating-ui/dom";
|
|
@@ -739,6 +739,9 @@ var RenderComponent = class extends BaseObject {
|
|
|
739
739
|
super(..._args);
|
|
740
740
|
_defineProperty(this, "_extensions", /* @__PURE__ */ new Map());
|
|
741
741
|
}
|
|
742
|
+
canReuseViewportCache() {
|
|
743
|
+
return super.canReuseViewportCache() && this.getExtensionsByOrder().every((extension) => typeof extension.canReuseViewportCache === "function" && extension.canReuseViewportCache() === true);
|
|
744
|
+
}
|
|
742
745
|
get extensions() {
|
|
743
746
|
return this._extensions;
|
|
744
747
|
}
|
|
@@ -747,8 +750,12 @@ var RenderComponent = class extends BaseObject {
|
|
|
747
750
|
for (const extension of extensions) {
|
|
748
751
|
extension.parent = this;
|
|
749
752
|
this._extensions.set(extension.uKey, extension);
|
|
753
|
+
this.makeForceDirty(true);
|
|
754
|
+
this.makeDirtyNoDebounce(true);
|
|
750
755
|
disposableCollection.add(toDisposable(() => {
|
|
751
756
|
this._extensions.delete(extension.uKey);
|
|
757
|
+
this.makeForceDirty(true);
|
|
758
|
+
this.makeDirtyNoDebounce(true);
|
|
752
759
|
extension.parent = null;
|
|
753
760
|
}));
|
|
754
761
|
}
|
|
@@ -765,8 +772,9 @@ var RenderComponent = class extends BaseObject {
|
|
|
765
772
|
}
|
|
766
773
|
draw(ctx, bounds) {}
|
|
767
774
|
dispose() {
|
|
775
|
+
const extensions = [...this._extensions.values()];
|
|
768
776
|
super.dispose();
|
|
769
|
-
for (const extension of
|
|
777
|
+
for (const extension of extensions) extension.dispose();
|
|
770
778
|
this._extensions.clear();
|
|
771
779
|
}
|
|
772
780
|
};
|
|
@@ -958,7 +966,7 @@ var Control = class extends Rect {
|
|
|
958
966
|
const center = this.ancestorTransform.applyPoint(new Vector2(this.width / 2, this.height / 2));
|
|
959
967
|
const scale = (_this$getScene = this.getScene()) === null || _this$getScene === void 0 ? void 0 : _this$getScene.getAncestorScale();
|
|
960
968
|
const distance = Math.hypot((coord.x - center.x) * ((scale === null || scale === void 0 ? void 0 : scale.scaleX) ?? 1), (coord.y - center.y) * ((scale === null || scale === void 0 ? void 0 : scale.scaleY) ?? 1));
|
|
961
|
-
return distance <=
|
|
969
|
+
return distance <= 22 || this.isHit(coord) ? distance : Number.POSITIVE_INFINITY;
|
|
962
970
|
}
|
|
963
971
|
};
|
|
964
972
|
|
|
@@ -2736,14 +2744,15 @@ var ScrollBar = class ScrollBar extends Disposable {
|
|
|
2736
2744
|
this._resizeVertical();
|
|
2737
2745
|
this._resizeRightBottomCorner();
|
|
2738
2746
|
}
|
|
2739
|
-
makeDirty(state) {
|
|
2747
|
+
makeDirty(state, viewportScroll = false) {
|
|
2740
2748
|
var _this$horizonScrollTr5, _this$horizonThumbRec8, _this$verticalScrollT5, _this$verticalThumbRe8, _this$placeholderBarR4;
|
|
2741
2749
|
(_this$horizonScrollTr5 = this.horizonScrollTrack) === null || _this$horizonScrollTr5 === void 0 || _this$horizonScrollTr5.makeDirty(state);
|
|
2742
2750
|
(_this$horizonThumbRec8 = this.horizonThumbRect) === null || _this$horizonThumbRec8 === void 0 || _this$horizonThumbRec8.makeDirty(state);
|
|
2743
2751
|
(_this$verticalScrollT5 = this.verticalScrollTrack) === null || _this$verticalScrollT5 === void 0 || _this$verticalScrollT5.makeDirty(state);
|
|
2744
2752
|
(_this$verticalThumbRe8 = this.verticalThumbRect) === null || _this$verticalThumbRe8 === void 0 || _this$verticalThumbRe8.makeDirty(state);
|
|
2745
2753
|
(_this$placeholderBarR4 = this.placeholderBarRect) === null || _this$placeholderBarR4 === void 0 || _this$placeholderBarR4.makeDirty(state);
|
|
2746
|
-
this.
|
|
2754
|
+
if (viewportScroll && state && !this._mainScene) this._viewport.scene.makeDirtyForViewportScroll(this._viewport);
|
|
2755
|
+
else this.makeViewDirty(state);
|
|
2747
2756
|
}
|
|
2748
2757
|
makeViewDirty(state) {
|
|
2749
2758
|
(this._mainScene || this._viewport.scene).makeDirty(state);
|
|
@@ -3208,6 +3217,40 @@ var Text = class Text extends Shape {
|
|
|
3208
3217
|
}
|
|
3209
3218
|
return totalHeight;
|
|
3210
3219
|
}
|
|
3220
|
+
/** Ink bounds of the same uncropped layout used by drawPlainWith, before any canvas transform. */
|
|
3221
|
+
static getPlainTextVerticalBounds(props) {
|
|
3222
|
+
const { text, fontStyle, height, top = 0, vAlign } = props;
|
|
3223
|
+
if (!text) return {
|
|
3224
|
+
top: 0,
|
|
3225
|
+
bottom: 0
|
|
3226
|
+
};
|
|
3227
|
+
const metrics = FontCache.getMeasureText(text, fontStyle);
|
|
3228
|
+
const cached = Text._layoutCache.get(`${fontStyle}\u0000${text}`);
|
|
3229
|
+
const totalHeight = (cached === null || cached === void 0 ? void 0 : cached.totalHeight) ?? metrics.fontBoundingBoxAscent + metrics.fontBoundingBoxDescent;
|
|
3230
|
+
const lines = (cached === null || cached === void 0 ? void 0 : cached.lines) ?? [{
|
|
3231
|
+
text,
|
|
3232
|
+
height: totalHeight,
|
|
3233
|
+
baseline: metrics.fontBoundingBoxAscent
|
|
3234
|
+
}];
|
|
3235
|
+
let lineTop = top + (vAlign === VerticalAlign.TOP ? 0 : vAlign === VerticalAlign.MIDDLE ? (height - totalHeight) / 2 : height - totalHeight);
|
|
3236
|
+
let inkTop = Infinity;
|
|
3237
|
+
let inkBottom = -Infinity;
|
|
3238
|
+
for (const line of lines) {
|
|
3239
|
+
if (line.text) {
|
|
3240
|
+
const ink = line.text === text ? metrics : FontCache.getMeasureText(line.text, fontStyle);
|
|
3241
|
+
inkTop = Math.min(inkTop, lineTop + line.baseline - (ink.actualBoundingBoxAscent ?? line.baseline));
|
|
3242
|
+
inkBottom = Math.max(inkBottom, lineTop + line.baseline + (ink.actualBoundingBoxDescent ?? line.height - line.baseline));
|
|
3243
|
+
}
|
|
3244
|
+
lineTop += line.height;
|
|
3245
|
+
}
|
|
3246
|
+
return Number.isFinite(inkTop) && Number.isFinite(inkBottom) ? {
|
|
3247
|
+
top: inkTop,
|
|
3248
|
+
bottom: inkBottom
|
|
3249
|
+
} : {
|
|
3250
|
+
top: 0,
|
|
3251
|
+
bottom: 0
|
|
3252
|
+
};
|
|
3253
|
+
}
|
|
3211
3254
|
static _getCachedLayout(text, fontStyle) {
|
|
3212
3255
|
const cacheKey = `${fontStyle}\u0000${text}`;
|
|
3213
3256
|
const cached = Text._layoutCache.get(cacheKey);
|
|
@@ -3724,6 +3767,7 @@ var DocBackground = class DocBackground extends DocComponent {
|
|
|
3724
3767
|
var ComponentExtension = class {
|
|
3725
3768
|
constructor() {
|
|
3726
3769
|
_defineProperty(this, "uKey", "");
|
|
3770
|
+
_defineProperty(this, "viewportCacheReusable", false);
|
|
3727
3771
|
_defineProperty(this, "type", void 0);
|
|
3728
3772
|
_defineProperty(this, "Z_INDEX", 0);
|
|
3729
3773
|
_defineProperty(this, "parent", void 0);
|
|
@@ -3734,6 +3778,9 @@ var ComponentExtension = class {
|
|
|
3734
3778
|
get zIndex() {
|
|
3735
3779
|
return this.Z_INDEX;
|
|
3736
3780
|
}
|
|
3781
|
+
canReuseViewportCache() {
|
|
3782
|
+
return this.viewportCacheReusable;
|
|
3783
|
+
}
|
|
3737
3784
|
draw(_ctx, _parentScale, _skeleton, _diff, _more) {}
|
|
3738
3785
|
clearCache() {}
|
|
3739
3786
|
_getScale(parentScale) {
|
|
@@ -4611,7 +4658,7 @@ var FontAndBaseLine = class extends docExtension {
|
|
|
4611
4658
|
const VERTICAL_DEG = 90;
|
|
4612
4659
|
const isVertical = vertexAngle === VERTICAL_DEG && centerAngle === VERTICAL_DEG;
|
|
4613
4660
|
const horizontalScale = getTextHorizontalScale((_glyph$ts2 = glyph.ts) === null || _glyph$ts2 === void 0 ? void 0 : _glyph$ts2.sa);
|
|
4614
|
-
if (isVertical && !cjk.hasCJK(content)) {
|
|
4661
|
+
if (isVertical && !(renderConfig === null || renderConfig === void 0 ? void 0 : renderConfig.stackedText) && !cjk.hasCJK(content)) {
|
|
4615
4662
|
ctx.save();
|
|
4616
4663
|
ctx.translate(spanStartPoint.x + centerPoint.x, spanStartPoint.y + centerPoint.y);
|
|
4617
4664
|
ctx.rotate(Math.PI / 2);
|
|
@@ -4636,7 +4683,7 @@ var FontAndBaseLine = class extends docExtension {
|
|
|
4636
4683
|
var _glyph$ts3, _glyph$ts4;
|
|
4637
4684
|
let x_offset = 0;
|
|
4638
4685
|
let y_offset = 0;
|
|
4639
|
-
if (isVertical) {
|
|
4686
|
+
if (isVertical && !(renderConfig === null || renderConfig === void 0 ? void 0 : renderConfig.stackedText)) {
|
|
4640
4687
|
const fontHeight = glyph.bBox.aba - glyph.bBox.abd;
|
|
4641
4688
|
x_offset = (glyph.width - glyph.bBox.width) / 2;
|
|
4642
4689
|
y_offset = -(glyph.width - fontHeight) / 2;
|
|
@@ -5386,10 +5433,11 @@ var Documents = class Documents extends DocComponent {
|
|
|
5386
5433
|
const { x, y } = this._drawLiquid;
|
|
5387
5434
|
const originTranslate = Vector2.create(x, y);
|
|
5388
5435
|
const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
|
|
5436
|
+
const spanStartPoint = calculateRectRotate(originTranslate.addByPoint(spanLeft + xOffset, 0), centerPoint, centerAngle, vertexAngle, alignOffset);
|
|
5389
5437
|
const extensionOffset = {
|
|
5390
5438
|
originTranslate,
|
|
5391
|
-
spanStartPoint
|
|
5392
|
-
spanPointWithFont: calculateRectRotate(originTranslate.addByPoint(spanLeft + maxLineAscSin + xOffset, maxLineAscCos), centerPoint, centerAngle, vertexAngle, alignOffset),
|
|
5439
|
+
spanStartPoint,
|
|
5440
|
+
spanPointWithFont: renderConfig.stackedText ? Vector2.create(spanStartPoint.x + centerPoint.x - glyph.bBox.width / 2, spanStartPoint.y + centerPoint.y + (glyph.bBox.aba - glyph.bBox.abd) / 2) : calculateRectRotate(originTranslate.addByPoint(spanLeft + maxLineAscSin + xOffset, maxLineAscCos), centerPoint, centerAngle, vertexAngle, alignOffset),
|
|
5393
5441
|
centerPoint,
|
|
5394
5442
|
alignOffset,
|
|
5395
5443
|
renderConfig
|
|
@@ -6276,6 +6324,14 @@ var SheetComponent = class extends RenderComponent {
|
|
|
6276
6324
|
constructor(oKey, _skeleton) {
|
|
6277
6325
|
super(oKey);
|
|
6278
6326
|
this._skeleton = _skeleton;
|
|
6327
|
+
_defineProperty(this, "_viewportCacheFontRevision", FontCache.metricsRevision);
|
|
6328
|
+
}
|
|
6329
|
+
canReuseViewportCache() {
|
|
6330
|
+
return this._viewportCacheFontRevision === FontCache.metricsRevision && super.canReuseViewportCache();
|
|
6331
|
+
}
|
|
6332
|
+
onViewportCacheReuse(viewportInfo) {
|
|
6333
|
+
var _this$_skeleton;
|
|
6334
|
+
(_this$_skeleton = this._skeleton) === null || _this$_skeleton === void 0 || _this$_skeleton.updateVisibleRange(viewportInfo);
|
|
6279
6335
|
}
|
|
6280
6336
|
getSkeleton() {
|
|
6281
6337
|
return this._skeleton;
|
|
@@ -6286,6 +6342,7 @@ var SheetComponent = class extends RenderComponent {
|
|
|
6286
6342
|
(_this$getScene = this.getScene()) === null || _this$getScene === void 0 || _this$getScene.updateTransformerZero(spreadsheetSkeleton.rowHeaderWidth, spreadsheetSkeleton.columnHeaderHeight);
|
|
6287
6343
|
}
|
|
6288
6344
|
render(mainCtx, bounds) {
|
|
6345
|
+
this._viewportCacheFontRevision = FontCache.metricsRevision;
|
|
6289
6346
|
if (!this.visible) {
|
|
6290
6347
|
this.makeDirty(false);
|
|
6291
6348
|
return this;
|
|
@@ -6326,7 +6383,7 @@ var SpreadsheetHeader = class extends SheetComponent {
|
|
|
6326
6383
|
};
|
|
6327
6384
|
|
|
6328
6385
|
// src/components/sheets/column-header.ts
|
|
6329
|
-
var SpreadsheetColumnHeader = class extends SpreadsheetHeader {
|
|
6386
|
+
var SpreadsheetColumnHeader = class SpreadsheetColumnHeader extends SpreadsheetHeader {
|
|
6330
6387
|
getDocuments() {
|
|
6331
6388
|
throw new Error("Method not implemented.");
|
|
6332
6389
|
}
|
|
@@ -6339,6 +6396,7 @@ var SpreadsheetColumnHeader = class extends SpreadsheetHeader {
|
|
|
6339
6396
|
constructor(oKey, spreadsheetSkeleton) {
|
|
6340
6397
|
super(oKey, spreadsheetSkeleton);
|
|
6341
6398
|
_defineProperty(this, "_columnHeaderLayoutExtension", void 0);
|
|
6399
|
+
this.viewportCacheReusable = this.constructor === SpreadsheetColumnHeader;
|
|
6342
6400
|
this._initialDefaultExtension();
|
|
6343
6401
|
this.makeDirty(true);
|
|
6344
6402
|
}
|
|
@@ -6538,14 +6596,40 @@ const UNIQUE_KEY$6 = "DefaultBackgroundExtension";
|
|
|
6538
6596
|
*/
|
|
6539
6597
|
const DOC_EXTENSION_Z_INDEX = 21;
|
|
6540
6598
|
const PRINTING_Z_INDEX = 21;
|
|
6541
|
-
function
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6599
|
+
function forEachCachedBackground(matrix, ranges, visit) {
|
|
6600
|
+
let cachedRows;
|
|
6601
|
+
for (const range of ranges) {
|
|
6602
|
+
const visitRow = (row) => {
|
|
6603
|
+
const values = matrix.getRow(row);
|
|
6604
|
+
if (!values) return;
|
|
6605
|
+
const visitColumn = (col) => {
|
|
6606
|
+
const value = values[col];
|
|
6607
|
+
if (value) visit(row, col, value);
|
|
6608
|
+
};
|
|
6609
|
+
const width = range.endColumn - range.startColumn + 1;
|
|
6610
|
+
if (width <= 32) for (let col = range.startColumn; col <= range.endColumn; col++) visitColumn(col);
|
|
6611
|
+
else {
|
|
6612
|
+
const columns = Object.keys(values);
|
|
6613
|
+
if (width < columns.length) for (let col = range.startColumn; col <= range.endColumn; col++) visitColumn(col);
|
|
6614
|
+
else for (const column of columns) {
|
|
6615
|
+
const col = Number(column);
|
|
6616
|
+
if (col >= range.startColumn && col <= range.endColumn) visitColumn(col);
|
|
6617
|
+
}
|
|
6618
|
+
}
|
|
6619
|
+
};
|
|
6620
|
+
const height = range.endRow - range.startRow + 1;
|
|
6621
|
+
if (height <= 32) for (let row = range.startRow; row <= range.endRow; row++) visitRow(row);
|
|
6622
|
+
else {
|
|
6623
|
+
cachedRows ??= Object.keys(matrix.getMatrix()).map(Number);
|
|
6624
|
+
if (height < cachedRows.length) for (let row = range.startRow; row <= range.endRow; row++) visitRow(row);
|
|
6625
|
+
else for (const row of cachedRows) if (row >= range.startRow && row <= range.endRow) visitRow(row);
|
|
6626
|
+
}
|
|
6627
|
+
}
|
|
6545
6628
|
}
|
|
6546
|
-
var Background = class extends SheetExtension {
|
|
6629
|
+
var Background = class Background extends SheetExtension {
|
|
6547
6630
|
constructor(..._args) {
|
|
6548
6631
|
super(..._args);
|
|
6632
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === Background);
|
|
6549
6633
|
_defineProperty(this, "uKey", UNIQUE_KEY$6);
|
|
6550
6634
|
_defineProperty(this, "Z_INDEX", DOC_EXTENSION_Z_INDEX);
|
|
6551
6635
|
_defineProperty(this, "PRINTING_Z_INDEX", PRINTING_Z_INDEX);
|
|
@@ -6598,17 +6682,9 @@ var Background = class extends SheetExtension {
|
|
|
6598
6682
|
const backgroundPaths = new Path2D();
|
|
6599
6683
|
renderBGContext.backgroundPaths = backgroundPaths;
|
|
6600
6684
|
ctx.beginPath();
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
renderRanges.forEach((range) => {
|
|
6605
|
-
Range.foreach(range, rangeForEachFn);
|
|
6606
|
-
});
|
|
6607
|
-
renderBGContext.skipRenderRangeCheck = false;
|
|
6608
|
-
} else {
|
|
6609
|
-
renderBGContext.skipRenderRangeCheck = false;
|
|
6610
|
-
bgColorMatrix.forValue(rangeForEachFn);
|
|
6611
|
-
}
|
|
6685
|
+
renderBGContext.skipRenderRangeCheck = true;
|
|
6686
|
+
forEachCachedBackground(bgColorMatrix, renderRanges, rangeForEachFn);
|
|
6687
|
+
renderBGContext.skipRenderRangeCheck = false;
|
|
6612
6688
|
ctx.fill(backgroundPaths);
|
|
6613
6689
|
ctx.closePath();
|
|
6614
6690
|
};
|
|
@@ -6677,16 +6753,599 @@ var Background = class extends SheetExtension {
|
|
|
6677
6753
|
};
|
|
6678
6754
|
SpreadsheetExtensionRegistry.add(Background);
|
|
6679
6755
|
|
|
6756
|
+
// src/components/sheets/extensions/border-row-cache.ts
|
|
6757
|
+
const MAX_ENTRIES$1 = 128;
|
|
6758
|
+
const MAX_COMMANDS = 16384;
|
|
6759
|
+
const MAX_ROW_COMMANDS = 1024;
|
|
6760
|
+
const PIXEL_METHODS = /* @__PURE__ */ new Set([
|
|
6761
|
+
"stroke",
|
|
6762
|
+
"fill",
|
|
6763
|
+
"fillRect",
|
|
6764
|
+
"strokeRect",
|
|
6765
|
+
"clearRect",
|
|
6766
|
+
"fillText",
|
|
6767
|
+
"strokeText",
|
|
6768
|
+
"putImageData",
|
|
6769
|
+
"clip",
|
|
6770
|
+
"reset",
|
|
6771
|
+
"drawFocusIfNeeded"
|
|
6772
|
+
]);
|
|
6773
|
+
/** Reuse native edge blits, preserving their order and individual alpha/clip composition. */
|
|
6774
|
+
var BorderRowCache = class extends Disposable {
|
|
6775
|
+
constructor(..._args) {
|
|
6776
|
+
super(..._args);
|
|
6777
|
+
_defineProperty(this, "_rows", /* @__PURE__ */ new Map());
|
|
6778
|
+
_defineProperty(this, "_commands", 0);
|
|
6779
|
+
}
|
|
6780
|
+
draw(ctx, skeleton, row, range, resolveColor, paint) {
|
|
6781
|
+
var _skeleton$stylesCache, _native$getContextAtt;
|
|
6782
|
+
const native = ctx._context;
|
|
6783
|
+
const borderRow = (_skeleton$stylesCache = skeleton.stylesCache.border) === null || _skeleton$stylesCache === void 0 ? void 0 : _skeleton$stylesCache.getRow(row);
|
|
6784
|
+
if (ctx.__mode === "printing" || !native || typeof document === "undefined" || range.endColumn - range.startColumn < 7 || range.endColumn - range.startColumn >= 256 || !borderRow || !skeleton.worksheet.getRowVisible(row) || skeleton.overflowCache.getRow(row) || native.globalAlpha !== 1 || native.globalCompositeOperation !== "source-over" || native.shadowBlur || native.shadowOffsetX || native.shadowOffsetY || ![
|
|
6785
|
+
"rgba(0, 0, 0, 0)",
|
|
6786
|
+
"transparent",
|
|
6787
|
+
"#00000000"
|
|
6788
|
+
].includes(native.shadowColor) || native.filter && native.filter !== "none" || (((_native$getContextAtt = native.getContextAttributes) === null || _native$getContextAtt === void 0 || (_native$getContextAtt = _native$getContextAtt.call(native)) === null || _native$getContextAtt === void 0 ? void 0 : _native$getContextAtt.colorSpace) ?? "srgb") !== "srgb") return false;
|
|
6789
|
+
const m = native.getTransform();
|
|
6790
|
+
if (m.a !== m.d || m.a <= 0 || m.b || m.c) return false;
|
|
6791
|
+
const startY = row === 0 ? 0 : skeleton.rowHeightAccumulation[row - 1];
|
|
6792
|
+
const endY = skeleton.rowHeightAccumulation[row];
|
|
6793
|
+
if ((endY - startY) * m.d > 12 || endY <= startY) return false;
|
|
6794
|
+
const startX = range.startColumn === 0 ? 0 : skeleton.columnWidthAccumulation[range.startColumn - 1];
|
|
6795
|
+
const endX = skeleton.columnWidthAccumulation[range.endColumn];
|
|
6796
|
+
const left = Math.floor(Math.round(startX * m.a) + m.e);
|
|
6797
|
+
const top = Math.floor(Math.round(startY * m.d) + m.f);
|
|
6798
|
+
const width = Math.round(endX * m.a) - Math.round(startX * m.a);
|
|
6799
|
+
const height = Math.round(endY * m.d) - Math.round(startY * m.d);
|
|
6800
|
+
if (!Number.isFinite(width * height)) return false;
|
|
6801
|
+
const identity = [
|
|
6802
|
+
m.a,
|
|
6803
|
+
m.e - left,
|
|
6804
|
+
m.f + Math.round(startY * m.d) - top,
|
|
6805
|
+
width,
|
|
6806
|
+
height,
|
|
6807
|
+
native.lineCap,
|
|
6808
|
+
native.lineJoin,
|
|
6809
|
+
native.miterLimit
|
|
6810
|
+
];
|
|
6811
|
+
let edges = 0;
|
|
6812
|
+
let rowColor;
|
|
6813
|
+
for (let col = range.startColumn; col <= range.endColumn; col++) {
|
|
6814
|
+
const cell = skeleton.getCellWithCoordByIndex(row, col, false);
|
|
6815
|
+
if (cell.isMerged || cell.isMergedMainCell || !skeleton.worksheet.getColVisible(col)) return false;
|
|
6816
|
+
const border = borderRow[col];
|
|
6817
|
+
for (const key in border) {
|
|
6818
|
+
const item = border[key];
|
|
6819
|
+
if (!item || item.style !== BorderStyleTypes.THIN || ![
|
|
6820
|
+
"t",
|
|
6821
|
+
"b",
|
|
6822
|
+
"l",
|
|
6823
|
+
"r"
|
|
6824
|
+
].includes(item.type)) return false;
|
|
6825
|
+
const color = resolveColor(item.color || "rgb(0,0,0)");
|
|
6826
|
+
if (!/^#(?:[\da-f]{3}|[\da-f]{6})$/i.test(color) || rowColor !== void 0 && rowColor !== color) return false;
|
|
6827
|
+
rowColor = color;
|
|
6828
|
+
identity.push(color);
|
|
6829
|
+
edges++;
|
|
6830
|
+
}
|
|
6831
|
+
identity.push(Math.round(cell.startX * m.a) + m.e - left, Math.round(cell.endX * m.a) + m.e - left, border);
|
|
6832
|
+
}
|
|
6833
|
+
if (edges < 16 || edges > MAX_ROW_COMMANDS) return false;
|
|
6834
|
+
const key = JSON.stringify(identity);
|
|
6835
|
+
let commands = this._rows.get(key);
|
|
6836
|
+
if (commands && commands.some((item) => item.canvas.width !== item.width || item.canvas.height !== item.height)) {
|
|
6837
|
+
this._commands -= commands.length;
|
|
6838
|
+
this._rows.delete(key);
|
|
6839
|
+
return false;
|
|
6840
|
+
}
|
|
6841
|
+
if (!commands) {
|
|
6842
|
+
const captured = [];
|
|
6843
|
+
let unsupported = false;
|
|
6844
|
+
const methods = /* @__PURE__ */ new Map();
|
|
6845
|
+
const capture = new Proxy(native, {
|
|
6846
|
+
get: (target, property) => {
|
|
6847
|
+
if (property === "drawImage") return (canvas, x, y, ...rest) => {
|
|
6848
|
+
const transform = target.getTransform();
|
|
6849
|
+
if (rest.length || !(canvas === null || canvas === void 0 ? void 0 : canvas.width) || !canvas.height || typeof canvas.getContext !== "function" || !Number.isFinite(x + y) || captured.length >= MAX_ROW_COMMANDS || transform.a !== 1 || transform.d !== 1 || transform.b || transform.c || transform.e || transform.f || target.globalAlpha !== 1 || target.globalCompositeOperation !== "source-over") {
|
|
6850
|
+
unsupported = true;
|
|
6851
|
+
return;
|
|
6852
|
+
}
|
|
6853
|
+
captured.push({
|
|
6854
|
+
canvas,
|
|
6855
|
+
x: x - left,
|
|
6856
|
+
y: y - top,
|
|
6857
|
+
width: canvas.width,
|
|
6858
|
+
height: canvas.height
|
|
6859
|
+
});
|
|
6860
|
+
};
|
|
6861
|
+
if (PIXEL_METHODS.has(String(property))) return () => {
|
|
6862
|
+
unsupported = true;
|
|
6863
|
+
};
|
|
6864
|
+
const value = Reflect.get(target, property, target);
|
|
6865
|
+
if (typeof value !== "function") return value;
|
|
6866
|
+
let method = methods.get(property);
|
|
6867
|
+
if (!method) {
|
|
6868
|
+
method = value.bind(target);
|
|
6869
|
+
methods.set(property, method);
|
|
6870
|
+
}
|
|
6871
|
+
return method;
|
|
6872
|
+
},
|
|
6873
|
+
set: (target, property, value) => Reflect.set(target, property, value, target)
|
|
6874
|
+
});
|
|
6875
|
+
ctx.save();
|
|
6876
|
+
try {
|
|
6877
|
+
paint(new UniverRenderingContext(capture, { canvasColorService: { getRenderColor: resolveColor } }));
|
|
6878
|
+
} finally {
|
|
6879
|
+
ctx.restore();
|
|
6880
|
+
}
|
|
6881
|
+
if (unsupported || !captured.length || captured.some((item) => item.canvas.width !== item.width || item.canvas.height !== item.height)) return false;
|
|
6882
|
+
commands = captured;
|
|
6883
|
+
while (this._rows.size && (this._rows.size >= MAX_ENTRIES$1 || this._commands + commands.length > MAX_COMMANDS)) {
|
|
6884
|
+
const oldest = this._rows.keys().next().value;
|
|
6885
|
+
this._commands -= this._rows.get(oldest).length;
|
|
6886
|
+
this._rows.delete(oldest);
|
|
6887
|
+
}
|
|
6888
|
+
this._rows.set(key, commands);
|
|
6889
|
+
this._commands += commands.length;
|
|
6890
|
+
}
|
|
6891
|
+
ctx.save();
|
|
6892
|
+
try {
|
|
6893
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
6894
|
+
ctx.imageSmoothingEnabled = false;
|
|
6895
|
+
for (const command of commands) ctx.drawImage(command.canvas, command.x + left, command.y + top);
|
|
6896
|
+
} finally {
|
|
6897
|
+
ctx.restore();
|
|
6898
|
+
}
|
|
6899
|
+
return true;
|
|
6900
|
+
}
|
|
6901
|
+
clear() {
|
|
6902
|
+
this._rows.clear();
|
|
6903
|
+
this._commands = 0;
|
|
6904
|
+
}
|
|
6905
|
+
dispose() {
|
|
6906
|
+
this.clear();
|
|
6907
|
+
super.dispose();
|
|
6908
|
+
}
|
|
6909
|
+
};
|
|
6910
|
+
|
|
6911
|
+
// src/components/sheets/extensions/render-primitive-cache.ts
|
|
6912
|
+
/**
|
|
6913
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
6914
|
+
*
|
|
6915
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6916
|
+
* you may not use this file except in compliance with the License.
|
|
6917
|
+
* You may obtain a copy of the License at
|
|
6918
|
+
*
|
|
6919
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6920
|
+
*
|
|
6921
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6922
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6923
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6924
|
+
* See the License for the specific language governing permissions and
|
|
6925
|
+
* limitations under the License.
|
|
6926
|
+
*/
|
|
6927
|
+
const MAX_ENTRIES = 128;
|
|
6928
|
+
const MAX_PIXELS = 524288;
|
|
6929
|
+
const MAX_STROKE_PIXELS = 131072;
|
|
6930
|
+
const TEXT_PROPERTIES = [
|
|
6931
|
+
"lang",
|
|
6932
|
+
"font",
|
|
6933
|
+
"textAlign",
|
|
6934
|
+
"textBaseline",
|
|
6935
|
+
"direction",
|
|
6936
|
+
"fontKerning",
|
|
6937
|
+
"fontStretch",
|
|
6938
|
+
"fontVariantCaps",
|
|
6939
|
+
"letterSpacing",
|
|
6940
|
+
"wordSpacing",
|
|
6941
|
+
"textRendering"
|
|
6942
|
+
];
|
|
6943
|
+
/** Rasterize at a stable local origin, retaining the native physical resolution and antialiasing. */
|
|
6944
|
+
var RenderPrimitiveCache = class extends Disposable {
|
|
6945
|
+
constructor(_maxEntries = MAX_ENTRIES) {
|
|
6946
|
+
super();
|
|
6947
|
+
this._maxEntries = _maxEntries;
|
|
6948
|
+
_defineProperty(this, "_bitmaps", /* @__PURE__ */ new Map());
|
|
6949
|
+
_defineProperty(this, "_contexts", /* @__PURE__ */ new WeakMap());
|
|
6950
|
+
_defineProperty(this, "_pixels", 0);
|
|
6951
|
+
_defineProperty(this, "_fontRevision", -1);
|
|
6952
|
+
_defineProperty(this, "_fonts", void 0);
|
|
6953
|
+
_defineProperty(this, "_textClipBound", void 0);
|
|
6954
|
+
_defineProperty(this, "_textClipRepairCanvas", void 0);
|
|
6955
|
+
}
|
|
6956
|
+
draw(ctx, draw, textClipBound) {
|
|
6957
|
+
var _original$getContextA;
|
|
6958
|
+
const original = ctx._context;
|
|
6959
|
+
const colorSpace = original === null || original === void 0 || (_original$getContextA = original.getContextAttributes) === null || _original$getContextA === void 0 || (_original$getContextA = _original$getContextA.call(original)) === null || _original$getContextA === void 0 ? void 0 : _original$getContextA.colorSpace;
|
|
6960
|
+
if (ctx.__mode === "printing" || !original || typeof document === "undefined" || colorSpace && colorSpace !== "srgb") {
|
|
6961
|
+
draw();
|
|
6962
|
+
return;
|
|
6963
|
+
}
|
|
6964
|
+
const previousTextClipBound = this._textClipBound;
|
|
6965
|
+
this._textClipBound = textClipBound;
|
|
6966
|
+
ctx._context = this._getContext(original);
|
|
6967
|
+
try {
|
|
6968
|
+
draw();
|
|
6969
|
+
} finally {
|
|
6970
|
+
ctx._context = original;
|
|
6971
|
+
this._textClipBound = previousTextClipBound;
|
|
6972
|
+
}
|
|
6973
|
+
}
|
|
6974
|
+
clear() {
|
|
6975
|
+
for (const bitmap of this._bitmaps.values()) {
|
|
6976
|
+
bitmap.canvas.width = 0;
|
|
6977
|
+
bitmap.canvas.height = 0;
|
|
6978
|
+
}
|
|
6979
|
+
this._bitmaps.clear();
|
|
6980
|
+
this._contexts = /* @__PURE__ */ new WeakMap();
|
|
6981
|
+
this._pixels = 0;
|
|
6982
|
+
if (this._textClipRepairCanvas) {
|
|
6983
|
+
this._textClipRepairCanvas.width = 0;
|
|
6984
|
+
this._textClipRepairCanvas.height = 0;
|
|
6985
|
+
this._textClipRepairCanvas = void 0;
|
|
6986
|
+
}
|
|
6987
|
+
}
|
|
6988
|
+
dispose() {
|
|
6989
|
+
this.clear();
|
|
6990
|
+
super.dispose();
|
|
6991
|
+
}
|
|
6992
|
+
_getContext(native) {
|
|
6993
|
+
const existing = this._contexts.get(native);
|
|
6994
|
+
if (existing) return existing;
|
|
6995
|
+
const path = {
|
|
6996
|
+
points: [],
|
|
6997
|
+
closed: false,
|
|
6998
|
+
unsupported: false
|
|
6999
|
+
};
|
|
7000
|
+
const methods = /* @__PURE__ */ new Map();
|
|
7001
|
+
const proxy = new Proxy(native, {
|
|
7002
|
+
get: (target, key) => {
|
|
7003
|
+
const value = Reflect.get(target, key, target);
|
|
7004
|
+
if (typeof value !== "function") return value;
|
|
7005
|
+
const cached = methods.get(key);
|
|
7006
|
+
if (cached) return cached;
|
|
7007
|
+
let method = value.bind(target);
|
|
7008
|
+
if (key === "beginPath") method = () => {
|
|
7009
|
+
path.points.length = 0;
|
|
7010
|
+
path.closed = false;
|
|
7011
|
+
path.unsupported = false;
|
|
7012
|
+
target.beginPath();
|
|
7013
|
+
};
|
|
7014
|
+
else if (key === "moveTo" || key === "lineTo") method = (...args) => {
|
|
7015
|
+
if (key === "moveTo" && path.points.length) path.unsupported = true;
|
|
7016
|
+
path.points.push([args[0], args[1]]);
|
|
7017
|
+
Reflect.apply(value, target, args);
|
|
7018
|
+
};
|
|
7019
|
+
else if (key === "closePath") method = () => {
|
|
7020
|
+
if (path.points.length < 2) path.unsupported = true;
|
|
7021
|
+
path.closed = true;
|
|
7022
|
+
target.closePath();
|
|
7023
|
+
};
|
|
7024
|
+
else if (key === "stroke") method = (...args) => this._stroke(target, path, args);
|
|
7025
|
+
else if (key === "fillText") method = (...args) => this._fillText(target, args);
|
|
7026
|
+
else if ([
|
|
7027
|
+
"translate",
|
|
7028
|
+
"scale",
|
|
7029
|
+
"rotate",
|
|
7030
|
+
"transform",
|
|
7031
|
+
"setTransform",
|
|
7032
|
+
"resetTransform",
|
|
7033
|
+
"restore"
|
|
7034
|
+
].includes(String(key))) method = (...args) => {
|
|
7035
|
+
if (path.points.length) path.unsupported = true;
|
|
7036
|
+
Reflect.apply(value, target, args);
|
|
7037
|
+
};
|
|
7038
|
+
else if ([
|
|
7039
|
+
"arc",
|
|
7040
|
+
"arcTo",
|
|
7041
|
+
"ellipse",
|
|
7042
|
+
"rect",
|
|
7043
|
+
"roundRect",
|
|
7044
|
+
"bezierCurveTo",
|
|
7045
|
+
"quadraticCurveTo"
|
|
7046
|
+
].includes(String(key))) method = (...args) => {
|
|
7047
|
+
path.unsupported = true;
|
|
7048
|
+
Reflect.apply(value, target, args);
|
|
7049
|
+
};
|
|
7050
|
+
methods.set(key, method);
|
|
7051
|
+
return method;
|
|
7052
|
+
},
|
|
7053
|
+
set: (target, key, value) => Reflect.set(target, key, value, target)
|
|
7054
|
+
});
|
|
7055
|
+
this._contexts.set(native, proxy);
|
|
7056
|
+
return proxy;
|
|
7057
|
+
}
|
|
7058
|
+
_stroke(native, path, args) {
|
|
7059
|
+
const m = native.getTransform();
|
|
7060
|
+
if (this._textClipBound || args.length || path.unsupported || path.points.length !== 2 || m.a !== m.d || m.a <= 0 || m.b || m.c || native.shadowBlur || native.shadowOffsetX || native.shadowOffsetY || ![
|
|
7061
|
+
"rgba(0, 0, 0, 0)",
|
|
7062
|
+
"transparent",
|
|
7063
|
+
"#00000000"
|
|
7064
|
+
].includes(native.shadowColor) || native.filter && native.filter !== "none" || typeof native.strokeStyle !== "string" || !["source-over", "destination-out"].includes(native.globalCompositeOperation)) {
|
|
7065
|
+
Reflect.apply(native.stroke, native, args);
|
|
7066
|
+
return;
|
|
7067
|
+
}
|
|
7068
|
+
const x0 = path.points[0][0] * m.a + m.e;
|
|
7069
|
+
const y0 = path.points[0][1] * m.d + m.f;
|
|
7070
|
+
const x1 = path.points[1][0] * m.a + m.e;
|
|
7071
|
+
const y1 = path.points[1][1] * m.d + m.f;
|
|
7072
|
+
const padding = Math.ceil(native.lineWidth * m.a / 2) + 2;
|
|
7073
|
+
const left = Math.floor(Math.min(x0, x1)) - padding;
|
|
7074
|
+
const top = Math.floor(Math.min(y0, y1)) - padding;
|
|
7075
|
+
const width = Math.ceil(Math.max(x0, x1)) - left + padding;
|
|
7076
|
+
const height = Math.ceil(Math.max(y0, y1)) - top + padding;
|
|
7077
|
+
if (!Number.isFinite(width * height) || width * height > MAX_STROKE_PIXELS) {
|
|
7078
|
+
native.stroke();
|
|
7079
|
+
return;
|
|
7080
|
+
}
|
|
7081
|
+
const localX0 = x0 - left;
|
|
7082
|
+
const localY0 = y0 - top;
|
|
7083
|
+
const localX1 = x1 - left;
|
|
7084
|
+
const localY1 = y1 - top;
|
|
7085
|
+
const dash = native.getLineDash();
|
|
7086
|
+
const key = JSON.stringify([
|
|
7087
|
+
Math.round(localX0 * 1e6) / 1e6,
|
|
7088
|
+
Math.round(localY0 * 1e6) / 1e6,
|
|
7089
|
+
Math.round(localX1 * 1e6) / 1e6,
|
|
7090
|
+
Math.round(localY1 * 1e6) / 1e6,
|
|
7091
|
+
width,
|
|
7092
|
+
height,
|
|
7093
|
+
native.lineWidth * m.a,
|
|
7094
|
+
native.strokeStyle,
|
|
7095
|
+
native.lineCap,
|
|
7096
|
+
native.lineJoin,
|
|
7097
|
+
native.miterLimit,
|
|
7098
|
+
dash.map((value) => value * m.a),
|
|
7099
|
+
native.lineDashOffset * m.a,
|
|
7100
|
+
path.closed
|
|
7101
|
+
]);
|
|
7102
|
+
let bitmap = this._bitmaps.get(key);
|
|
7103
|
+
if (!bitmap) {
|
|
7104
|
+
const canvas = createCanvasElement();
|
|
7105
|
+
canvas.width = width;
|
|
7106
|
+
canvas.height = height;
|
|
7107
|
+
const paint = canvas.getContext("2d");
|
|
7108
|
+
if (!paint) {
|
|
7109
|
+
native.stroke();
|
|
7110
|
+
return;
|
|
7111
|
+
}
|
|
7112
|
+
paint.setTransform(m.a, 0, 0, m.d, 0, 0);
|
|
7113
|
+
paint.lineWidth = native.lineWidth;
|
|
7114
|
+
paint.strokeStyle = native.strokeStyle;
|
|
7115
|
+
paint.lineCap = native.lineCap;
|
|
7116
|
+
paint.lineJoin = native.lineJoin;
|
|
7117
|
+
paint.miterLimit = native.miterLimit;
|
|
7118
|
+
paint.setLineDash(dash);
|
|
7119
|
+
paint.lineDashOffset = native.lineDashOffset;
|
|
7120
|
+
paint.beginPath();
|
|
7121
|
+
paint.moveTo(localX0 / m.a, localY0 / m.d);
|
|
7122
|
+
paint.lineTo(localX1 / m.a, localY1 / m.d);
|
|
7123
|
+
if (path.closed) paint.closePath();
|
|
7124
|
+
const halfWidth = native.lineWidth * m.a / 2;
|
|
7125
|
+
const horizontal = localY0 === localY1 && localX0 !== localX1;
|
|
7126
|
+
const vertical = localX0 === localX1 && localY0 !== localY1;
|
|
7127
|
+
const center = horizontal ? localY0 : localX0;
|
|
7128
|
+
const low = center - halfWidth;
|
|
7129
|
+
const high = center + halfWidth;
|
|
7130
|
+
const lowPixel = Math.round(low);
|
|
7131
|
+
const highPixel = Math.round(high);
|
|
7132
|
+
if ((horizontal || vertical) && !dash.length && native.lineCap === "butt" && (!path.closed || native.lineJoin === "miter") && Math.abs(low - lowPixel) <= 1e-6 && Math.abs(high - highPixel) <= 1e-6 && highPixel > lowPixel) {
|
|
7133
|
+
paint.setTransform(1, 0, 0, 1, 0, 0);
|
|
7134
|
+
paint.fillStyle = native.strokeStyle;
|
|
7135
|
+
paint.fillRect(horizontal ? Math.min(localX0, localX1) : lowPixel, vertical ? Math.min(localY0, localY1) : lowPixel, horizontal ? Math.abs(localX1 - localX0) : highPixel - lowPixel, vertical ? Math.abs(localY1 - localY0) : highPixel - lowPixel);
|
|
7136
|
+
} else paint.stroke();
|
|
7137
|
+
bitmap = {
|
|
7138
|
+
canvas,
|
|
7139
|
+
pixels: width * height
|
|
7140
|
+
};
|
|
7141
|
+
this._trim(bitmap.pixels);
|
|
7142
|
+
this._bitmaps.set(key, bitmap);
|
|
7143
|
+
this._pixels += bitmap.pixels;
|
|
7144
|
+
}
|
|
7145
|
+
const smoothing = native.imageSmoothingEnabled;
|
|
7146
|
+
native.setTransform(1, 0, 0, 1, 0, 0);
|
|
7147
|
+
native.imageSmoothingEnabled = false;
|
|
7148
|
+
try {
|
|
7149
|
+
native.drawImage(bitmap.canvas, left, top);
|
|
7150
|
+
} finally {
|
|
7151
|
+
native.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
7152
|
+
native.imageSmoothingEnabled = smoothing;
|
|
7153
|
+
}
|
|
7154
|
+
}
|
|
7155
|
+
_fillText(native, args) {
|
|
7156
|
+
var _native$canvas$closes;
|
|
7157
|
+
const m = native.getTransform();
|
|
7158
|
+
const fallback = () => Reflect.apply(native.fillText, native, args);
|
|
7159
|
+
if (args.length !== 3 || typeof args[0] !== "string" || m.a !== m.d || m.a <= 0 || m.b || m.c || native.shadowBlur || native.shadowOffsetX || native.shadowOffsetY || ![
|
|
7160
|
+
"rgba(0, 0, 0, 0)",
|
|
7161
|
+
"transparent",
|
|
7162
|
+
"#00000000"
|
|
7163
|
+
].includes(native.shadowColor) || native.filter && native.filter !== "none" || typeof native.fillStyle !== "string" || native.globalCompositeOperation !== "source-over" || !document.fonts || native.canvas.ownerDocument !== document || ![
|
|
7164
|
+
"ltr",
|
|
7165
|
+
"rtl",
|
|
7166
|
+
"inherit"
|
|
7167
|
+
].includes(native.direction) || document.fonts.status === "loading") {
|
|
7168
|
+
fallback();
|
|
7169
|
+
return;
|
|
7170
|
+
}
|
|
7171
|
+
if (!this._fonts) {
|
|
7172
|
+
const fonts = document.fonts;
|
|
7173
|
+
this._fonts = fonts;
|
|
7174
|
+
const clear = () => this.clear();
|
|
7175
|
+
fonts.addEventListener("loadingdone", clear);
|
|
7176
|
+
fonts.addEventListener("loadingerror", clear);
|
|
7177
|
+
this.disposeWithMe({ dispose: () => {
|
|
7178
|
+
fonts.removeEventListener("loadingdone", clear);
|
|
7179
|
+
fonts.removeEventListener("loadingerror", clear);
|
|
7180
|
+
} });
|
|
7181
|
+
}
|
|
7182
|
+
if (this._fontRevision !== FontCache.metricsRevision) {
|
|
7183
|
+
this.clear();
|
|
7184
|
+
this._fontRevision = FontCache.metricsRevision;
|
|
7185
|
+
}
|
|
7186
|
+
const text = args[0];
|
|
7187
|
+
const px = args[1] * m.a + m.e;
|
|
7188
|
+
const py = args[2] * m.d + m.f;
|
|
7189
|
+
const ix = Math.floor(px);
|
|
7190
|
+
const iy = Math.floor(py);
|
|
7191
|
+
let metrics;
|
|
7192
|
+
if (this._textClipBound) {
|
|
7193
|
+
metrics = native.measureText(text);
|
|
7194
|
+
const left = px - metrics.actualBoundingBoxLeft * m.a;
|
|
7195
|
+
const right = px + metrics.actualBoundingBoxRight * m.a;
|
|
7196
|
+
const top = py - metrics.actualBoundingBoxAscent * m.d;
|
|
7197
|
+
const bottom = py + metrics.actualBoundingBoxDescent * m.d;
|
|
7198
|
+
const clip = this._textClipBound;
|
|
7199
|
+
if (right > clip.left && left < clip.right && bottom > clip.top && top < clip.bottom || right < clip.left - 2 || left > clip.right + 2 || bottom < clip.top - 2 || top > clip.bottom + 2) {
|
|
7200
|
+
fallback();
|
|
7201
|
+
return;
|
|
7202
|
+
}
|
|
7203
|
+
}
|
|
7204
|
+
const values = TEXT_PROPERTIES.map((property) => Reflect.get(native, property));
|
|
7205
|
+
const language = ((_native$canvas$closes = native.canvas.closest("[lang]")) === null || _native$canvas$closes === void 0 ? void 0 : _native$canvas$closes.getAttribute("lang")) ?? document.documentElement.lang;
|
|
7206
|
+
if (native.direction === "inherit" && !["ltr", "rtl"].includes(native.canvas.dir)) {
|
|
7207
|
+
fallback();
|
|
7208
|
+
return;
|
|
7209
|
+
}
|
|
7210
|
+
const direction = native.direction === "inherit" ? native.canvas.dir : native.direction;
|
|
7211
|
+
if (this._textClipBound) {
|
|
7212
|
+
metrics ??= native.measureText(text);
|
|
7213
|
+
const left = Math.max(0, Math.floor(px - metrics.actualBoundingBoxLeft * m.a) - 2);
|
|
7214
|
+
const top = Math.max(0, Math.floor(py - metrics.actualBoundingBoxAscent * m.d) - 2);
|
|
7215
|
+
const width = Math.min(native.canvas.width, Math.ceil(px + metrics.actualBoundingBoxRight * m.a) + 2) - left;
|
|
7216
|
+
const height = Math.min(native.canvas.height, Math.ceil(py + metrics.actualBoundingBoxDescent * m.d) + 2) - top;
|
|
7217
|
+
if (!Number.isFinite(width * height) || width <= 0 || height <= 0 || width * height > MAX_STROKE_PIXELS) {
|
|
7218
|
+
fallback();
|
|
7219
|
+
return;
|
|
7220
|
+
}
|
|
7221
|
+
const canvas = this._textClipRepairCanvas ??= createCanvasElement();
|
|
7222
|
+
if (canvas.width !== native.canvas.width || canvas.height !== native.canvas.height) {
|
|
7223
|
+
canvas.width = native.canvas.width;
|
|
7224
|
+
canvas.height = native.canvas.height;
|
|
7225
|
+
}
|
|
7226
|
+
canvas.dir = direction;
|
|
7227
|
+
canvas.lang = language;
|
|
7228
|
+
const paint = canvas.getContext("2d");
|
|
7229
|
+
if (!paint) {
|
|
7230
|
+
canvas.width = 0;
|
|
7231
|
+
canvas.height = 0;
|
|
7232
|
+
this._textClipRepairCanvas = void 0;
|
|
7233
|
+
fallback();
|
|
7234
|
+
return;
|
|
7235
|
+
}
|
|
7236
|
+
paint.setTransform(1, 0, 0, 1, 0, 0);
|
|
7237
|
+
paint.clearRect(left, top, width, height);
|
|
7238
|
+
TEXT_PROPERTIES.forEach((property, index) => {
|
|
7239
|
+
if (values[index] !== void 0) Reflect.set(paint, property, values[index]);
|
|
7240
|
+
});
|
|
7241
|
+
paint.direction = direction;
|
|
7242
|
+
paint.fillStyle = native.fillStyle;
|
|
7243
|
+
paint.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
7244
|
+
paint.fillText(text, args[1], args[2]);
|
|
7245
|
+
native.save();
|
|
7246
|
+
try {
|
|
7247
|
+
native.setTransform(1, 0, 0, 1, 0, 0);
|
|
7248
|
+
native.imageSmoothingEnabled = false;
|
|
7249
|
+
native.drawImage(canvas, left, top, width, height, left, top, width, height);
|
|
7250
|
+
} finally {
|
|
7251
|
+
native.restore();
|
|
7252
|
+
}
|
|
7253
|
+
return;
|
|
7254
|
+
}
|
|
7255
|
+
const key = JSON.stringify([
|
|
7256
|
+
"text",
|
|
7257
|
+
text,
|
|
7258
|
+
native.fillStyle,
|
|
7259
|
+
m.a,
|
|
7260
|
+
values,
|
|
7261
|
+
direction,
|
|
7262
|
+
language,
|
|
7263
|
+
Math.round((px - ix) * 1e6) / 1e6,
|
|
7264
|
+
Math.round((py - iy) * 1e6) / 1e6
|
|
7265
|
+
]);
|
|
7266
|
+
let bitmap = this._bitmaps.get(key);
|
|
7267
|
+
if (!bitmap) {
|
|
7268
|
+
metrics ??= native.measureText(text);
|
|
7269
|
+
const left = Math.floor(px - metrics.actualBoundingBoxLeft * m.a) - 2;
|
|
7270
|
+
const top = Math.floor(py - metrics.actualBoundingBoxAscent * m.d) - 2;
|
|
7271
|
+
const width = Math.ceil(px + metrics.actualBoundingBoxRight * m.a) - left + 2;
|
|
7272
|
+
const height = Math.ceil(py + metrics.actualBoundingBoxDescent * m.d) - top + 2;
|
|
7273
|
+
if (!Number.isFinite(width * height) || width <= 0 || height <= 0 || width * height > MAX_STROKE_PIXELS) {
|
|
7274
|
+
fallback();
|
|
7275
|
+
return;
|
|
7276
|
+
}
|
|
7277
|
+
const canvas = createCanvasElement();
|
|
7278
|
+
canvas.width = width;
|
|
7279
|
+
canvas.height = height;
|
|
7280
|
+
canvas.dir = direction;
|
|
7281
|
+
canvas.lang = language;
|
|
7282
|
+
const paint = canvas.getContext("2d");
|
|
7283
|
+
if (!paint) {
|
|
7284
|
+
fallback();
|
|
7285
|
+
return;
|
|
7286
|
+
}
|
|
7287
|
+
TEXT_PROPERTIES.forEach((property, index) => {
|
|
7288
|
+
if (values[index] !== void 0) Reflect.set(paint, property, values[index]);
|
|
7289
|
+
});
|
|
7290
|
+
paint.direction = direction;
|
|
7291
|
+
paint.fillStyle = native.fillStyle;
|
|
7292
|
+
paint.setTransform(m.a, 0, 0, m.d, px - left, py - top);
|
|
7293
|
+
paint.fillText(text, 0, 0);
|
|
7294
|
+
bitmap = {
|
|
7295
|
+
canvas,
|
|
7296
|
+
pixels: width * height,
|
|
7297
|
+
offsetX: left - ix,
|
|
7298
|
+
offsetY: top - iy
|
|
7299
|
+
};
|
|
7300
|
+
this._trim(bitmap.pixels);
|
|
7301
|
+
this._bitmaps.set(key, bitmap);
|
|
7302
|
+
this._pixels += bitmap.pixels;
|
|
7303
|
+
}
|
|
7304
|
+
native.save();
|
|
7305
|
+
try {
|
|
7306
|
+
native.setTransform(1, 0, 0, 1, 0, 0);
|
|
7307
|
+
native.imageSmoothingEnabled = false;
|
|
7308
|
+
native.drawImage(bitmap.canvas, ix + bitmap.offsetX, iy + bitmap.offsetY);
|
|
7309
|
+
} finally {
|
|
7310
|
+
native.restore();
|
|
7311
|
+
}
|
|
7312
|
+
}
|
|
7313
|
+
_trim(incoming) {
|
|
7314
|
+
while (this._bitmaps.size >= this._maxEntries || this._pixels + incoming > MAX_PIXELS) {
|
|
7315
|
+
const key = this._bitmaps.keys().next().value;
|
|
7316
|
+
if (key === void 0) break;
|
|
7317
|
+
const bitmap = this._bitmaps.get(key);
|
|
7318
|
+
this._pixels -= bitmap.pixels;
|
|
7319
|
+
bitmap.canvas.width = 0;
|
|
7320
|
+
bitmap.canvas.height = 0;
|
|
7321
|
+
this._bitmaps.delete(key);
|
|
7322
|
+
}
|
|
7323
|
+
}
|
|
7324
|
+
};
|
|
7325
|
+
|
|
6680
7326
|
// src/components/sheets/extensions/border.ts
|
|
6681
7327
|
const UNIQUE_KEY$5 = "DefaultBorderExtension";
|
|
6682
7328
|
const BORDER_Z_INDEX$1 = 50;
|
|
6683
|
-
|
|
7329
|
+
const BORDER_PRIMITIVE_CACHE_ENTRIES = 512;
|
|
7330
|
+
var Border = class Border extends SheetExtension {
|
|
6684
7331
|
constructor(..._args) {
|
|
6685
7332
|
super(..._args);
|
|
7333
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === Border);
|
|
6686
7334
|
_defineProperty(this, "uKey", UNIQUE_KEY$5);
|
|
6687
7335
|
_defineProperty(this, "Z_INDEX", BORDER_Z_INDEX$1);
|
|
6688
7336
|
_defineProperty(this, "preStyle", void 0);
|
|
6689
7337
|
_defineProperty(this, "preColor", void 0);
|
|
7338
|
+
_defineProperty(this, "_strokeCache", new RenderPrimitiveCache(BORDER_PRIMITIVE_CACHE_ENTRIES));
|
|
7339
|
+
_defineProperty(this, "_rowCache", new BorderRowCache());
|
|
7340
|
+
}
|
|
7341
|
+
clearCache() {
|
|
7342
|
+
this._strokeCache.clear();
|
|
7343
|
+
this._rowCache.clear();
|
|
7344
|
+
}
|
|
7345
|
+
dispose() {
|
|
7346
|
+
this._strokeCache.dispose();
|
|
7347
|
+
this._rowCache.dispose();
|
|
7348
|
+
super.dispose();
|
|
6690
7349
|
}
|
|
6691
7350
|
draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges, { viewRanges }) {
|
|
6692
7351
|
const { stylesCache, overflowCache, worksheet, rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;
|
|
@@ -6704,14 +7363,44 @@ var Border = class extends SheetExtension {
|
|
|
6704
7363
|
viewRanges,
|
|
6705
7364
|
spreadsheetSkeleton
|
|
6706
7365
|
};
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
7366
|
+
const colors = /* @__PURE__ */ new Map();
|
|
7367
|
+
const resolveColor = (color) => {
|
|
7368
|
+
let resolved = colors.get(color);
|
|
7369
|
+
if (resolved === void 0) {
|
|
7370
|
+
ctx.save();
|
|
7371
|
+
ctx.strokeStyle = color;
|
|
7372
|
+
resolved = ctx.strokeStyle;
|
|
7373
|
+
ctx.restore();
|
|
7374
|
+
colors.set(color, resolved);
|
|
7375
|
+
}
|
|
7376
|
+
return resolved;
|
|
7377
|
+
};
|
|
7378
|
+
const paint = () => {
|
|
7379
|
+
this._strokeCache.draw(ctx, () => {
|
|
7380
|
+
ctx.beginPath();
|
|
7381
|
+
viewRanges.forEach((range) => {
|
|
7382
|
+
for (let row = range.startRow; row <= range.endRow; row++) {
|
|
7383
|
+
const paintRow = (target) => {
|
|
7384
|
+
const context = target === ctx ? renderBorderContext : {
|
|
7385
|
+
...renderBorderContext,
|
|
7386
|
+
ctx: target,
|
|
7387
|
+
lineStyle: void 0,
|
|
7388
|
+
lineWidth: void 0,
|
|
7389
|
+
lineColor: void 0
|
|
7390
|
+
};
|
|
7391
|
+
for (let col = range.startColumn; col <= range.endColumn; col++) {
|
|
7392
|
+
const borderConfig = border.getValue(row, col);
|
|
7393
|
+
if (borderConfig) this.renderBorderByCell(context, row, col, borderConfig);
|
|
7394
|
+
}
|
|
7395
|
+
};
|
|
7396
|
+
if (!this.isRenderDiffRangesByRow(row, row, diffRanges) || !this._rowCache.draw(ctx, spreadsheetSkeleton, row, range, resolveColor, (target) => this._strokeCache.draw(target, () => paintRow(target)))) paintRow(ctx);
|
|
7397
|
+
}
|
|
7398
|
+
});
|
|
7399
|
+
ctx.closePath();
|
|
6712
7400
|
});
|
|
6713
|
-
}
|
|
6714
|
-
ctx.
|
|
7401
|
+
};
|
|
7402
|
+
if (this.constructor === Border) ctx.withCachedScale(paint);
|
|
7403
|
+
else paint();
|
|
6715
7404
|
ctx.restore();
|
|
6716
7405
|
}
|
|
6717
7406
|
renderBorderByCell(renderBorderContext, row, col, borderCacheItem) {
|
|
@@ -6731,7 +7420,8 @@ var Border = class extends SheetExtension {
|
|
|
6731
7420
|
let endY = cellEndY;
|
|
6732
7421
|
let startX = cellStartX;
|
|
6733
7422
|
let endX = cellEndX;
|
|
6734
|
-
|
|
7423
|
+
const isDiagonal = type !== "t" && type !== "b" && type !== "l" && type !== "r";
|
|
7424
|
+
if (isDiagonal) {
|
|
6735
7425
|
if (isMerged) continue;
|
|
6736
7426
|
if (isMergedMainCell) {
|
|
6737
7427
|
startY = mergeInfo.startY;
|
|
@@ -6740,16 +7430,28 @@ var Border = class extends SheetExtension {
|
|
|
6740
7430
|
endX = mergeInfo.endX;
|
|
6741
7431
|
}
|
|
6742
7432
|
}
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
7433
|
+
let lineWidth = renderBorderContext.lineWidth;
|
|
7434
|
+
if (renderBorderContext.lineStyle !== style || lineWidth === void 0) {
|
|
7435
|
+
lineWidth = getLineWidth(style);
|
|
7436
|
+
setLineType(ctx, style);
|
|
7437
|
+
ctx.setLineWidthByPrecision(lineWidth);
|
|
7438
|
+
renderBorderContext.lineStyle = style;
|
|
7439
|
+
renderBorderContext.lineWidth = lineWidth;
|
|
7440
|
+
}
|
|
7441
|
+
const lineColor = color || "rgb(0,0,0)";
|
|
7442
|
+
if (renderBorderContext.lineColor !== lineColor) {
|
|
7443
|
+
ctx.strokeStyle = lineColor;
|
|
7444
|
+
renderBorderContext.lineColor = lineColor;
|
|
7445
|
+
}
|
|
7446
|
+
if (isDiagonal) {
|
|
7447
|
+
drawDiagonalLineByBorderType(ctx, style, type, {
|
|
7448
|
+
startX,
|
|
7449
|
+
startY,
|
|
7450
|
+
endX,
|
|
7451
|
+
endY
|
|
7452
|
+
});
|
|
7453
|
+
continue;
|
|
7454
|
+
}
|
|
6753
7455
|
if (this._getOverflowExclusion(overflowCache, type, row, col)) continue;
|
|
6754
7456
|
const lineWidthBuffer = (lineWidth - 1) / 2 / precisionScale;
|
|
6755
7457
|
drawLineByBorderType(ctx, type, lineWidthBuffer, {
|
|
@@ -6772,23 +7474,14 @@ var Border = class extends SheetExtension {
|
|
|
6772
7474
|
}
|
|
6773
7475
|
}
|
|
6774
7476
|
_getOverflowExclusion(overflowCache, type, borderRow, borderColumn) {
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
return false;
|
|
6784
|
-
}
|
|
6785
|
-
if (type === "r" && borderColumn >= startColumn && borderColumn < endColumn) {
|
|
6786
|
-
isDraw = true;
|
|
6787
|
-
return false;
|
|
6788
|
-
}
|
|
6789
|
-
});
|
|
6790
|
-
});
|
|
6791
|
-
return isDraw;
|
|
7477
|
+
if (type === "t" || type === "b") return false;
|
|
7478
|
+
const row = overflowCache === null || overflowCache === void 0 ? void 0 : overflowCache.getRow(borderRow);
|
|
7479
|
+
if (!row) return false;
|
|
7480
|
+
for (const column in row) {
|
|
7481
|
+
const { startColumn, endColumn } = row[column];
|
|
7482
|
+
if (type === "l" && borderColumn > startColumn && borderColumn <= endColumn || type === "r" && borderColumn >= startColumn && borderColumn < endColumn) return true;
|
|
7483
|
+
}
|
|
7484
|
+
return false;
|
|
6792
7485
|
}
|
|
6793
7486
|
_renderDoubleBorder({ renderBorderContext, row, col, type, lineWidth, startX, startY, endX, endY }) {
|
|
6794
7487
|
const { ctx, precisionScale, spreadsheetSkeleton } = renderBorderContext;
|
|
@@ -6955,9 +7648,10 @@ const DEFAULT_PRINTING_COLUMN_STYLE = {
|
|
|
6955
7648
|
/**
|
|
6956
7649
|
* Column Header Bar, include a lot of columns header
|
|
6957
7650
|
*/
|
|
6958
|
-
var ColumnHeaderLayout = class extends SheetExtension {
|
|
7651
|
+
var ColumnHeaderLayout = class ColumnHeaderLayout extends SheetExtension {
|
|
6959
7652
|
constructor(cfg) {
|
|
6960
7653
|
super();
|
|
7654
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === ColumnHeaderLayout);
|
|
6961
7655
|
_defineProperty(this, "uKey", UNIQUE_KEY$4);
|
|
6962
7656
|
_defineProperty(this, "Z_INDEX", 10);
|
|
6963
7657
|
_defineProperty(this, "columnsCfg", {});
|
|
@@ -7127,9 +7821,10 @@ const stringifyRange$1 = (range) => {
|
|
|
7127
7821
|
const { startRow, endRow, startColumn, endColumn } = range;
|
|
7128
7822
|
return `${startRow}-${endRow}-${startColumn}-${endColumn}`;
|
|
7129
7823
|
};
|
|
7130
|
-
var Custom = class extends SheetExtension {
|
|
7824
|
+
var Custom = class Custom extends SheetExtension {
|
|
7131
7825
|
constructor(..._args) {
|
|
7132
7826
|
super(..._args);
|
|
7827
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === Custom);
|
|
7133
7828
|
_defineProperty(this, "Z_INDEX", Z_INDEX$1);
|
|
7134
7829
|
_defineProperty(this, "uKey", UNIQUE_KEY$3);
|
|
7135
7830
|
}
|
|
@@ -7163,6 +7858,7 @@ var Custom = class extends SheetExtension {
|
|
|
7163
7858
|
worksheet,
|
|
7164
7859
|
unitId: worksheet.unitId
|
|
7165
7860
|
};
|
|
7861
|
+
if (cellData.customRender.length > 0) this.viewportCacheReusable = false;
|
|
7166
7862
|
const customRender = cellData.customRender.sort(sortRules);
|
|
7167
7863
|
ctx.save();
|
|
7168
7864
|
customRender.forEach((item) => {
|
|
@@ -7177,6 +7873,12 @@ SpreadsheetExtensionRegistry.add(Custom);
|
|
|
7177
7873
|
|
|
7178
7874
|
// src/components/sheets/sheet-cell-document-view-model.ts
|
|
7179
7875
|
var SheetCellDocumentViewModel = class SheetCellDocumentViewModel extends DocumentViewModel {
|
|
7876
|
+
getLayoutRenderConfig(config) {
|
|
7877
|
+
return config.centerAngle === 90 && config.vertexAngle === 90 ? {
|
|
7878
|
+
...config,
|
|
7879
|
+
stackedText: true
|
|
7880
|
+
} : config;
|
|
7881
|
+
}
|
|
7180
7882
|
getParagraphWordWrap() {}
|
|
7181
7883
|
createLineBreaker(content) {
|
|
7182
7884
|
return new LineBreaker(content);
|
|
@@ -7186,14 +7888,14 @@ var SheetCellDocumentViewModel = class SheetCellDocumentViewModel extends Docume
|
|
|
7186
7888
|
}
|
|
7187
7889
|
};
|
|
7188
7890
|
|
|
7189
|
-
// \0@oxc-project+runtime@0.
|
|
7891
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
7190
7892
|
function __decorateParam(paramIndex, decorator) {
|
|
7191
7893
|
return function(target, key) {
|
|
7192
7894
|
decorator(target, key, paramIndex);
|
|
7193
7895
|
};
|
|
7194
7896
|
}
|
|
7195
7897
|
|
|
7196
|
-
// \0@oxc-project+runtime@0.
|
|
7898
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
7197
7899
|
function __decorate(decorators, target, key, desc) {
|
|
7198
7900
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7199
7901
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -7278,6 +7980,11 @@ function updateDocumentPageWidth(documentModel, cellInfo) {
|
|
|
7278
7980
|
const endX = cellInfo.isMergedMainCell ? cellInfo.mergeInfo.endX : cellInfo.endX;
|
|
7279
7981
|
documentModel.updateDocumentDataPageSize(endX - startX, Infinity);
|
|
7280
7982
|
}
|
|
7983
|
+
function updateStackedDocumentPageWidth(documentModel, cellInfo) {
|
|
7984
|
+
const { startY, endY } = cellInfo.isMergedMainCell ? cellInfo.mergeInfo : cellInfo;
|
|
7985
|
+
const { marginLeft = 0, marginRight = 0 } = documentModel.getSnapshot().documentStyle;
|
|
7986
|
+
documentModel.updateDocumentDataPageSize(Math.max(endY - startY, marginLeft + marginRight + 1), Infinity);
|
|
7987
|
+
}
|
|
7281
7988
|
function pushRowRange(ranges, row, startColumn, endColumn) {
|
|
7282
7989
|
if (endColumn < startColumn) return;
|
|
7283
7990
|
const last = ranges[ranges.length - 1];
|
|
@@ -7306,6 +8013,8 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7306
8013
|
_defineProperty(this, "_visibleRangeMap", /* @__PURE__ */ new Map());
|
|
7307
8014
|
_defineProperty(this, "_overflowCache", new ObjectMatrix());
|
|
7308
8015
|
_defineProperty(this, "_incrementalFontRenderRanges", []);
|
|
8016
|
+
_defineProperty(this, "_preparedStyleRanges", /* @__PURE__ */ new Map());
|
|
8017
|
+
_defineProperty(this, "_preparedMergeStyleRanges", new ObjectMatrix());
|
|
7309
8018
|
_defineProperty(this, "_stylesCache", {
|
|
7310
8019
|
background: {},
|
|
7311
8020
|
backgroundPositions: new ObjectMatrix(),
|
|
@@ -7315,6 +8024,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7315
8024
|
_defineProperty(this, "_clearTaskId", null);
|
|
7316
8025
|
_defineProperty(this, "_handleBgMatrix", new ObjectMatrix());
|
|
7317
8026
|
_defineProperty(this, "_handleBorderMatrix", new ObjectMatrix());
|
|
8027
|
+
_defineProperty(this, "_emptyFontCache", new ObjectMatrix());
|
|
8028
|
+
_defineProperty(this, "_nativeTextClipCache", new ObjectMatrix());
|
|
8029
|
+
_defineProperty(this, "_plainTextVerticalOverflowByRow", /* @__PURE__ */ new Map());
|
|
7318
8030
|
_defineProperty(this, "_showGridlines", BooleanNumber.TRUE);
|
|
7319
8031
|
_defineProperty(this, "_gridlinesColor", void 0);
|
|
7320
8032
|
_defineProperty(this, "_defaultGridlinesColor", void 0);
|
|
@@ -7324,6 +8036,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7324
8036
|
const themeService = _injector.get(ThemeService);
|
|
7325
8037
|
this.disposeWithMe(themeService.currentTheme$.subscribe(() => {
|
|
7326
8038
|
var _this$_scene, _this$_scene2;
|
|
8039
|
+
this._preparedMergeStyleRanges.reset();
|
|
7327
8040
|
const gray200 = themeService.getColorFromTheme("gray.200");
|
|
7328
8041
|
const gray900 = themeService.getColorFromTheme("gray.900");
|
|
7329
8042
|
this._defaultGridlinesColor = ColorKit.mix(gray200, gray900, .07).toHexString();
|
|
@@ -7377,6 +8090,19 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7377
8090
|
get incrementalFontRenderRanges() {
|
|
7378
8091
|
return this._incrementalFontRenderRanges;
|
|
7379
8092
|
}
|
|
8093
|
+
get nativeTextClipCache() {
|
|
8094
|
+
return this._nativeTextClipCache;
|
|
8095
|
+
}
|
|
8096
|
+
/** Bound source-row checks by the current cache, without scanning retained font entries. */
|
|
8097
|
+
getPlainTextVerticalOverflow(bound) {
|
|
8098
|
+
if (!this._plainTextVerticalOverflowByRow.size) return 0;
|
|
8099
|
+
let overflow = 0;
|
|
8100
|
+
if (bound) {
|
|
8101
|
+
const { startRow, endRow } = this.getRangeByViewBound(bound);
|
|
8102
|
+
for (let row = startRow; row <= endRow; row++) overflow = Math.max(overflow, this._plainTextVerticalOverflowByRow.get(row) ?? 0);
|
|
8103
|
+
} else for (const value of this._plainTextVerticalOverflowByRow.values()) overflow = Math.max(overflow, value);
|
|
8104
|
+
return overflow;
|
|
8105
|
+
}
|
|
7380
8106
|
get showGridlines() {
|
|
7381
8107
|
return this._showGridlines;
|
|
7382
8108
|
}
|
|
@@ -7402,11 +8128,22 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7402
8128
|
};
|
|
7403
8129
|
this._handleBgMatrix.reset();
|
|
7404
8130
|
this._handleBorderMatrix.reset();
|
|
8131
|
+
this._emptyFontCache.reset();
|
|
8132
|
+
this._nativeTextClipCache.reset();
|
|
8133
|
+
this._plainTextVerticalOverflowByRow.clear();
|
|
8134
|
+
this._preparedStyleRanges.clear();
|
|
7405
8135
|
this._overflowCache.reset();
|
|
8136
|
+
this._preparedMergeStyleRanges.reset();
|
|
7406
8137
|
}
|
|
7407
8138
|
setOverflowCache(value) {
|
|
7408
8139
|
this._overflowCache = value;
|
|
7409
8140
|
}
|
|
8141
|
+
_refreshPlainTextVerticalOverflow(row) {
|
|
8142
|
+
let overflow = 0;
|
|
8143
|
+
for (const font of Object.values(this._stylesCache.fontMatrix.getRow(row) ?? {})) overflow = Math.max(overflow, (font === null || font === void 0 ? void 0 : font.verticalInkOverflow) ?? 0);
|
|
8144
|
+
if (overflow) this._plainTextVerticalOverflowByRow.set(row, overflow);
|
|
8145
|
+
else this._plainTextVerticalOverflowByRow.delete(row);
|
|
8146
|
+
}
|
|
7410
8147
|
getFont(rowIndex, columnIndex) {
|
|
7411
8148
|
const fontCache = this.stylesCache.fontMatrix;
|
|
7412
8149
|
if (!fontCache) return null;
|
|
@@ -7442,9 +8179,15 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7442
8179
|
_clearCacheOutOfVisibleRange(visibleStartRow, visibleEndRow, visibleStartColumn, visibleEndColumn) {
|
|
7443
8180
|
if (this._clearTaskId) cancelIdleCallback(this._clearTaskId);
|
|
7444
8181
|
this._clearTaskId = requestIdleCallback(() => {
|
|
8182
|
+
const overflowRows = /* @__PURE__ */ new Set();
|
|
7445
8183
|
this._stylesCache.fontMatrix.forValue((row, col) => {
|
|
7446
|
-
if (row < visibleStartRow - CACHE_COUNT || row > visibleEndRow + CACHE_COUNT || col < visibleStartColumn - CACHE_COUNT || col > visibleEndColumn + CACHE_COUNT)
|
|
8184
|
+
if (row < visibleStartRow - CACHE_COUNT || row > visibleEndRow + CACHE_COUNT || col < visibleStartColumn - CACHE_COUNT || col > visibleEndColumn + CACHE_COUNT) {
|
|
8185
|
+
this._stylesCache.fontMatrix.realDeleteValue(row, col);
|
|
8186
|
+
this._nativeTextClipCache.realDeleteValue(row, col);
|
|
8187
|
+
if (this._plainTextVerticalOverflowByRow.has(row)) overflowRows.add(row);
|
|
8188
|
+
}
|
|
7447
8189
|
});
|
|
8190
|
+
for (const row of overflowRows) this._refreshPlainTextVerticalOverflow(row);
|
|
7448
8191
|
this._clearTaskId = null;
|
|
7449
8192
|
});
|
|
7450
8193
|
}
|
|
@@ -7454,17 +8197,20 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7454
8197
|
* @param options screen scale
|
|
7455
8198
|
*/
|
|
7456
8199
|
setStylesCache(vpInfo, options) {
|
|
7457
|
-
var _vpInfo$diffBounds, _vpInfo$diffCacheBoun
|
|
8200
|
+
var _vpInfo$diffBounds, _vpInfo$diffCacheBoun;
|
|
7458
8201
|
if (!this._worksheetData) return;
|
|
7459
8202
|
if (!this.rowHeightAccumulation || !this.columnWidthAccumulation) return;
|
|
7460
8203
|
this.updateVisibleRange(vpInfo);
|
|
7461
8204
|
const rowColumnSegment = this._drawingRange;
|
|
7462
8205
|
const columnWidthAccumulation = this.columnWidthAccumulation;
|
|
7463
8206
|
const isIncrementalScroll = !!vpInfo && !vpInfo.isDirty && !vpInfo.isForceDirty && (!!((_vpInfo$diffBounds = vpInfo.diffBounds) === null || _vpInfo$diffBounds === void 0 ? void 0 : _vpInfo$diffBounds.length) || !!((_vpInfo$diffCacheBoun = vpInfo.diffCacheBounds) === null || _vpInfo$diffCacheBoun === void 0 ? void 0 : _vpInfo$diffCacheBoun.length) || !!vpInfo.diffX || !!vpInfo.diffY);
|
|
8207
|
+
const scaleY = (options === null || options === void 0 ? void 0 : options.scaleY) ?? 1;
|
|
8208
|
+
const prepared = vpInfo && this._preparedStyleRanges.get(vpInfo.viewportKey);
|
|
8209
|
+
const shouldUseIncrementalStyleRange = isIncrementalScroll && (prepared === null || prepared === void 0 ? void 0 : prepared.scaleY) === scaleY;
|
|
8210
|
+
this._incrementalFontRenderRanges = [];
|
|
8211
|
+
if (shouldUseIncrementalStyleRange && !vpInfo.shouldCacheUpdate && Rectangle.contains(prepared.range, this.getRangeByViewport(vpInfo))) return this;
|
|
7464
8212
|
const hasMergeData = this.worksheet.getMergeData().length > 0;
|
|
7465
|
-
const
|
|
7466
|
-
const shouldUseIncrementalStyleRange = isIncrementalScroll && !shouldRefreshCacheForScroll;
|
|
7467
|
-
const styleRanges = shouldUseIncrementalStyleRange ? vpInfo.shouldCacheUpdate ? ((_vpInfo$diffCacheBoun2 = vpInfo.diffCacheBounds) === null || _vpInfo$diffCacheBoun2 === void 0 ? void 0 : _vpInfo$diffCacheBoun2.map((bound) => this.getRangeByViewBound(bound))) ?? [] : [] : [rowColumnSegment];
|
|
8213
|
+
const styleRanges = shouldUseIncrementalStyleRange ? Rectangle.subtract(rowColumnSegment, prepared.range) : [rowColumnSegment];
|
|
7468
8214
|
const visibleCellOptions = {
|
|
7469
8215
|
cacheItem: {
|
|
7470
8216
|
bg: true,
|
|
@@ -7487,9 +8233,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7487
8233
|
hasMergeData,
|
|
7488
8234
|
rowVisible: true
|
|
7489
8235
|
};
|
|
7490
|
-
const scaleY = (options === null || options === void 0 ? void 0 : options.scaleY) ?? 1;
|
|
7491
8236
|
const hasRenderContext = options !== void 0;
|
|
7492
|
-
this._incrementalFontRenderRanges = [];
|
|
7493
8237
|
for (const styleRange of styleRanges) {
|
|
7494
8238
|
const { startRow: visibleStartRow, endRow: visibleEndRow, startColumn: visibleStartColumn, endColumn: visibleEndColumn } = styleRange;
|
|
7495
8239
|
if (visibleEndColumn === -1 || visibleEndRow === -1) continue;
|
|
@@ -7552,6 +8296,10 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7552
8296
|
if (shouldUseIncrementalStyleRange) pushRowRange(this._incrementalFontRenderRanges, mergeRange.startRow, mergeRange.startColumn, mergeRange.startColumn);
|
|
7553
8297
|
}
|
|
7554
8298
|
}
|
|
8299
|
+
if (vpInfo) this._preparedStyleRanges.set(vpInfo.viewportKey, {
|
|
8300
|
+
range: { ...rowColumnSegment },
|
|
8301
|
+
scaleY
|
|
8302
|
+
});
|
|
7555
8303
|
return this;
|
|
7556
8304
|
}
|
|
7557
8305
|
/**
|
|
@@ -7783,8 +8531,10 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7783
8531
|
if (documentModel == null) return measuredWidth;
|
|
7784
8532
|
const documentViewModel = new SheetCellDocumentViewModel(documentModel);
|
|
7785
8533
|
const { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
7786
|
-
if ((style === null || style === void 0 ? void 0 : style.tb) === WrapStrategy.WRAP)
|
|
7787
|
-
|
|
8534
|
+
if ((style === null || style === void 0 ? void 0 : style.tb) === WrapStrategy.WRAP) {
|
|
8535
|
+
if (textRotation.v === BooleanNumber.TRUE) updateStackedDocumentPageWidth(documentModel, this.getCellWithCoordByIndex(row, column));
|
|
8536
|
+
else documentModel.updateDocumentDataPageSize(currColWidth, Infinity);
|
|
8537
|
+
} else documentModel.updateDocumentDataPageSize(Infinity, Infinity);
|
|
7788
8538
|
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
7789
8539
|
documentSkeleton.calculate();
|
|
7790
8540
|
measuredWidth = (getDocsSkeletonPageSize(documentSkeleton, angle) ?? { width: 0 }).width;
|
|
@@ -7854,6 +8604,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7854
8604
|
_calculateOverflowCell(row, column, docsConfig, hasMergeData = true) {
|
|
7855
8605
|
const { documentSkeleton, vertexAngle = 0, centerAngle = 0, horizontalAlign, wrapStrategy } = docsConfig;
|
|
7856
8606
|
const { t: cellValueType = CellValueType.STRING } = this._cellData.getValue(row, column) || {};
|
|
8607
|
+
delete docsConfig.verticalInkOverflow;
|
|
7857
8608
|
let horizontalAlignPos = horizontalAlign;
|
|
7858
8609
|
/**
|
|
7859
8610
|
* #univer-pro/issues/334
|
|
@@ -7895,17 +8646,39 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7895
8646
|
}
|
|
7896
8647
|
if (contentSize.width < currentColumnWidth) {
|
|
7897
8648
|
docsConfig.textFitsCurrentCell = true;
|
|
8649
|
+
if (!documentSkeleton && !vertexAngle && !centerAngle) {
|
|
8650
|
+
var _this$gapConfig2, _docsConfig$style;
|
|
8651
|
+
const rowHeight = Math.max(0, this.rowHeightAccumulation[row] - (this.rowHeightAccumulation[row - 1] ?? 0) - (((_this$gapConfig2 = this.gapConfig) === null || _this$gapConfig2 === void 0 || (_this$gapConfig2 = _this$gapConfig2.rowGaps) === null || _this$gapConfig2 === void 0 || (_this$gapConfig2 = _this$gapConfig2[row]) === null || _this$gapConfig2 === void 0 ? void 0 : _this$gapConfig2.size) ?? 0));
|
|
8652
|
+
const padding = ((_docsConfig$style = docsConfig.style) === null || _docsConfig$style === void 0 ? void 0 : _docsConfig$style.pd) ?? DEFAULT_PADDING_DATA;
|
|
8653
|
+
const top = padding.t ?? DEFAULT_PADDING_DATA.t;
|
|
8654
|
+
const bottom = padding.b ?? DEFAULT_PADDING_DATA.b;
|
|
8655
|
+
const ink = Text.getPlainTextVerticalBounds({
|
|
8656
|
+
text: docsConfig.displayText ?? getDisplayValueFromCell(docsConfig.cellData),
|
|
8657
|
+
fontStyle: docsConfig.fontString,
|
|
8658
|
+
height: rowHeight - top - bottom,
|
|
8659
|
+
top: top + FIX_ONE_PIXEL_BLUR_OFFSET,
|
|
8660
|
+
vAlign: docsConfig.verticalAlign
|
|
8661
|
+
});
|
|
8662
|
+
const overflow = Math.max(0, -ink.top, ink.bottom - rowHeight);
|
|
8663
|
+
if (Number.isFinite(overflow) && overflow > 0) {
|
|
8664
|
+
docsConfig.verticalInkOverflow = overflow;
|
|
8665
|
+
this._plainTextVerticalOverflowByRow.set(row, Math.max(this._plainTextVerticalOverflowByRow.get(row) ?? 0, overflow));
|
|
8666
|
+
}
|
|
8667
|
+
}
|
|
7898
8668
|
return true;
|
|
7899
8669
|
}
|
|
7900
8670
|
const { startColumn, endColumn } = this.getOverflowPosition(contentSize, horizontalAlignPos, row, column, this.getColumnCount());
|
|
7901
8671
|
if (startColumn === endColumn) return true;
|
|
7902
8672
|
this.appendToOverflowCache(row, column, startColumn, endColumn);
|
|
7903
8673
|
} else if (wrapStrategy === WrapStrategy.WRAP && vertexAngle !== 0) {
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
const
|
|
7907
|
-
documentSkeleton.getViewModel().getDataModel()
|
|
8674
|
+
const isMerged = hasMergeData && this.intersectMergeRange(row, column);
|
|
8675
|
+
if (isMerged && centerAngle !== 90) return true;
|
|
8676
|
+
const cellInfo = this.getCellWithCoordByIndex(row, column);
|
|
8677
|
+
const documentModel = documentSkeleton.getViewModel().getDataModel();
|
|
8678
|
+
if (centerAngle === 90) updateStackedDocumentPageWidth(documentModel, cellInfo);
|
|
8679
|
+
else documentModel.updateDocumentDataPageSize(cellInfo.endY - cellInfo.startY);
|
|
7908
8680
|
documentSkeleton.calculate();
|
|
8681
|
+
if (isMerged) return true;
|
|
7909
8682
|
const contentSize = getDocsSkeletonPageSize(documentSkeleton, vertexAngle);
|
|
7910
8683
|
if (!contentSize) return true;
|
|
7911
8684
|
const { startColumn, endColumn } = this.getOverflowPosition(contentSize, horizontalAlignPos, row, column, this.getColumnCount());
|
|
@@ -7980,7 +8753,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7980
8753
|
* Any changes to sheet model would reset cache.
|
|
7981
8754
|
*/
|
|
7982
8755
|
_resetCache() {
|
|
7983
|
-
var _this$_handleBgMatrix, _this$_handleBorderMa, _this$_overflowCache;
|
|
8756
|
+
var _this$_handleBgMatrix, _this$_handleBorderMa, _this$_emptyFontCache, _this$_overflowCache;
|
|
8757
|
+
this._preparedStyleRanges.clear();
|
|
8758
|
+
this._preparedMergeStyleRanges.reset();
|
|
7984
8759
|
this._stylesCache = {
|
|
7985
8760
|
background: {},
|
|
7986
8761
|
backgroundPositions: new ObjectMatrix(),
|
|
@@ -7989,23 +8764,33 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
7989
8764
|
};
|
|
7990
8765
|
(_this$_handleBgMatrix = this._handleBgMatrix) === null || _this$_handleBgMatrix === void 0 || _this$_handleBgMatrix.reset();
|
|
7991
8766
|
(_this$_handleBorderMa = this._handleBorderMatrix) === null || _this$_handleBorderMa === void 0 || _this$_handleBorderMa.reset();
|
|
8767
|
+
(_this$_emptyFontCache = this._emptyFontCache) === null || _this$_emptyFontCache === void 0 || _this$_emptyFontCache.reset();
|
|
8768
|
+
this._nativeTextClipCache.reset();
|
|
8769
|
+
this._plainTextVerticalOverflowByRow.clear();
|
|
7992
8770
|
(_this$_overflowCache = this._overflowCache) === null || _this$_overflowCache === void 0 || _this$_overflowCache.reset();
|
|
7993
8771
|
}
|
|
7994
8772
|
resetRangeCache(ranges) {
|
|
8773
|
+
const overflowRows = this._plainTextVerticalOverflowByRow.size ? /* @__PURE__ */ new Set() : null;
|
|
8774
|
+
this._preparedStyleRanges.clear();
|
|
8775
|
+
this._preparedMergeStyleRanges.reset();
|
|
7995
8776
|
for (let i = 0; i < ranges.length; i++) {
|
|
7996
8777
|
const range = ranges[i];
|
|
7997
8778
|
Range.foreach(range, (row, col) => {
|
|
7998
8779
|
var _this$_stylesCache$bo, _this$_stylesCache$ba;
|
|
8780
|
+
if (this._plainTextVerticalOverflowByRow.has(row)) overflowRows === null || overflowRows === void 0 || overflowRows.add(row);
|
|
7999
8781
|
this._stylesCache.fontMatrix.realDeleteValue(row, col);
|
|
8782
|
+
this._nativeTextClipCache.realDeleteValue(row, col);
|
|
8000
8783
|
(_this$_stylesCache$bo = this._stylesCache.border) === null || _this$_stylesCache$bo === void 0 || _this$_stylesCache$bo.realDeleteValue(row, col);
|
|
8001
8784
|
(_this$_stylesCache$ba = this._stylesCache.backgroundPositions) === null || _this$_stylesCache$ba === void 0 || _this$_stylesCache$ba.realDeleteValue(row, col);
|
|
8002
8785
|
this._handleBgMatrix.realDeleteValue(row, col);
|
|
8003
8786
|
this._handleBorderMatrix.realDeleteValue(row, col);
|
|
8787
|
+
this._emptyFontCache.realDeleteValue(row, col);
|
|
8004
8788
|
Object.values(this._stylesCache.background ?? {}).forEach((backgroundMatrix) => {
|
|
8005
8789
|
backgroundMatrix.realDeleteValue(row, col);
|
|
8006
8790
|
});
|
|
8007
8791
|
});
|
|
8008
8792
|
}
|
|
8793
|
+
if (overflowRows) for (const row of overflowRows) this._refreshPlainTextVerticalOverflow(row);
|
|
8009
8794
|
this.makeDirty(true);
|
|
8010
8795
|
}
|
|
8011
8796
|
_setBorderStylesCache(row, col, style, options) {
|
|
@@ -8094,7 +8879,11 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8094
8879
|
} else fontCache.displayText = getCustomNumberDisplayText(displayText, fontCache.fontString, availableWidth);
|
|
8095
8880
|
}
|
|
8096
8881
|
_setFontStylesCache(row, col, cellData, style, hasMergeData = true) {
|
|
8097
|
-
if (isNullCell(cellData))
|
|
8882
|
+
if (isNullCell(cellData)) {
|
|
8883
|
+
this._emptyFontCache.setValue(row, col, true);
|
|
8884
|
+
return;
|
|
8885
|
+
}
|
|
8886
|
+
this._emptyFontCache.realDeleteValue(row, col);
|
|
8098
8887
|
let config = {
|
|
8099
8888
|
cellData,
|
|
8100
8889
|
imageCacheMap: this._imageCacheMap
|
|
@@ -8122,7 +8911,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8122
8911
|
const documentViewModel = new SheetCellDocumentViewModel(documentModel);
|
|
8123
8912
|
if (documentViewModel) {
|
|
8124
8913
|
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
8125
|
-
documentSkeleton.calculate();
|
|
8914
|
+
if (wrapStrategy !== WrapStrategy.WRAP || centerAngle !== 90 || style.stf === BooleanNumber.TRUE) documentSkeleton.calculate();
|
|
8126
8915
|
config = {
|
|
8127
8916
|
documentSkeleton,
|
|
8128
8917
|
vertexAngle,
|
|
@@ -8159,6 +8948,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8159
8948
|
this._applyShrinkToFit(row, col, fontCacheItem, style);
|
|
8160
8949
|
this._calculateOverflowCell(row, col, fontCacheItem, hasMergeData);
|
|
8161
8950
|
this._stylesCache.fontMatrix.setValue(row, col, fontCacheItem);
|
|
8951
|
+
if (fontCacheItem.vertexAngle || fontCacheItem.centerAngle || fontCacheItem.shrinkScale !== void 0 && fontCacheItem.shrinkScale !== 1) this._nativeTextClipCache.setValue(row, col, true);
|
|
8162
8952
|
}
|
|
8163
8953
|
/**
|
|
8164
8954
|
* Set border background and font to this._stylesCache cell by cell.
|
|
@@ -8172,11 +8962,16 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8172
8962
|
bg: true,
|
|
8173
8963
|
border: true
|
|
8174
8964
|
} };
|
|
8175
|
-
const cacheItem = options.cacheItem
|
|
8176
|
-
|
|
8965
|
+
const cacheItem = options.cacheItem ?? {
|
|
8966
|
+
bg: true,
|
|
8967
|
+
border: true
|
|
8968
|
+
};
|
|
8969
|
+
const mergeRange = options.mergeRange;
|
|
8970
|
+
const preparedMergeRange = mergeRange && this._preparedMergeStyleRanges.getValue(row, col);
|
|
8971
|
+
if (options.reuseExisting && (!mergeRange || preparedMergeRange && Rectangle.equals(preparedMergeRange, mergeRange))) {
|
|
8177
8972
|
const bgHandled = !cacheItem.bg || Tools.isDefine(this._handleBgMatrix.getValue(row, col));
|
|
8178
8973
|
const borderHandled = !cacheItem.border || Tools.isDefine(this._handleBorderMatrix.getValue(row, col));
|
|
8179
|
-
if (bgHandled && borderHandled && (options.skipFontCache || this._stylesCache.fontMatrix.getValue(row, col))) return;
|
|
8974
|
+
if (bgHandled && borderHandled && (options.skipFontCache || this._stylesCache.fontMatrix.getValue(row, col) || this._emptyFontCache.getValue(row, col))) return;
|
|
8180
8975
|
}
|
|
8181
8976
|
const hasMergeData = options.hasMergeData ?? true;
|
|
8182
8977
|
let isMerged = false;
|
|
@@ -8193,13 +8988,14 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8193
8988
|
}
|
|
8194
8989
|
const cell = this.worksheet.getCell(row, col) || this.worksheet.getCellRaw(row, col);
|
|
8195
8990
|
const style = this.worksheet.getComposedCellStyleByCellData(row, col, cell);
|
|
8196
|
-
if (!cell && Object.keys(style).length === 0) return;
|
|
8991
|
+
if (!mergeRange && isNullCell(cell) && Object.keys(style).length === 0) return;
|
|
8197
8992
|
this._setBgStylesCache(row, col, style, options);
|
|
8198
8993
|
this._setBorderStylesCache(row, col, style, options);
|
|
8199
8994
|
if (!options.skipFontCache) this._setFontStylesCache(row, col, {
|
|
8200
8995
|
...cell,
|
|
8201
8996
|
s: style
|
|
8202
8997
|
}, style, options.hasMergeData ?? true);
|
|
8998
|
+
if (mergeRange && cacheItem.bg && cacheItem.border && !options.skipFontCache) this._preparedMergeStyleRanges.setValue(row, col, { ...mergeRange });
|
|
8203
8999
|
}
|
|
8204
9000
|
/**
|
|
8205
9001
|
* pro/issues/344
|
|
@@ -8432,18 +9228,52 @@ function needsFontRenderExtensionBounds(fontCache) {
|
|
|
8432
9228
|
const extension = (_fontCache$cellData = fontCache.cellData) === null || _fontCache$cellData === void 0 ? void 0 : _fontCache$cellData.fontRenderExtension;
|
|
8433
9229
|
return Boolean((extension === null || extension === void 0 ? void 0 : extension.isSkip) || (extension === null || extension === void 0 ? void 0 : extension.leftOffset) || (extension === null || extension === void 0 ? void 0 : extension.rightOffset));
|
|
8434
9230
|
}
|
|
8435
|
-
var Font = class extends SheetExtension {
|
|
9231
|
+
var Font = class Font extends SheetExtension {
|
|
9232
|
+
clearCache() {
|
|
9233
|
+
this._primitiveCache.clear();
|
|
9234
|
+
}
|
|
9235
|
+
dispose() {
|
|
9236
|
+
this._imageFallback.onload = null;
|
|
9237
|
+
this._primitiveCache.dispose();
|
|
9238
|
+
super.dispose();
|
|
9239
|
+
}
|
|
8436
9240
|
constructor() {
|
|
8437
9241
|
super();
|
|
9242
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === Font);
|
|
8438
9243
|
_defineProperty(this, "uKey", UNIQUE_KEY$2);
|
|
8439
9244
|
_defineProperty(this, "Z_INDEX", 45);
|
|
8440
9245
|
_defineProperty(this, "_imageFallback", new Image());
|
|
9246
|
+
_defineProperty(this, "_primitiveCache", new RenderPrimitiveCache());
|
|
9247
|
+
this._imageFallback.onload = () => {
|
|
9248
|
+
var _this$parent;
|
|
9249
|
+
this._imageFallback.onload = null;
|
|
9250
|
+
(_this$parent = this.parent) === null || _this$parent === void 0 || _this$parent.makeDirty(true);
|
|
9251
|
+
};
|
|
8441
9252
|
this._imageFallback.src = IMAGE_FALLBACK_SRC;
|
|
8442
9253
|
}
|
|
8443
9254
|
getDocuments() {
|
|
8444
9255
|
const parent = this.parent;
|
|
8445
9256
|
return parent === null || parent === void 0 ? void 0 : parent.getDocuments();
|
|
8446
9257
|
}
|
|
9258
|
+
getNativeTextClipRepairRanges(skeleton) {
|
|
9259
|
+
const ranges = [];
|
|
9260
|
+
skeleton.nativeTextClipCache.forValue((row, column) => {
|
|
9261
|
+
const cell = skeleton.getCellWithCoordByIndex(row, column, false);
|
|
9262
|
+
const range = skeleton.overflowCache.getValue(row, column) ?? (cell.isMerged || cell.isMergedMainCell ? cell.mergeInfo : {
|
|
9263
|
+
startRow: row,
|
|
9264
|
+
endRow: row,
|
|
9265
|
+
startColumn: column,
|
|
9266
|
+
endColumn: column
|
|
9267
|
+
});
|
|
9268
|
+
ranges.push({
|
|
9269
|
+
startRow: range.startRow,
|
|
9270
|
+
endRow: range.endRow,
|
|
9271
|
+
startColumn: range.startColumn,
|
|
9272
|
+
endColumn: range.endColumn
|
|
9273
|
+
});
|
|
9274
|
+
});
|
|
9275
|
+
return ranges;
|
|
9276
|
+
}
|
|
8447
9277
|
/**
|
|
8448
9278
|
* Safely draw fallback image, checking if it's fully loaded first.
|
|
8449
9279
|
* If not loaded, draw a simple gray rectangle as placeholder.
|
|
@@ -8471,6 +9301,26 @@ var Font = class extends SheetExtension {
|
|
|
8471
9301
|
endColumn: range.endColumn + 20
|
|
8472
9302
|
}, lastRowIndex, lastColIndex));
|
|
8473
9303
|
const rangesToScan = (fontRenderRanges === null || fontRenderRanges === void 0 ? void 0 : fontRenderRanges.length) ? fontRenderRanges : expandedViewRanges;
|
|
9304
|
+
const verticalOverflow = ctx.__mode !== "printing" && moreBoundsInfo.textClipBound ? spreadsheetSkeleton.getPlainTextVerticalOverflow(moreBoundsInfo.viewBound) : 0;
|
|
9305
|
+
const sourceRange = verticalOverflow ? spreadsheetSkeleton.getRangeByViewBound(moreBoundsInfo.viewBound) : null;
|
|
9306
|
+
const expandPlainTextRows = (range) => {
|
|
9307
|
+
if (!verticalOverflow || !sourceRange) return range;
|
|
9308
|
+
const top = rowHeightAccumulation[range.startRow - 1] ?? 0;
|
|
9309
|
+
const bottom = rowHeightAccumulation[range.endRow] ?? top;
|
|
9310
|
+
const rows = spreadsheetSkeleton.getRangeByViewBound({
|
|
9311
|
+
left: 0,
|
|
9312
|
+
right: 0,
|
|
9313
|
+
top: Math.floor(top - verticalOverflow) - 1 + spreadsheetSkeleton.columnHeaderHeightAndMarginTop,
|
|
9314
|
+
bottom: Math.ceil(bottom + verticalOverflow) + 1 + spreadsheetSkeleton.columnHeaderHeightAndMarginTop
|
|
9315
|
+
});
|
|
9316
|
+
return {
|
|
9317
|
+
...range,
|
|
9318
|
+
startRow: Math.max(sourceRange.startRow, rows.startRow),
|
|
9319
|
+
endRow: Math.min(sourceRange.endRow, rows.endRow)
|
|
9320
|
+
};
|
|
9321
|
+
};
|
|
9322
|
+
const plainTextRanges = verticalOverflow ? (diffRanges.length ? diffRanges : rangesToScan).map(expandPlainTextRows) : [];
|
|
9323
|
+
const extraPlainCells = verticalOverflow ? /* @__PURE__ */ new Set() : null;
|
|
8474
9324
|
const renderFontContext = {
|
|
8475
9325
|
ctx,
|
|
8476
9326
|
scale,
|
|
@@ -8478,10 +9328,12 @@ var Font = class extends SheetExtension {
|
|
|
8478
9328
|
rowTotalHeight,
|
|
8479
9329
|
viewRanges: (fontRenderRanges === null || fontRenderRanges === void 0 ? void 0 : fontRenderRanges.length) ? viewRanges : expandedViewRanges,
|
|
8480
9330
|
checkOutOfViewBound: checkOutOfViewBound || true,
|
|
8481
|
-
diffRanges,
|
|
9331
|
+
diffRanges: verticalOverflow ? plainTextRanges : diffRanges,
|
|
8482
9332
|
spreadsheetSkeleton
|
|
8483
9333
|
};
|
|
8484
9334
|
ctx.save();
|
|
9335
|
+
const deviceClip = ctx.__mode === "printing" ? void 0 : moreBoundsInfo.textClipBound;
|
|
9336
|
+
const transform = deviceClip ? ctx.getTransform() : void 0;
|
|
8485
9337
|
const hasMerge = spreadsheetSkeleton.worksheet.getMergeData().length > 0;
|
|
8486
9338
|
const uniqueMergeRanges = [];
|
|
8487
9339
|
const mergeRangeIDSet = hasMerge ? /* @__PURE__ */ new Set() : null;
|
|
@@ -8495,7 +9347,8 @@ var Font = class extends SheetExtension {
|
|
|
8495
9347
|
}
|
|
8496
9348
|
});
|
|
8497
9349
|
const { startRow, endRow, startColumn, endColumn } = range;
|
|
8498
|
-
|
|
9350
|
+
const scan = expandPlainTextRows(range);
|
|
9351
|
+
for (let row = scan.startRow; row <= scan.endRow; row++) {
|
|
8499
9352
|
var _spreadsheetSkeleton$;
|
|
8500
9353
|
const rowStartPosition = rowHeightAccumulation[row - 1] ?? 0;
|
|
8501
9354
|
const rowEndPosition = rowHeightAccumulation[row] ?? rowStartPosition;
|
|
@@ -8503,13 +9356,31 @@ var Font = class extends SheetExtension {
|
|
|
8503
9356
|
const rowHeight = Math.max(0, rowEndPosition - rowStartPosition - rowGap);
|
|
8504
9357
|
if (!shouldRenderRowText(rowHeight, parentScale.scaleY)) continue;
|
|
8505
9358
|
for (let col = startColumn; col <= endColumn; col++) {
|
|
9359
|
+
var _fontCache$cellData2;
|
|
8506
9360
|
const fontCache = fontMatrix.getValue(row, col);
|
|
8507
9361
|
if (!fontCache) continue;
|
|
9362
|
+
if (row < startRow || row > endRow) {
|
|
9363
|
+
if (inViewRanges(rangesToScan, row, col) || !inViewRanges(plainTextRanges, row, col) || !this._canRenderPlainTextWithoutClip(fontCache)) continue;
|
|
9364
|
+
const key = `${row}:${col}`;
|
|
9365
|
+
if (extraPlainCells === null || extraPlainCells === void 0 ? void 0 : extraPlainCells.has(key)) continue;
|
|
9366
|
+
extraPlainCells === null || extraPlainCells === void 0 || extraPlainCells.add(key);
|
|
9367
|
+
}
|
|
8508
9368
|
if (spanModel && spanModel.getMergeDataIndex(row, col) !== -1) continue;
|
|
9369
|
+
if (deviceClip && transform && transform.a > 0 && transform.d > 0 && !transform.b && !transform.c && !fontCache.documentSkeleton && !fontCache.vertexAngle && !fontCache.centerAngle && fontCache.textFitsCurrentCell === false && !((_fontCache$cellData2 = fontCache.cellData) === null || _fontCache$cellData2 === void 0 ? void 0 : _fontCache$cellData2.fontRenderExtension)) {
|
|
9370
|
+
const overflow = spreadsheetSkeleton.overflowCache.getValue(row, col);
|
|
9371
|
+
if (overflow) {
|
|
9372
|
+
const left = (columnWidthAccumulation[Math.min(col, overflow.startColumn) - 1] ?? 0) * transform.a + transform.e;
|
|
9373
|
+
const right = columnWidthAccumulation[Math.max(col, overflow.endColumn)] * transform.a + transform.e;
|
|
9374
|
+
const top = (rowHeightAccumulation[Math.min(row, overflow.startRow) - 1] ?? 0) * transform.d + transform.f;
|
|
9375
|
+
const bottom = rowHeightAccumulation[Math.max(row, overflow.endRow)] * transform.d + transform.f;
|
|
9376
|
+
if (right + 2 < deviceClip.left || left - 2 > deviceClip.right || bottom + 2 < deviceClip.top || top - 2 > deviceClip.bottom) continue;
|
|
9377
|
+
}
|
|
9378
|
+
}
|
|
8509
9379
|
const cellInfo = spreadsheetSkeleton.getCellWithCoordByIndex(row, col, false);
|
|
8510
9380
|
if (!cellInfo) continue;
|
|
8511
9381
|
renderFontContext.cellInfo = cellInfo;
|
|
8512
|
-
this._renderFontEachCell(renderFontContext, row, col, fontMatrix, fontCache);
|
|
9382
|
+
if (fontCache.documentSkeleton || moreBoundsInfo.textClipBound) this._primitiveCache.draw(ctx, () => this._renderFontEachCell(renderFontContext, row, col, fontMatrix, fontCache), fontCache.documentSkeleton ? void 0 : moreBoundsInfo.textClipBound);
|
|
9383
|
+
else this._renderFontEachCell(renderFontContext, row, col, fontMatrix, fontCache);
|
|
8513
9384
|
}
|
|
8514
9385
|
}
|
|
8515
9386
|
});
|
|
@@ -8518,12 +9389,12 @@ var Font = class extends SheetExtension {
|
|
|
8518
9389
|
if (!fontCache) return;
|
|
8519
9390
|
const cellInfo = spreadsheetSkeleton.getCellWithCoordByIndex(range.startRow, range.startColumn, false);
|
|
8520
9391
|
renderFontContext.cellInfo = cellInfo;
|
|
8521
|
-
this._renderFontEachCell(renderFontContext, range.startRow, range.startColumn, fontMatrix, fontCache);
|
|
9392
|
+
this._primitiveCache.draw(ctx, () => this._renderFontEachCell(renderFontContext, range.startRow, range.startColumn, fontMatrix, fontCache));
|
|
8522
9393
|
});
|
|
8523
9394
|
ctx.restore();
|
|
8524
9395
|
}
|
|
8525
9396
|
_renderFontEachCell(renderFontCtx, row, col, fontMatrix, cacheValue) {
|
|
8526
|
-
var _fontCache$
|
|
9397
|
+
var _fontCache$cellData3;
|
|
8527
9398
|
const { ctx, viewRanges, diffRanges, spreadsheetSkeleton, cellInfo } = renderFontCtx;
|
|
8528
9399
|
const { startY, endY, startX, endX } = cellInfo;
|
|
8529
9400
|
const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
|
|
@@ -8564,7 +9435,7 @@ var Font = class extends SheetExtension {
|
|
|
8564
9435
|
}
|
|
8565
9436
|
if (isAllColHidden) return true;
|
|
8566
9437
|
}
|
|
8567
|
-
if ((_fontCache$
|
|
9438
|
+
if ((_fontCache$cellData3 = fontCache.cellData) === null || _fontCache$cellData3 === void 0 ? void 0 : _fontCache$cellData3.fontRenderExtension) {
|
|
8568
9439
|
var _cellData$fontRenderE;
|
|
8569
9440
|
const cellData = spreadsheetSkeleton.worksheet.getCell(row, col) || {};
|
|
8570
9441
|
if (cellData === null || cellData === void 0 || (_cellData$fontRenderE = cellData.fontRenderExtension) === null || _cellData$fontRenderE === void 0 ? void 0 : _cellData$fontRenderE.isSkip) return true;
|
|
@@ -8603,8 +9474,8 @@ var Font = class extends SheetExtension {
|
|
|
8603
9474
|
renderFontCtx.overflowRectangle = null;
|
|
8604
9475
|
return false;
|
|
8605
9476
|
}
|
|
8606
|
-
|
|
8607
|
-
var _fontCache$style, _fontCache$style2
|
|
9477
|
+
_canRenderPlainTextWithoutClip(fontCache) {
|
|
9478
|
+
var _fontCache$style, _fontCache$style2;
|
|
8608
9479
|
const { cellData, documentSkeleton, textFitsCurrentCell, vertexAngle = 0, centerAngle = 0, wrapStrategy } = fontCache;
|
|
8609
9480
|
if (!textFitsCurrentCell) return false;
|
|
8610
9481
|
if (documentSkeleton) return false;
|
|
@@ -8613,6 +9484,12 @@ var Font = class extends SheetExtension {
|
|
|
8613
9484
|
if (needsFontRenderExtensionBounds(fontCache)) return false;
|
|
8614
9485
|
if (((_fontCache$style = fontCache.style) === null || _fontCache$style === void 0 || (_fontCache$style = _fontCache$style.st) === null || _fontCache$style === void 0 ? void 0 : _fontCache$style.s) || ((_fontCache$style2 = fontCache.style) === null || _fontCache$style2 === void 0 || (_fontCache$style2 = _fontCache$style2.ul) === null || _fontCache$style2 === void 0 ? void 0 : _fontCache$style2.s)) return false;
|
|
8615
9486
|
if ((cellData === null || cellData === void 0 ? void 0 : cellData.v) === void 0 || (cellData === null || cellData === void 0 ? void 0 : cellData.v) === null) return false;
|
|
9487
|
+
return true;
|
|
9488
|
+
}
|
|
9489
|
+
_renderPlainTextWithoutClip(ctx, renderFontCtx, fontCache) {
|
|
9490
|
+
var _fontCache$style3, _fontCache$style4;
|
|
9491
|
+
if (!this._canRenderPlainTextWithoutClip(fontCache)) return false;
|
|
9492
|
+
const cellData = fontCache.cellData;
|
|
8616
9493
|
const padding = ((_fontCache$style3 = fontCache.style) === null || _fontCache$style3 === void 0 ? void 0 : _fontCache$style3.pd) ?? DEFAULT_PADDING_DATA;
|
|
8617
9494
|
const paddingLeft = padding.l ?? DEFAULT_PADDING_DATA.l;
|
|
8618
9495
|
const paddingRight = padding.r ?? DEFAULT_PADDING_DATA.r;
|
|
@@ -8647,11 +9524,11 @@ var Font = class extends SheetExtension {
|
|
|
8647
9524
|
if (drawingData) {
|
|
8648
9525
|
var _drawingData$docTrans, _drawingData$docTrans2, _drawingData$docTrans3, _fontsConfig$style;
|
|
8649
9526
|
const image = fontsConfig.imageCacheMap.getImage(drawingData.imageSourceType, drawingData.source, () => {
|
|
8650
|
-
var _this$parent;
|
|
8651
|
-
(_this$parent = this.parent) === null || _this$parent === void 0 || _this$parent.makeDirty();
|
|
8652
|
-
}, () => {
|
|
8653
9527
|
var _this$parent2;
|
|
8654
9528
|
(_this$parent2 = this.parent) === null || _this$parent2 === void 0 || _this$parent2.makeDirty();
|
|
9529
|
+
}, () => {
|
|
9530
|
+
var _this$parent3;
|
|
9531
|
+
(_this$parent3 = this.parent) === null || _this$parent3 === void 0 || _this$parent3.makeDirty();
|
|
8655
9532
|
});
|
|
8656
9533
|
const width = ((_drawingData$docTrans = drawingData.docTransform) === null || _drawingData$docTrans === void 0 ? void 0 : _drawingData$docTrans.size.width) ?? drawing.width;
|
|
8657
9534
|
const height = ((_drawingData$docTrans2 = drawingData.docTransform) === null || _drawingData$docTrans2 === void 0 ? void 0 : _drawingData$docTrans2.size.height) ?? drawing.height;
|
|
@@ -8694,7 +9571,7 @@ var Font = class extends SheetExtension {
|
|
|
8694
9571
|
* @param padding
|
|
8695
9572
|
*/
|
|
8696
9573
|
_clipByRenderBounds(renderFontContext, row, col, padding = 0) {
|
|
8697
|
-
var _fontCache$
|
|
9574
|
+
var _fontCache$cellData4, _fontCache$cellData5;
|
|
8698
9575
|
const { ctx, scale, overflowRectangle, fontCache } = renderFontContext;
|
|
8699
9576
|
let { startX, endX, startY, endY } = renderFontContext;
|
|
8700
9577
|
const { horizontalAlign = 0, vertexAngle = 0, centerAngle = 0 } = fontCache;
|
|
@@ -8703,8 +9580,8 @@ var Font = class extends SheetExtension {
|
|
|
8703
9580
|
if (centerAngle === 90 && vertexAngle === 90) horizontalAlignOverFlow = HorizontalAlign.CENTER;
|
|
8704
9581
|
else if (vertexAngle > 0 && vertexAngle !== 90 || vertexAngle === -90) horizontalAlignOverFlow = HorizontalAlign.RIGHT;
|
|
8705
9582
|
}
|
|
8706
|
-
const rightOffset = (fontCache === null || fontCache === void 0 || (_fontCache$
|
|
8707
|
-
const leftOffset = (fontCache === null || fontCache === void 0 || (_fontCache$
|
|
9583
|
+
const rightOffset = (fontCache === null || fontCache === void 0 || (_fontCache$cellData4 = fontCache.cellData) === null || _fontCache$cellData4 === void 0 || (_fontCache$cellData4 = _fontCache$cellData4.fontRenderExtension) === null || _fontCache$cellData4 === void 0 ? void 0 : _fontCache$cellData4.rightOffset) ?? 0;
|
|
9584
|
+
const leftOffset = (fontCache === null || fontCache === void 0 || (_fontCache$cellData5 = fontCache.cellData) === null || _fontCache$cellData5 === void 0 || (_fontCache$cellData5 = _fontCache$cellData5.fontRenderExtension) === null || _fontCache$cellData5 === void 0 ? void 0 : _fontCache$cellData5.leftOffset) ?? 0;
|
|
8708
9585
|
let isOverflow = true;
|
|
8709
9586
|
if (vertexAngle === 0) {
|
|
8710
9587
|
startX = startX + leftOffset;
|
|
@@ -8855,9 +9732,10 @@ function drawTriangleMarker(ctx, color, x, y, x2, y2, x3, y3) {
|
|
|
8855
9732
|
ctx.closePath();
|
|
8856
9733
|
ctx.fill();
|
|
8857
9734
|
}
|
|
8858
|
-
var Marker = class extends SheetExtension {
|
|
9735
|
+
var Marker = class Marker extends SheetExtension {
|
|
8859
9736
|
constructor(..._args) {
|
|
8860
9737
|
super(..._args);
|
|
9738
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === Marker);
|
|
8861
9739
|
_defineProperty(this, "Z_INDEX", Z_INDEX);
|
|
8862
9740
|
_defineProperty(this, "uKey", UNIQUE_KEY$1);
|
|
8863
9741
|
}
|
|
@@ -8955,9 +9833,10 @@ const DEFAULT_PRINTING_ROW_STYLE = {
|
|
|
8955
9833
|
217
|
|
8956
9834
|
])
|
|
8957
9835
|
};
|
|
8958
|
-
var RowHeaderLayout = class extends SheetExtension {
|
|
9836
|
+
var RowHeaderLayout = class RowHeaderLayout extends SheetExtension {
|
|
8959
9837
|
constructor(cfg) {
|
|
8960
9838
|
super();
|
|
9839
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === RowHeaderLayout);
|
|
8961
9840
|
_defineProperty(this, "uKey", UNIQUE_KEY);
|
|
8962
9841
|
_defineProperty(this, "Z_INDEX", 10);
|
|
8963
9842
|
_defineProperty(this, "rowsCfg", {});
|
|
@@ -9122,7 +10001,7 @@ var RowHeaderLayout = class extends SheetExtension {
|
|
|
9122
10001
|
SheetRowHeaderExtensionRegistry.add(new RowHeaderLayout());
|
|
9123
10002
|
|
|
9124
10003
|
// src/components/sheets/row-header.ts
|
|
9125
|
-
var SpreadsheetRowHeader = class extends SpreadsheetHeader {
|
|
10004
|
+
var SpreadsheetRowHeader = class SpreadsheetRowHeader extends SpreadsheetHeader {
|
|
9126
10005
|
getDocuments() {
|
|
9127
10006
|
throw new Error("Method not implemented.");
|
|
9128
10007
|
}
|
|
@@ -9135,6 +10014,7 @@ var SpreadsheetRowHeader = class extends SpreadsheetHeader {
|
|
|
9135
10014
|
constructor(oKey, spreadsheetSkeleton) {
|
|
9136
10015
|
super(oKey, spreadsheetSkeleton);
|
|
9137
10016
|
_defineProperty(this, "_rowHeaderLayoutExtension", void 0);
|
|
10017
|
+
this.viewportCacheReusable = this.constructor === SpreadsheetRowHeader;
|
|
9138
10018
|
this._initialDefaultExtension();
|
|
9139
10019
|
this.makeDirty(true);
|
|
9140
10020
|
}
|
|
@@ -9179,6 +10059,14 @@ var SpreadsheetRowHeader = class extends SpreadsheetHeader {
|
|
|
9179
10059
|
// src/components/sheets/spreadsheet.ts
|
|
9180
10060
|
const OBJECT_KEY = "__SHEET_EXTENSION_FONT_DOCUMENT_INSTANCE__";
|
|
9181
10061
|
const MERGE_REPAIR_CACHE_REFRESH_RATIO = .6;
|
|
10062
|
+
const SCROLL_REPAIR_INK_HALO = 2;
|
|
10063
|
+
const BORDER_INK_HALO = 2;
|
|
10064
|
+
const BORDER_EDGE_KEYS = /* @__PURE__ */ new Set([
|
|
10065
|
+
"t",
|
|
10066
|
+
"b",
|
|
10067
|
+
"l",
|
|
10068
|
+
"r"
|
|
10069
|
+
]);
|
|
9182
10070
|
const CUSTOM_EXTENSION_KEY = "DefaultCustomExtension";
|
|
9183
10071
|
const MARKER_EXTENSION_KEY = "DefaultMarkerExtension";
|
|
9184
10072
|
const RANGE_PROTECTION_VIEW_EXTENSION_KEY = "RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY";
|
|
@@ -9201,7 +10089,7 @@ function pushSparseCellRange(ranges, row, col) {
|
|
|
9201
10089
|
endColumn: col
|
|
9202
10090
|
});
|
|
9203
10091
|
}
|
|
9204
|
-
function scanSparseExtensionFeatures(spreadsheetSkeleton, ranges) {
|
|
10092
|
+
function scanSparseExtensionFeatures(spreadsheetSkeleton, ranges, includeMergedAnchors) {
|
|
9205
10093
|
const { worksheet } = spreadsheetSkeleton;
|
|
9206
10094
|
if (!worksheet || !ranges.length) return null;
|
|
9207
10095
|
const flags = {
|
|
@@ -9212,25 +10100,38 @@ function scanSparseExtensionFeatures(spreadsheetSkeleton, ranges) {
|
|
|
9212
10100
|
markerRanges: [],
|
|
9213
10101
|
selectionProtectionRanges: []
|
|
9214
10102
|
};
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
10103
|
+
const visitCell = (row, col, renderRow = row, renderCol = col) => {
|
|
10104
|
+
var _spreadsheetSkeleton$, _cell$customRender, _cell$selectionProtec;
|
|
10105
|
+
const cell = ((_spreadsheetSkeleton$ = spreadsheetSkeleton.stylesCache.fontMatrix.getValue(row, col)) === null || _spreadsheetSkeleton$ === void 0 ? void 0 : _spreadsheetSkeleton$.cellData) ?? worksheet.getCell(row, col);
|
|
10106
|
+
if (!cell) return;
|
|
10107
|
+
if ((_cell$customRender = cell.customRender) === null || _cell$customRender === void 0 ? void 0 : _cell$customRender.length) {
|
|
10108
|
+
flags.hasCustomRender = true;
|
|
10109
|
+
pushSparseCellRange(flags.customRenderRanges, renderRow, renderCol);
|
|
10110
|
+
}
|
|
10111
|
+
if (cell.markers) {
|
|
10112
|
+
flags.hasMarkers = true;
|
|
10113
|
+
pushSparseCellRange(flags.markerRanges, renderRow, renderCol);
|
|
10114
|
+
}
|
|
10115
|
+
if ((_cell$selectionProtec = cell.selectionProtection) === null || _cell$selectionProtec === void 0 ? void 0 : _cell$selectionProtec.length) {
|
|
10116
|
+
flags.hasSelectionProtection = true;
|
|
10117
|
+
pushSparseCellRange(flags.selectionProtectionRanges, renderRow, renderCol);
|
|
10118
|
+
}
|
|
10119
|
+
};
|
|
10120
|
+
for (const range of ranges) {
|
|
10121
|
+
for (let row = range.startRow; row <= range.endRow; row++) {
|
|
10122
|
+
if (!worksheet.getRowVisible(row)) continue;
|
|
10123
|
+
for (let col = range.startColumn; col <= range.endColumn; col++) if (worksheet.getColVisible(col)) visitCell(row, col);
|
|
10124
|
+
}
|
|
10125
|
+
if (!includeMergedAnchors) continue;
|
|
10126
|
+
for (const merge of worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn)) {
|
|
10127
|
+
if (merge.startRow >= range.startRow && merge.startColumn >= range.startColumn && worksheet.getRowVisible(merge.startRow) && worksheet.getColVisible(merge.startColumn)) continue;
|
|
10128
|
+
let row = Math.max(range.startRow, merge.startRow);
|
|
10129
|
+
let col = Math.max(range.startColumn, merge.startColumn);
|
|
10130
|
+
const endRow = Math.min(range.endRow, merge.endRow);
|
|
10131
|
+
const endColumn = Math.min(range.endColumn, merge.endColumn);
|
|
10132
|
+
while (row <= endRow && !worksheet.getRowVisible(row)) row++;
|
|
10133
|
+
while (col <= endColumn && !worksheet.getColVisible(col)) col++;
|
|
10134
|
+
if (row <= endRow && col <= endColumn) visitCell(merge.startRow, merge.startColumn, row, col);
|
|
9234
10135
|
}
|
|
9235
10136
|
}
|
|
9236
10137
|
return flags;
|
|
@@ -9269,10 +10170,50 @@ function getSparseExtensionDiffRanges(uKey, flags, diffRanges) {
|
|
|
9269
10170
|
function boundsOverlap(a, b) {
|
|
9270
10171
|
return a.left <= b.right && a.right >= b.left && a.top <= b.bottom && a.bottom >= b.top;
|
|
9271
10172
|
}
|
|
9272
|
-
function
|
|
9273
|
-
|
|
10173
|
+
function getIntersectBound(a, b) {
|
|
10174
|
+
const left = Math.max(a.left, b.left);
|
|
10175
|
+
const right = Math.min(a.right, b.right);
|
|
10176
|
+
const top = Math.max(a.top, b.top);
|
|
10177
|
+
const bottom = Math.min(a.bottom, b.bottom);
|
|
10178
|
+
return right > left && bottom > top ? {
|
|
10179
|
+
left,
|
|
10180
|
+
right,
|
|
10181
|
+
top,
|
|
10182
|
+
bottom
|
|
10183
|
+
} : null;
|
|
9274
10184
|
}
|
|
9275
|
-
function
|
|
10185
|
+
function getOutwardRoundedBound(bound) {
|
|
10186
|
+
return {
|
|
10187
|
+
left: Math.floor(bound.left),
|
|
10188
|
+
top: Math.floor(bound.top),
|
|
10189
|
+
right: Math.ceil(bound.right),
|
|
10190
|
+
bottom: Math.ceil(bound.bottom)
|
|
10191
|
+
};
|
|
10192
|
+
}
|
|
10193
|
+
function appendRepaintBound(bounds, next) {
|
|
10194
|
+
for (let index = 0; index < bounds.length;) {
|
|
10195
|
+
const previous = bounds[index];
|
|
10196
|
+
if (!getIntersectBound(next.bound, previous.bound)) {
|
|
10197
|
+
index++;
|
|
10198
|
+
continue;
|
|
10199
|
+
}
|
|
10200
|
+
next.bound = {
|
|
10201
|
+
left: Math.min(next.bound.left, previous.bound.left),
|
|
10202
|
+
top: Math.min(next.bound.top, previous.bound.top),
|
|
10203
|
+
right: Math.max(next.bound.right, previous.bound.right),
|
|
10204
|
+
bottom: Math.max(next.bound.bottom, previous.bound.bottom)
|
|
10205
|
+
};
|
|
10206
|
+
next.repairsMerge ||= previous.repairsMerge;
|
|
10207
|
+
next.repairsNativeText ||= previous.repairsNativeText;
|
|
10208
|
+
bounds.splice(index, 1);
|
|
10209
|
+
index = 0;
|
|
10210
|
+
}
|
|
10211
|
+
bounds.push(next);
|
|
10212
|
+
}
|
|
10213
|
+
function getClippedBoundArea(bound, clipBound) {
|
|
10214
|
+
return Math.max(0, Math.min(bound.right, clipBound.right) - Math.max(bound.left, clipBound.left)) * Math.max(0, Math.min(bound.bottom, clipBound.bottom) - Math.max(bound.top, clipBound.top));
|
|
10215
|
+
}
|
|
10216
|
+
function exceedsMergeRepairThreshold(cacheBound, repaintBounds, hasMergeRepair) {
|
|
9276
10217
|
if (!hasMergeRepair) return false;
|
|
9277
10218
|
const cacheArea = getClippedBoundArea(cacheBound, cacheBound);
|
|
9278
10219
|
return repaintBounds.reduce((area, repaintBound) => area + getClippedBoundArea(repaintBound.bound, cacheBound), 0) >= cacheArea * MERGE_REPAIR_CACHE_REFRESH_RATIO;
|
|
@@ -9334,11 +10275,17 @@ function clipBlitRectToBounds(rect, sourceWidth, sourceHeight) {
|
|
|
9334
10275
|
dh
|
|
9335
10276
|
};
|
|
9336
10277
|
}
|
|
9337
|
-
var Spreadsheet = class extends SheetComponent {
|
|
10278
|
+
var Spreadsheet = class Spreadsheet extends SheetComponent {
|
|
10279
|
+
onViewportCacheReuse(viewportInfo) {
|
|
10280
|
+
if (!sheetHeaderViewportKeys.includes(viewportInfo.viewportKey)) super.onViewportCacheReuse(viewportInfo);
|
|
10281
|
+
}
|
|
9338
10282
|
constructor(oKey, spreadsheetSkeleton, _allowCache = true) {
|
|
9339
10283
|
super(oKey, spreadsheetSkeleton);
|
|
9340
10284
|
this._allowCache = _allowCache;
|
|
10285
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === Spreadsheet);
|
|
9341
10286
|
_defineProperty(this, "_scrollBufferCanvases", /* @__PURE__ */ new Map());
|
|
10287
|
+
_defineProperty(this, "_scrollCacheStates", /* @__PURE__ */ new Map());
|
|
10288
|
+
_defineProperty(this, "_gridlineCache", new RenderPrimitiveCache());
|
|
9342
10289
|
_defineProperty(this, "_backgroundExtension", void 0);
|
|
9343
10290
|
_defineProperty(this, "_borderExtension", void 0);
|
|
9344
10291
|
_defineProperty(this, "_fontExtension", void 0);
|
|
@@ -9350,6 +10297,7 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9350
10297
|
pageMarginTop: 0
|
|
9351
10298
|
}));
|
|
9352
10299
|
_defineProperty(this, "isPrinting", false);
|
|
10300
|
+
this.disposeWithMe(this._gridlineCache);
|
|
9353
10301
|
this._initialDefaultExtension();
|
|
9354
10302
|
this.makeDirty(true);
|
|
9355
10303
|
}
|
|
@@ -9377,6 +10325,7 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9377
10325
|
(_this$_documents = this._documents) === null || _this$_documents === void 0 || _this$_documents.dispose();
|
|
9378
10326
|
this._scrollBufferCanvases.forEach((canvas) => canvas.dispose());
|
|
9379
10327
|
this._scrollBufferCanvases.clear();
|
|
10328
|
+
this._scrollCacheStates.clear();
|
|
9380
10329
|
this._documents = null;
|
|
9381
10330
|
this._backgroundExtension = null;
|
|
9382
10331
|
this._borderExtension = null;
|
|
@@ -9387,13 +10336,13 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9387
10336
|
* @param ctx
|
|
9388
10337
|
* @param viewportInfo
|
|
9389
10338
|
*/
|
|
9390
|
-
draw(ctx, viewportInfo, isMergeRepair = false) {
|
|
9391
|
-
var _viewportInfo$diffBou;
|
|
10339
|
+
draw(ctx, viewportInfo, isMergeRepair = false, textClipBound) {
|
|
10340
|
+
var _viewportInfo$diffBou, _ref, _scene$getViewport;
|
|
9392
10341
|
const spreadsheetSkeleton = this.getSkeleton();
|
|
9393
10342
|
if (!spreadsheetSkeleton) return;
|
|
9394
10343
|
const hasMergeData = spreadsheetSkeleton.worksheet.getMergeData().length > 0;
|
|
9395
10344
|
const parentScale = this.getParentScale();
|
|
9396
|
-
const diffRanges = this._refreshIncrementalState && viewportInfo.diffBounds ? (_viewportInfo$diffBou = viewportInfo.diffBounds) === null || _viewportInfo$diffBou === void 0 ? void 0 : _viewportInfo$diffBou.map((bound) => spreadsheetSkeleton.getRangeByViewBound(bound)) : [];
|
|
10345
|
+
const diffRanges = this._refreshIncrementalState && viewportInfo.diffBounds ? (_viewportInfo$diffBou = viewportInfo.diffBounds) === null || _viewportInfo$diffBou === void 0 ? void 0 : _viewportInfo$diffBou.map((bound) => spreadsheetSkeleton.getRangeByViewBound(getOutwardRoundedBound(bound))) : [];
|
|
9397
10346
|
const cacheRange = spreadsheetSkeleton.getCacheRangeByViewport(viewportInfo, this.isPrinting);
|
|
9398
10347
|
const viewRanges = this._refreshIncrementalState && diffRanges.length > 0 ? diffRanges : [cacheRange];
|
|
9399
10348
|
const overflowSafeViewRanges = this._refreshIncrementalState && diffRanges.length > 0 ? diffRanges.map((range) => ({
|
|
@@ -9401,10 +10350,11 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9401
10350
|
startColumn: cacheRange.startColumn,
|
|
9402
10351
|
endColumn: cacheRange.endColumn
|
|
9403
10352
|
})) : viewRanges;
|
|
10353
|
+
const borderViewRanges = this._refreshIncrementalState && diffRanges.length > 0 ? this._getBorderRenderRanges(spreadsheetSkeleton, viewportInfo, overflowSafeViewRanges, hasMergeData, cacheRange) : viewRanges;
|
|
9404
10354
|
const extensions = this.getExtensionsByOrder();
|
|
9405
10355
|
const backgroundExtensions = extensions.filter((extension) => extension.type === 0);
|
|
9406
10356
|
const gridExtensions = extensions.filter((extension) => extension.type !== 0);
|
|
9407
|
-
const sparseExtensionFeatures =
|
|
10357
|
+
const sparseExtensionFeatures = hasSparseExtension(gridExtensions) ? scanSparseExtensionFeatures(spreadsheetSkeleton, viewRanges, isMergeRepair) : null;
|
|
9408
10358
|
const scene = this.getScene();
|
|
9409
10359
|
const drawBackgroundExtensions = (backgroundDiffRanges, backgroundViewRanges) => {
|
|
9410
10360
|
for (const extension of backgroundExtensions) {
|
|
@@ -9423,13 +10373,18 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9423
10373
|
}
|
|
9424
10374
|
};
|
|
9425
10375
|
drawBackgroundExtensions(diffRanges, viewRanges);
|
|
9426
|
-
this.
|
|
9427
|
-
|
|
10376
|
+
const repairNativeGridlines = !!ctx._context && ctx.__mode !== "printing" && ctx.getSystemType() === "Linux" && this.allowCache && ctx._context.canvas === ((_ref = (scene === null || scene === void 0 || (_scene$getViewport = scene.getViewport(viewportInfo.viewportKey)) === null || _scene$getViewport === void 0 ? void 0 : _scene$getViewport.canvas) ?? viewportInfo.cacheCanvas) === null || _ref === void 0 ? void 0 : _ref.getCanvasEle());
|
|
10377
|
+
this._gridlineCache.draw(ctx, () => {
|
|
10378
|
+
this._drawAuxiliary(ctx, hasMergeData, (clearedRanges) => {
|
|
10379
|
+
drawBackgroundExtensions(clearedRanges, clearedRanges);
|
|
10380
|
+
}, repairNativeGridlines, textClipBound);
|
|
9428
10381
|
});
|
|
9429
10382
|
for (const extension of gridExtensions) {
|
|
9430
10383
|
if (shouldSkipSparseExtension(extension.uKey, sparseExtensionFeatures)) continue;
|
|
9431
|
-
|
|
9432
|
-
|
|
10384
|
+
let extensionViewRanges = viewRanges;
|
|
10385
|
+
if (extension === this._fontExtension) extensionViewRanges = overflowSafeViewRanges;
|
|
10386
|
+
else if (extension === this._borderExtension) extensionViewRanges = borderViewRanges;
|
|
10387
|
+
const extensionDiffRanges = extension === this._borderExtension && diffRanges.length ? borderViewRanges : getSparseExtensionDiffRanges(extension.uKey, sparseExtensionFeatures, diffRanges);
|
|
9433
10388
|
const timeKey = `${SHEET_EXTENSION_PREFIX}${extension.uKey}`;
|
|
9434
10389
|
const st = Tools.now();
|
|
9435
10390
|
extension.draw(ctx, parentScale, spreadsheetSkeleton, extensionDiffRanges, {
|
|
@@ -9438,12 +10393,36 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9438
10393
|
hasMergeData,
|
|
9439
10394
|
viewportKey: viewportInfo.viewportKey,
|
|
9440
10395
|
viewBound: viewportInfo.cacheBound,
|
|
9441
|
-
diffBounds: viewportInfo.diffBounds
|
|
10396
|
+
diffBounds: viewportInfo.diffBounds,
|
|
10397
|
+
textClipBound
|
|
9442
10398
|
});
|
|
9443
10399
|
const cost = Tools.now() - st;
|
|
9444
10400
|
this.addRenderFrameTimeMetricToScene(timeKey, cost, scene);
|
|
9445
10401
|
}
|
|
9446
10402
|
}
|
|
10403
|
+
_getBorderRenderRanges(skeleton, viewportInfo, overflowSafeRanges, hasMergeData, cacheRange) {
|
|
10404
|
+
if (this.isPrinting) return overflowSafeRanges;
|
|
10405
|
+
const ranges = viewportInfo.diffBounds.map((bound) => skeleton.getRangeByViewBound(getOutwardRoundedBound({
|
|
10406
|
+
left: bound.left - BORDER_INK_HALO,
|
|
10407
|
+
top: bound.top - BORDER_INK_HALO,
|
|
10408
|
+
right: bound.right + BORDER_INK_HALO,
|
|
10409
|
+
bottom: bound.bottom + BORDER_INK_HALO
|
|
10410
|
+
})));
|
|
10411
|
+
if (hasMergeData) for (const range of ranges) {
|
|
10412
|
+
const merges = skeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn);
|
|
10413
|
+
for (const merge of merges) {
|
|
10414
|
+
var _skeleton$stylesCache;
|
|
10415
|
+
const border = (_skeleton$stylesCache = skeleton.stylesCache.border) === null || _skeleton$stylesCache === void 0 ? void 0 : _skeleton$stylesCache.getValue(merge.startRow, merge.startColumn);
|
|
10416
|
+
if (border && Object.keys(border).some((key) => !BORDER_EDGE_KEYS.has(key))) return overflowSafeRanges;
|
|
10417
|
+
}
|
|
10418
|
+
}
|
|
10419
|
+
return ranges.map((range) => ({
|
|
10420
|
+
startRow: Math.max(range.startRow, cacheRange.startRow),
|
|
10421
|
+
endRow: Math.min(range.endRow, cacheRange.endRow),
|
|
10422
|
+
startColumn: Math.max(range.startColumn, cacheRange.startColumn),
|
|
10423
|
+
endColumn: Math.min(range.endColumn, cacheRange.endColumn)
|
|
10424
|
+
})).filter((range) => range.startRow <= range.endRow && range.startColumn <= range.endColumn);
|
|
10425
|
+
}
|
|
9447
10426
|
addRenderFrameTimeMetricToScene(timeKey, val, scene) {
|
|
9448
10427
|
scene = scene ?? this.getScene();
|
|
9449
10428
|
scene.getEngine().renderFrameTimeMetric$.next([timeKey, val]);
|
|
@@ -9530,7 +10509,52 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9530
10509
|
setDirtyArea(dirtyBounds) {
|
|
9531
10510
|
this._dirtyBounds = dirtyBounds;
|
|
9532
10511
|
}
|
|
9533
|
-
renderByViewports(mainCtx,
|
|
10512
|
+
renderByViewports(mainCtx, inputViewportInfo, spreadsheetSkeleton) {
|
|
10513
|
+
let viewportInfo = inputViewportInfo;
|
|
10514
|
+
if (viewportInfo.viewportKey === "viewMainLeftTop" && mainCtx.__mode !== "printing" && mainCtx._context && mainCtx.getSystemType() === "Linux" && mainCtx.getBrowserType() === "Safari" && this._hasFractionalViewportPixels(viewportInfo)) {
|
|
10515
|
+
this._scrollCacheStates.set(viewportInfo.viewportKey, null);
|
|
10516
|
+
this.draw(mainCtx, viewportInfo);
|
|
10517
|
+
return;
|
|
10518
|
+
}
|
|
10519
|
+
const cacheState = this._getScrollCacheState(mainCtx, viewportInfo);
|
|
10520
|
+
const previousState = this._getReusableScrollCacheState(mainCtx, viewportInfo);
|
|
10521
|
+
if (previousState) {
|
|
10522
|
+
const diffX = (cacheState.left - previousState.left) / cacheState.scaleX;
|
|
10523
|
+
const diffY = (cacheState.top - previousState.top) / cacheState.scaleY;
|
|
10524
|
+
const { viewBound } = viewportInfo;
|
|
10525
|
+
const diffBounds = [...viewportInfo.diffBounds];
|
|
10526
|
+
if (!diffBounds.length) {
|
|
10527
|
+
if (diffX) {
|
|
10528
|
+
const left = diffX < 0 ? viewBound.right + diffX : viewBound.left;
|
|
10529
|
+
diffBounds.push({
|
|
10530
|
+
...viewBound,
|
|
10531
|
+
left,
|
|
10532
|
+
right: left + Math.abs(diffX)
|
|
10533
|
+
});
|
|
10534
|
+
}
|
|
10535
|
+
if (diffY) {
|
|
10536
|
+
const top = diffY < 0 ? viewBound.bottom + diffY : viewBound.top;
|
|
10537
|
+
diffBounds.push({
|
|
10538
|
+
...viewBound,
|
|
10539
|
+
top,
|
|
10540
|
+
bottom: top + Math.abs(diffY)
|
|
10541
|
+
});
|
|
10542
|
+
}
|
|
10543
|
+
}
|
|
10544
|
+
const expand = (bound) => ({
|
|
10545
|
+
left: bound.left - 1 / cacheState.scaleX,
|
|
10546
|
+
right: bound.right + 1 / cacheState.scaleX,
|
|
10547
|
+
top: bound.top - 1 / cacheState.scaleY,
|
|
10548
|
+
bottom: bound.bottom + 1 / cacheState.scaleY
|
|
10549
|
+
});
|
|
10550
|
+
viewportInfo = {
|
|
10551
|
+
...viewportInfo,
|
|
10552
|
+
diffX,
|
|
10553
|
+
diffY,
|
|
10554
|
+
diffBounds: diffBounds.map(expand),
|
|
10555
|
+
diffCacheBounds: viewportInfo.diffCacheBounds.map(expand)
|
|
10556
|
+
};
|
|
10557
|
+
}
|
|
9534
10558
|
const { diffBounds, diffX, diffY, viewPortPosition, cacheCanvas, leftOrigin, topOrigin, bufferEdgeX, bufferEdgeY, isDirty: isViewportDirty, isForceDirty: isViewportForceDirty, shouldCacheUpdate } = viewportInfo;
|
|
9535
10559
|
const { rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = spreadsheetSkeleton;
|
|
9536
10560
|
const { a: scaleX = 1, d: scaleY = 1 } = mainCtx.getTransform();
|
|
@@ -9546,9 +10570,14 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9546
10570
|
const hasMergeData = spreadsheetSkeleton.worksheet.getMergeData().length > 0;
|
|
9547
10571
|
const isScrolling = diffX !== 0 || diffY !== 0;
|
|
9548
10572
|
const mergeRepairBounds = this._getMergeRepairBounds(spreadsheetSkeleton, viewportInfo, hasMergeData, isScrolling);
|
|
9549
|
-
const repaintBounds = this._getRepaintBounds(viewportInfo, mergeRepairBounds);
|
|
10573
|
+
const repaintBounds = this._getRepaintBounds(viewportInfo, mergeRepairBounds, mainCtx);
|
|
9550
10574
|
const shouldRefreshForMergeRepairArea = exceedsMergeRepairThreshold(viewportInfo.cacheBound, repaintBounds, mergeRepairBounds.length > 0);
|
|
9551
|
-
const
|
|
10575
|
+
const shouldRefreshForHorizontalResampling = this._requiresHorizontalResampling(mainCtx, viewportInfo);
|
|
10576
|
+
const shouldRefreshForFrozenEdge = viewportInfo.viewportKey === "viewMainLeft" && diffY !== 0 && this._hasFractionalViewportPixels(viewportInfo) || this._requiresNativeFrozenEdgeRepaint(mainCtx, viewportInfo, repaintBounds);
|
|
10577
|
+
const shouldRefreshForNativeGridlines = isScrolling && this._requiresNativeGridlineRepaint(mainCtx, spreadsheetSkeleton, viewportInfo, hasMergeData);
|
|
10578
|
+
const shouldRefreshForGapStripes = isScrolling && this._requiresGapStripeRepaint(spreadsheetSkeleton, viewportInfo);
|
|
10579
|
+
const incompatibleCache = this._scrollCacheStates.has(viewportInfo.viewportKey) && !previousState;
|
|
10580
|
+
const shouldRefreshCache = isDirty || isForceDirty || incompatibleCache || isScrollJumpOutsideCache || shouldRefreshForMergeRepairArea || shouldRefreshForHorizontalResampling || shouldRefreshForFrozenEdge || shouldRefreshForNativeGridlines || shouldRefreshForGapStripes || shouldCacheUpdate && diffX !== 0 && !this._canPaintHorizontalScrollIncrementally(mainCtx, viewportInfo);
|
|
9552
10581
|
if (diffBounds.length === 0 || diffX === 0 && diffY === 0 || shouldRefreshCache) {
|
|
9553
10582
|
if (shouldRefreshCache) {
|
|
9554
10583
|
this.addRenderTagToScene("scrolling", false);
|
|
@@ -9576,7 +10605,7 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9576
10605
|
scaleY,
|
|
9577
10606
|
columnHeaderHeightAndMarginTop,
|
|
9578
10607
|
rowHeaderWidthAndMarginLeft
|
|
9579
|
-
}, mergeRepairBounds);
|
|
10608
|
+
}, mergeRepairBounds, repaintBounds);
|
|
9580
10609
|
cacheCtx.restore();
|
|
9581
10610
|
cacheCtx = renderCacheCanvas.getContext();
|
|
9582
10611
|
cacheCtx.save();
|
|
@@ -9588,6 +10617,10 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9588
10617
|
const dh = bottom - top + columnHeaderHeightAndMarginTop;
|
|
9589
10618
|
this._applyCache(renderCacheCanvas, mainCtx, sourceLeft, sourceTop, dw, dh, left, top, dw, dh);
|
|
9590
10619
|
cacheCtx.restore();
|
|
10620
|
+
this._scrollCacheStates.set(viewportInfo.viewportKey, {
|
|
10621
|
+
...cacheState,
|
|
10622
|
+
canvas: renderCacheCanvas
|
|
10623
|
+
});
|
|
9591
10624
|
}
|
|
9592
10625
|
_getMergeRepairBounds(spreadsheetSkeleton, viewportInfo, hasMergeData, isScrolling) {
|
|
9593
10626
|
if (!hasMergeData || !isScrolling) return [];
|
|
@@ -9596,7 +10629,7 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9596
10629
|
const mergeBounds = [];
|
|
9597
10630
|
const visited = /* @__PURE__ */ new Set();
|
|
9598
10631
|
for (const dirtyBound of dirtyBounds) {
|
|
9599
|
-
const range = spreadsheetSkeleton.getRangeByViewBound(dirtyBound);
|
|
10632
|
+
const range = spreadsheetSkeleton.getRangeByViewBound(getOutwardRoundedBound(dirtyBound));
|
|
9600
10633
|
const mergeRanges = spreadsheetSkeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn);
|
|
9601
10634
|
for (const mergeRange of mergeRanges) {
|
|
9602
10635
|
const key = `${mergeRange.startRow}:${mergeRange.startColumn}`;
|
|
@@ -9612,61 +10645,254 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9612
10645
|
}
|
|
9613
10646
|
return mergeBounds;
|
|
9614
10647
|
}
|
|
9615
|
-
_getRepaintBounds(viewportInfo, mergeRepairBounds) {
|
|
9616
|
-
const
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
10648
|
+
_getRepaintBounds(viewportInfo, mergeRepairBounds, mainCtx) {
|
|
10649
|
+
const transform = mainCtx.getTransform();
|
|
10650
|
+
if (!this._getReusableScrollCacheState(mainCtx, viewportInfo) && mergeRepairBounds.length && (!Number.isInteger(viewportInfo.diffX * transform.a) || !Number.isInteger(viewportInfo.diffY * transform.d))) {
|
|
10651
|
+
const repaintBounds = viewportInfo.shouldCacheUpdate ? viewportInfo.diffCacheBounds.map((bound) => ({
|
|
10652
|
+
bound: { ...bound },
|
|
10653
|
+
repairsMerge: false
|
|
10654
|
+
})) : [];
|
|
10655
|
+
for (const mergeBound of mergeRepairBounds) {
|
|
10656
|
+
const overlapping = repaintBounds.find(({ bound }) => boundsOverlap(bound, mergeBound));
|
|
10657
|
+
if (overlapping) {
|
|
10658
|
+
overlapping.bound.left = Math.min(overlapping.bound.left, mergeBound.left);
|
|
10659
|
+
overlapping.bound.top = Math.min(overlapping.bound.top, mergeBound.top);
|
|
10660
|
+
overlapping.bound.right = Math.max(overlapping.bound.right, mergeBound.right);
|
|
10661
|
+
overlapping.bound.bottom = Math.max(overlapping.bound.bottom, mergeBound.bottom);
|
|
10662
|
+
overlapping.repairsMerge = true;
|
|
10663
|
+
} else repaintBounds.push({
|
|
10664
|
+
bound: { ...mergeBound },
|
|
10665
|
+
repairsMerge: true
|
|
10666
|
+
});
|
|
10667
|
+
}
|
|
10668
|
+
return repaintBounds;
|
|
10669
|
+
}
|
|
10670
|
+
const repaintBounds = [];
|
|
10671
|
+
const dirtyBounds = viewportInfo.shouldCacheUpdate ? viewportInfo.diffCacheBounds : viewportInfo.diffBounds;
|
|
10672
|
+
for (const dirtyBound of dirtyBounds) {
|
|
10673
|
+
const clipped = getIntersectBound(dirtyBound, viewportInfo.cacheBound);
|
|
10674
|
+
if (!clipped) continue;
|
|
10675
|
+
if (viewportInfo.shouldCacheUpdate) repaintBounds.push({
|
|
10676
|
+
bound: clipped,
|
|
10677
|
+
repairsMerge: mergeRepairBounds.some((mergeBound) => getIntersectBound(clipped, mergeBound))
|
|
10678
|
+
});
|
|
10679
|
+
else for (const mergeBound of mergeRepairBounds) {
|
|
10680
|
+
const intersection = getIntersectBound(clipped, mergeBound);
|
|
10681
|
+
if (intersection) repaintBounds.push({
|
|
10682
|
+
bound: intersection,
|
|
10683
|
+
repairsMerge: true
|
|
10684
|
+
});
|
|
10685
|
+
}
|
|
10686
|
+
}
|
|
10687
|
+
return this._addNativeTextClipRepairBounds(repaintBounds, viewportInfo, mainCtx);
|
|
10688
|
+
}
|
|
10689
|
+
_addNativeTextClipRepairBounds(repaintBounds, viewportInfo, mainCtx) {
|
|
10690
|
+
if (!repaintBounds.length) return repaintBounds;
|
|
10691
|
+
const previous = this._getReusableScrollCacheState(mainCtx, viewportInfo);
|
|
10692
|
+
const skeleton = this.getSkeleton();
|
|
10693
|
+
if (!previous || !skeleton || !viewportInfo.diffX && !viewportInfo.diffY) return repaintBounds;
|
|
10694
|
+
const current = this._getScrollCacheState(mainCtx, viewportInfo);
|
|
10695
|
+
const columns = skeleton.columnWidthAccumulation;
|
|
10696
|
+
const rows = skeleton.rowHeightAccumulation;
|
|
10697
|
+
const headerX = skeleton.rowHeaderWidthAndMarginLeft;
|
|
10698
|
+
const headerY = skeleton.columnHeaderHeightAndMarginTop;
|
|
10699
|
+
const bounds = [];
|
|
10700
|
+
const addBound = (bound, repairsMerge, repairsNativeText = false) => {
|
|
10701
|
+
const clipped = getIntersectBound(bound, viewportInfo.cacheBound);
|
|
10702
|
+
if (clipped) appendRepaintBound(bounds, {
|
|
10703
|
+
bound: clipped,
|
|
10704
|
+
repairsMerge,
|
|
10705
|
+
repairsNativeText
|
|
9631
10706
|
});
|
|
10707
|
+
};
|
|
10708
|
+
const getBound = (range) => ({
|
|
10709
|
+
left: (columns[range.startColumn - 1] ?? 0) + headerX - SCROLL_REPAIR_INK_HALO / current.scaleX,
|
|
10710
|
+
right: columns[range.endColumn] + headerX + SCROLL_REPAIR_INK_HALO / current.scaleX,
|
|
10711
|
+
top: (rows[range.startRow - 1] ?? 0) + headerY - SCROLL_REPAIR_INK_HALO / current.scaleY,
|
|
10712
|
+
bottom: rows[range.endRow] + headerY + SCROLL_REPAIR_INK_HALO / current.scaleY
|
|
10713
|
+
});
|
|
10714
|
+
const addRange = (range) => {
|
|
10715
|
+
addBound(getBound(range), false, true);
|
|
10716
|
+
for (const merge of skeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn)) addBound(getBound(merge), true, true);
|
|
10717
|
+
for (let row = range.startRow; row <= range.endRow; row++) {
|
|
10718
|
+
const values = skeleton.overflowCache.getRow(row);
|
|
10719
|
+
for (const column in values) {
|
|
10720
|
+
const overflow = values[Number(column)];
|
|
10721
|
+
if (overflow.startColumn <= range.endColumn && overflow.endColumn >= range.startColumn) addBound(getBound({
|
|
10722
|
+
startRow: row,
|
|
10723
|
+
endRow: row,
|
|
10724
|
+
startColumn: Math.min(Number(column), overflow.startColumn),
|
|
10725
|
+
endColumn: Math.max(Number(column), overflow.endColumn)
|
|
10726
|
+
}), false, true);
|
|
10727
|
+
}
|
|
10728
|
+
}
|
|
10729
|
+
};
|
|
10730
|
+
for (const { bound, repairsMerge } of repaintBounds) addBound(bound, repairsMerge);
|
|
10731
|
+
const nativeClipRanges = this._fontExtension.getNativeTextClipRepairRanges(skeleton).map((range) => ({
|
|
10732
|
+
range,
|
|
10733
|
+
bound: getIntersectBound(getBound(range), viewportInfo.cacheBound)
|
|
10734
|
+
}));
|
|
10735
|
+
let expanded = true;
|
|
10736
|
+
while (expanded) {
|
|
10737
|
+
expanded = false;
|
|
10738
|
+
for (const { range, bound } of nativeClipRanges) {
|
|
10739
|
+
if (!bound || !bounds.some((item) => getIntersectBound(item.bound, bound)) || bounds.some((item) => item.bound.left <= bound.left && item.bound.right >= bound.right && item.bound.top <= bound.top && item.bound.bottom >= bound.bottom)) continue;
|
|
10740
|
+
addRange(range);
|
|
10741
|
+
expanded = true;
|
|
10742
|
+
}
|
|
9632
10743
|
}
|
|
9633
|
-
return
|
|
10744
|
+
return bounds;
|
|
10745
|
+
}
|
|
10746
|
+
_requiresNativeFrozenEdgeRepaint(mainCtx, viewportInfo, repaintBounds) {
|
|
10747
|
+
const vertical = viewportInfo.viewportKey === "viewMainLeft" && viewportInfo.diffY !== 0;
|
|
10748
|
+
const horizontal = viewportInfo.viewportKey === "viewMainTop" && viewportInfo.diffX !== 0;
|
|
10749
|
+
if (!mainCtx._context || !vertical && !horizontal) return false;
|
|
10750
|
+
const { a, d } = mainCtx.getTransform();
|
|
10751
|
+
const cache = viewportInfo.cacheBound;
|
|
10752
|
+
return repaintBounds.some(({ bound, repairsNativeText }) => repairsNativeText && (vertical && (bound.left <= cache.left + SCROLL_REPAIR_INK_HALO / a || bound.right >= cache.right - SCROLL_REPAIR_INK_HALO / a) || horizontal && (bound.top <= cache.top + SCROLL_REPAIR_INK_HALO / d || bound.bottom >= cache.bottom - SCROLL_REPAIR_INK_HALO / d)));
|
|
9634
10753
|
}
|
|
9635
|
-
|
|
10754
|
+
_requiresGapStripeRepaint(skeleton, viewportInfo) {
|
|
10755
|
+
const { rowGaps, colGaps } = skeleton.gapConfig ?? {};
|
|
10756
|
+
const { diffX, diffY } = viewportInfo;
|
|
10757
|
+
if ((!diffX || !rowGaps) && (!diffY || !colGaps)) return false;
|
|
10758
|
+
const range = skeleton.getCacheRangeByViewport(viewportInfo);
|
|
10759
|
+
return diffX !== 0 && Object.entries(rowGaps ?? {}).some(([row, gap]) => gap.size > 0 && Number(row) >= range.startRow && Number(row) <= range.endRow) || diffY !== 0 && Object.entries(colGaps ?? {}).some(([col, gap]) => gap.size > 0 && Number(col) >= range.startColumn && Number(col) <= range.endColumn);
|
|
10760
|
+
}
|
|
10761
|
+
_requiresNativeGridlineRepaint(ctx, skeleton, viewportInfo, hasMergeData) {
|
|
10762
|
+
if (!ctx._context || ctx.getSystemType() !== "Linux" || this._forceDisableGridlines || skeleton.showGridlines === BooleanNumber.FALSE) return false;
|
|
10763
|
+
const { a, d } = ctx.getTransform();
|
|
10764
|
+
if (Number.isInteger(a) && Number.isInteger(d)) return false;
|
|
10765
|
+
const range = skeleton.getRangeByViewBound(getOutwardRoundedBound(viewportInfo.cacheBound));
|
|
10766
|
+
if (hasMergeData && skeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn).length) return true;
|
|
10767
|
+
for (let row = range.startRow; row <= range.endRow; row++) {
|
|
10768
|
+
const values = skeleton.overflowCache.getRow(row);
|
|
10769
|
+
if (!values) continue;
|
|
10770
|
+
for (const column in values) {
|
|
10771
|
+
const overflow = values[column];
|
|
10772
|
+
if (overflow.startColumn <= range.endColumn && overflow.endColumn >= range.startColumn) return true;
|
|
10773
|
+
}
|
|
10774
|
+
}
|
|
10775
|
+
return false;
|
|
10776
|
+
}
|
|
10777
|
+
_requiresHorizontalResampling(mainCtx, viewportInfo) {
|
|
10778
|
+
const hasFractionalHorizontalEdge = viewportInfo.diffX !== 0 && this._hasFractionalViewportPixels(viewportInfo);
|
|
10779
|
+
if (hasFractionalHorizontalEdge && (viewportInfo.diffY !== 0 || viewportInfo.viewportKey === "viewMainTop")) return true;
|
|
10780
|
+
if (this._getReusableScrollCacheState(mainCtx, viewportInfo)) return false;
|
|
10781
|
+
if (hasFractionalHorizontalEdge) return true;
|
|
10782
|
+
const transform = mainCtx.getTransform();
|
|
10783
|
+
return viewportInfo.diffX !== 0 && (!Number.isInteger(viewportInfo.diffX * transform.a) || !Number.isInteger(viewportInfo.diffY * transform.d) || !Number.isInteger(transform.e) || !Number.isInteger(transform.f));
|
|
10784
|
+
}
|
|
10785
|
+
_hasFractionalViewportPixels(viewportInfo) {
|
|
10786
|
+
const pixelRatio = viewportInfo.cacheCanvas.getPixelRatio();
|
|
10787
|
+
return Object.values(viewportInfo.viewPortPosition).some((value) => Math.abs(value * pixelRatio - Math.round(value * pixelRatio)) > 1e-6);
|
|
10788
|
+
}
|
|
10789
|
+
_getScrollCacheState(mainCtx, viewportInfo) {
|
|
10790
|
+
const { a, b, c, d, e, f } = mainCtx.getTransform();
|
|
10791
|
+
const canvas = viewportInfo.cacheCanvas;
|
|
10792
|
+
return {
|
|
10793
|
+
canvas,
|
|
10794
|
+
width: canvas.getWidth(),
|
|
10795
|
+
height: canvas.getHeight(),
|
|
10796
|
+
pixelRatio: canvas.getPixelRatio(),
|
|
10797
|
+
scaleX: a,
|
|
10798
|
+
scaleY: d,
|
|
10799
|
+
left: Math.round((e / a - viewportInfo.leftOrigin + viewportInfo.bufferEdgeX) * a),
|
|
10800
|
+
top: Math.round((f / d - viewportInfo.topOrigin + viewportInfo.bufferEdgeY) * d),
|
|
10801
|
+
axisAligned: a > 0 && d > 0 && b === 0 && c === 0,
|
|
10802
|
+
viewportLeft: viewportInfo.viewPortPosition.left,
|
|
10803
|
+
viewportTop: viewportInfo.viewPortPosition.top,
|
|
10804
|
+
viewportRight: viewportInfo.viewPortPosition.right,
|
|
10805
|
+
viewportBottom: viewportInfo.viewPortPosition.bottom
|
|
10806
|
+
};
|
|
10807
|
+
}
|
|
10808
|
+
_getReusableScrollCacheState(mainCtx, viewportInfo) {
|
|
10809
|
+
const previous = this._scrollCacheStates.get(viewportInfo.viewportKey);
|
|
10810
|
+
const canvas = viewportInfo.cacheCanvas;
|
|
10811
|
+
const { a, b, c, d } = mainCtx.getTransform();
|
|
10812
|
+
if (!((previous === null || previous === void 0 ? void 0 : previous.axisAligned) && canvas === previous.canvas && a > 0 && d > 0 && b === 0 && c === 0 && a === previous.scaleX && d === previous.scaleY && canvas.getWidth() === previous.width && canvas.getHeight() === previous.height && canvas.getPixelRatio() === previous.pixelRatio && viewportInfo.viewPortPosition.left === previous.viewportLeft && viewportInfo.viewPortPosition.top === previous.viewportTop && viewportInfo.viewPortPosition.right === previous.viewportRight && viewportInfo.viewPortPosition.bottom === previous.viewportBottom)) return;
|
|
10813
|
+
const current = this._getScrollCacheState(mainCtx, viewportInfo);
|
|
10814
|
+
const sceneScale = this.getScene().getAncestorScale();
|
|
10815
|
+
const logicalScaleX = sceneScale.scaleX * canvas.getPixelRatio();
|
|
10816
|
+
const logicalScaleY = sceneScale.scaleY * canvas.getPixelRatio();
|
|
10817
|
+
const displacementScaleX = a === Math.fround(logicalScaleX) ? logicalScaleX : a;
|
|
10818
|
+
const displacementScaleY = d === Math.fround(logicalScaleY) ? logicalScaleY : d;
|
|
10819
|
+
return Math.abs(current.left - previous.left - viewportInfo.diffX * displacementScaleX) <= 1 + 1e-6 && Math.abs(current.top - previous.top - viewportInfo.diffY * displacementScaleY) <= 1 + 1e-6 ? previous : void 0;
|
|
10820
|
+
}
|
|
10821
|
+
_canPaintHorizontalScrollIncrementally(mainCtx, viewportInfo) {
|
|
9636
10822
|
var _this$_getAncestorPar;
|
|
10823
|
+
const cacheCanvas = viewportInfo.cacheCanvas;
|
|
10824
|
+
const viewport = this.getScene().getViewport(viewportInfo.viewportKey);
|
|
10825
|
+
const transform = mainCtx.getTransform();
|
|
10826
|
+
return !!cacheCanvas && ((_this$_getAncestorPar = this._getAncestorParent()) === null || _this$_getAncestorPar === void 0 ? void 0 : _this$_getAncestorPar.classType) === "Engine" && (viewport === null || viewport === void 0 ? void 0 : viewport.canvas) === cacheCanvas && viewportInfo.diffBounds.length > 0 && viewportInfo.diffCacheBounds.length > 0 && transform.b === 0 && transform.c === 0 && !this._requiresHorizontalResampling(mainCtx, viewportInfo);
|
|
10827
|
+
}
|
|
10828
|
+
paintNewAreaForScrolling(viewportInfo, param, mergeRepairBounds = [], repaintBounds = this._getRepaintBounds(viewportInfo, mergeRepairBounds, param.mainCtx)) {
|
|
10829
|
+
var _this$_getAncestorPar2;
|
|
9637
10830
|
const { cacheCanvas, cacheCtx, mainCtx, topOrigin, leftOrigin, bufferEdgeX, bufferEdgeY, scaleX, scaleY, columnHeaderHeightAndMarginTop, rowHeaderWidthAndMarginLeft } = param;
|
|
9638
10831
|
const { diffX, diffY } = viewportInfo;
|
|
9639
10832
|
let renderCacheCanvas = cacheCanvas;
|
|
9640
10833
|
let renderCacheCtx = cacheCtx;
|
|
9641
10834
|
const viewport = this.getScene().getViewport(viewportInfo.viewportKey);
|
|
9642
|
-
|
|
10835
|
+
const canSwapCache = ((_this$_getAncestorPar2 = this._getAncestorParent()) === null || _this$_getAncestorPar2 === void 0 ? void 0 : _this$_getAncestorPar2.classType) === "Engine" && (viewport === null || viewport === void 0 ? void 0 : viewport.canvas) === cacheCanvas && mainCtx.getBrowserType() !== "Safari" && !Tools.isIPhone();
|
|
10836
|
+
const previousState = this._getReusableScrollCacheState(mainCtx, viewportInfo);
|
|
10837
|
+
const cacheState = this._getScrollCacheState(mainCtx, viewportInfo);
|
|
10838
|
+
const offsetX = previousState ? cacheState.left - previousState.left : diffX * scaleX;
|
|
10839
|
+
const offsetY = previousState ? cacheState.top - previousState.top : diffY * scaleY;
|
|
10840
|
+
if (canSwapCache) {
|
|
9643
10841
|
renderCacheCanvas = this._getScrollBufferCanvas(viewportInfo.viewportKey, cacheCanvas);
|
|
9644
10842
|
renderCacheCtx = renderCacheCanvas.getContext();
|
|
9645
|
-
this._copyCacheForScrolling(renderCacheCtx, cacheCanvas,
|
|
10843
|
+
this._copyCacheForScrolling(renderCacheCtx, cacheCanvas, offsetX, offsetY);
|
|
9646
10844
|
const previousBufferCanvas = viewport.swapCacheCanvas(renderCacheCanvas);
|
|
9647
10845
|
if (previousBufferCanvas) this._scrollBufferCanvases.set(viewportInfo.viewportKey, previousBufferCanvas);
|
|
9648
|
-
} else this._copyCacheForScrolling(cacheCtx, cacheCanvas,
|
|
10846
|
+
} else this._copyCacheForScrolling(cacheCtx, cacheCanvas, offsetX, offsetY);
|
|
9649
10847
|
this._refreshIncrementalState = true;
|
|
9650
10848
|
const m = mainCtx.getTransform();
|
|
9651
|
-
renderCacheCtx.setTransform(m.a,
|
|
9652
|
-
|
|
9653
|
-
|
|
10849
|
+
if (cacheState.axisAligned) renderCacheCtx.setTransform(m.a, 0, 0, m.d, cacheState.left, cacheState.top);
|
|
10850
|
+
else {
|
|
10851
|
+
renderCacheCtx.setTransform(m.a, m.b, m.c, m.d, 0, 0);
|
|
10852
|
+
renderCacheCtx.translateWithPrecision(m.e / m.a - leftOrigin + bufferEdgeX, m.f / m.d - topOrigin + bufferEdgeY);
|
|
10853
|
+
}
|
|
9654
10854
|
if (repaintBounds.length) for (const { bound: diffBound, repairsMerge } of repaintBounds) {
|
|
9655
10855
|
const { left: diffLeft, right: diffRight, bottom: diffBottom, top: diffTop } = diffBound;
|
|
9656
10856
|
const x = diffLeft - rowHeaderWidthAndMarginLeft;
|
|
9657
10857
|
const y = diffTop - columnHeaderHeightAndMarginTop;
|
|
9658
10858
|
const w = diffRight - diffLeft;
|
|
9659
10859
|
const h = diffBottom - diffTop;
|
|
9660
|
-
|
|
10860
|
+
let renderBound = diffBound;
|
|
10861
|
+
let textClipBound;
|
|
9661
10862
|
renderCacheCtx.save();
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
10863
|
+
if (cacheState.axisAligned) {
|
|
10864
|
+
const left = Math.round(x * m.a) + cacheState.left;
|
|
10865
|
+
const top = Math.round(y * m.d) + cacheState.top;
|
|
10866
|
+
const width = Math.round((x + w) * m.a) + cacheState.left - left;
|
|
10867
|
+
const height = Math.round((y + h) * m.d) + cacheState.top - top;
|
|
10868
|
+
textClipBound = {
|
|
10869
|
+
left,
|
|
10870
|
+
top,
|
|
10871
|
+
right: left + width,
|
|
10872
|
+
bottom: top + height
|
|
10873
|
+
};
|
|
10874
|
+
renderCacheCtx.setTransform(1, 0, 0, 1, 0, 0);
|
|
10875
|
+
renderCacheCtx.clearRect(left, top, width, height);
|
|
10876
|
+
renderCacheCtx.beginPath();
|
|
10877
|
+
renderCacheCtx.rect(left, top, width, height);
|
|
10878
|
+
renderCacheCtx.clip();
|
|
10879
|
+
renderCacheCtx.setTransform(m.a, 0, 0, m.d, cacheState.left, cacheState.top);
|
|
10880
|
+
renderBound = {
|
|
10881
|
+
left: (left - cacheState.left - SCROLL_REPAIR_INK_HALO) / m.a + rowHeaderWidthAndMarginLeft,
|
|
10882
|
+
right: (left + width - cacheState.left + SCROLL_REPAIR_INK_HALO) / m.a + rowHeaderWidthAndMarginLeft,
|
|
10883
|
+
top: (top - cacheState.top - SCROLL_REPAIR_INK_HALO) / m.d + columnHeaderHeightAndMarginTop,
|
|
10884
|
+
bottom: (top + height - cacheState.top + SCROLL_REPAIR_INK_HALO) / m.d + columnHeaderHeightAndMarginTop
|
|
10885
|
+
};
|
|
10886
|
+
} else {
|
|
10887
|
+
renderCacheCtx.clearRectByPrecision(x, y, w, h);
|
|
10888
|
+
renderCacheCtx.beginPath();
|
|
10889
|
+
renderCacheCtx.rectByPrecision(x, y, w, h);
|
|
10890
|
+
renderCacheCtx.clip();
|
|
10891
|
+
}
|
|
9666
10892
|
this.draw(renderCacheCtx, {
|
|
9667
10893
|
...viewportInfo,
|
|
9668
|
-
diffBounds: [
|
|
9669
|
-
}, repairsMerge);
|
|
10894
|
+
diffBounds: [renderBound]
|
|
10895
|
+
}, repairsMerge, textClipBound);
|
|
9670
10896
|
renderCacheCtx.restore();
|
|
9671
10897
|
}
|
|
9672
10898
|
this._refreshIncrementalState = false;
|
|
@@ -9700,13 +10926,18 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9700
10926
|
cacheCtx.restore();
|
|
9701
10927
|
cacheCtx.save();
|
|
9702
10928
|
const m = mainCtx.getTransform();
|
|
9703
|
-
|
|
9704
|
-
cacheCtx.
|
|
10929
|
+
const cacheState = this._getScrollCacheState(mainCtx, viewportInfo);
|
|
10930
|
+
if (cacheState.axisAligned) cacheCtx.setTransform(m.a, 0, 0, m.d, cacheState.left, cacheState.top);
|
|
10931
|
+
else {
|
|
10932
|
+
cacheCtx.setTransform(m.a, m.b, m.c, m.d, 0, 0);
|
|
10933
|
+
cacheCtx.translateWithPrecision(m.e / m.a - leftOrigin + bufferEdgeX, m.f / m.d - topOrigin + bufferEdgeY);
|
|
10934
|
+
}
|
|
9705
10935
|
this.draw(cacheCtx, viewportInfo);
|
|
9706
10936
|
cacheCtx.restore();
|
|
9707
10937
|
}
|
|
9708
10938
|
render(mainCtx, viewportInfo) {
|
|
9709
10939
|
var _this$getScene2;
|
|
10940
|
+
this._viewportCacheFontRevision = FontCache.metricsRevision;
|
|
9710
10941
|
if (!this.visible) {
|
|
9711
10942
|
this.makeDirty(false);
|
|
9712
10943
|
return this;
|
|
@@ -9715,7 +10946,14 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9715
10946
|
if (!spreadsheetSkeleton) return;
|
|
9716
10947
|
const { viewportKey } = viewportInfo;
|
|
9717
10948
|
if (sheetHeaderViewportKeys.includes(viewportKey)) return this;
|
|
9718
|
-
|
|
10949
|
+
if (this._canReuseStyleCache(viewportInfo)) spreadsheetSkeleton.updateVisibleRange(viewportInfo);
|
|
10950
|
+
else {
|
|
10951
|
+
const stylesViewportInfo = viewportInfo.cacheCanvas && viewportInfo.diffX && this._hasFractionalViewportPixels(viewportInfo) ? {
|
|
10952
|
+
...viewportInfo,
|
|
10953
|
+
isForceDirty: true
|
|
10954
|
+
} : viewportInfo;
|
|
10955
|
+
spreadsheetSkeleton.setStylesCache(stylesViewportInfo, { scaleY: this.getParentScale().scaleY });
|
|
10956
|
+
}
|
|
9719
10957
|
const segment = spreadsheetSkeleton.rowColumnSegment;
|
|
9720
10958
|
if (!segment) return;
|
|
9721
10959
|
if (segment.startRow === -1 && segment.endRow === -1 || segment.startColumn === -1 && segment.endColumn === -1) return;
|
|
@@ -9731,6 +10969,10 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9731
10969
|
mainCtx.restore();
|
|
9732
10970
|
return this;
|
|
9733
10971
|
}
|
|
10972
|
+
_canReuseStyleCache(viewportInfo) {
|
|
10973
|
+
var _viewportInfo$diffBou2, _viewportInfo$diffCac;
|
|
10974
|
+
return !!viewportInfo.cacheCanvas && !this.isDirty() && !this.isForceDirty() && !viewportInfo.isDirty && !viewportInfo.isForceDirty && !viewportInfo.shouldCacheUpdate && !viewportInfo.diffX && !viewportInfo.diffY && !((_viewportInfo$diffBou2 = viewportInfo.diffBounds) === null || _viewportInfo$diffBou2 === void 0 ? void 0 : _viewportInfo$diffBou2.length) && !((_viewportInfo$diffCac = viewportInfo.diffCacheBounds) === null || _viewportInfo$diffCac === void 0 ? void 0 : _viewportInfo$diffCac.length);
|
|
10975
|
+
}
|
|
9734
10976
|
/**
|
|
9735
10977
|
* applyCache from cache canvas
|
|
9736
10978
|
* @param cacheCanvas Source Image
|
|
@@ -9809,7 +11051,7 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9809
11051
|
* draw gridlines
|
|
9810
11052
|
* @param ctx
|
|
9811
11053
|
*/
|
|
9812
|
-
_drawAuxiliary(ctx, hasMergeData = true, redrawBackgrounds) {
|
|
11054
|
+
_drawAuxiliary(ctx, hasMergeData = true, redrawBackgrounds, repairNativeGridlines = false, deviceClipBound) {
|
|
9813
11055
|
const spreadsheetSkeleton = this.getSkeleton();
|
|
9814
11056
|
if (spreadsheetSkeleton == null) return;
|
|
9815
11057
|
const { rowColumnSegment, overflowCache, showGridlines, gridlinesColor, worksheet } = spreadsheetSkeleton;
|
|
@@ -9844,6 +11086,7 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9844
11086
|
ctx.lineToByPrecision(startX, endY);
|
|
9845
11087
|
ctx.closePathByEnv();
|
|
9846
11088
|
ctx.stroke();
|
|
11089
|
+
if (repairNativeGridlines) this._repairGridlineStroke(ctx, startX, startY, endX, endY);
|
|
9847
11090
|
const mergeVisibleRanges = [];
|
|
9848
11091
|
let mergeVisibleRangeStartRow = startRow;
|
|
9849
11092
|
for (let r = rowStart; r <= rowEnd; r++) {
|
|
@@ -9887,32 +11130,54 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9887
11130
|
const mergeRangeInVisible = spreadsheetSkeleton.getCurrentRowColumnSegmentMergeData(mergeVisibleRange);
|
|
9888
11131
|
mergeCellRanges.push(...mergeRangeInVisible);
|
|
9889
11132
|
}
|
|
9890
|
-
this._clearRectangle(ctx, rowHeightAccumulation, columnWidthAccumulation, mergeCellRanges, redrawBackgrounds);
|
|
9891
|
-
this._clearRectangle(ctx, rowHeightAccumulation, columnWidthAccumulation, overflowCache.toNativeArray(), redrawBackgrounds);
|
|
11133
|
+
this._clearRectangle(ctx, rowHeightAccumulation, columnWidthAccumulation, mergeCellRanges, redrawBackgrounds, repairNativeGridlines, deviceClipBound);
|
|
11134
|
+
this._clearRectangle(ctx, rowHeightAccumulation, columnWidthAccumulation, overflowCache.toNativeArray(), redrawBackgrounds, repairNativeGridlines, deviceClipBound);
|
|
9892
11135
|
this._drawGapAreas(ctx, spreadsheetSkeleton, rowStart, rowEnd, columnStart, columnEnd, startX, endX, startY, endY);
|
|
9893
11136
|
ctx.restore();
|
|
9894
11137
|
}
|
|
9895
11138
|
/**
|
|
9896
11139
|
* Clear the guide lines within a range in the table, to make room for merged cells and overflow.
|
|
9897
11140
|
*/
|
|
9898
|
-
_clearRectangle(ctx, rowHeightAccumulation, columnWidthAccumulation, cellRanges, redrawBackgrounds) {
|
|
11141
|
+
_clearRectangle(ctx, rowHeightAccumulation, columnWidthAccumulation, cellRanges, redrawBackgrounds, repairNativeGridlines = false, deviceClipBound) {
|
|
9899
11142
|
if (!(cellRanges === null || cellRanges === void 0 ? void 0 : cellRanges.length)) return;
|
|
9900
11143
|
const bounds = [];
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
11144
|
+
const clearedRanges = [];
|
|
11145
|
+
const m = ctx.getTransform();
|
|
11146
|
+
const clearDevicePixels = ctx.__mode !== "printing" && m.a > 0 && m.d > 0 && !m.b && !m.c;
|
|
11147
|
+
const native = ctx._context;
|
|
11148
|
+
const cullClip = deviceClipBound && clearDevicePixels && native.globalCompositeOperation === "source-over" && !native.shadowBlur && !native.shadowOffsetX && !native.shadowOffsetY && (!native.filter || native.filter === "none") ? deviceClipBound : void 0;
|
|
11149
|
+
const inkPadding = Math.ceil(ctx.lineWidth * Math.max(m.a, m.d) * 2) + 2;
|
|
11150
|
+
if (clearDevicePixels) {
|
|
11151
|
+
ctx.save();
|
|
11152
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
11153
|
+
}
|
|
11154
|
+
try {
|
|
11155
|
+
for (const range of cellRanges) {
|
|
11156
|
+
const { startRow, endRow, startColumn, endColumn } = range;
|
|
11157
|
+
const startY = rowHeightAccumulation[startRow - 1] ?? 0;
|
|
11158
|
+
const endY = rowHeightAccumulation[endRow] ?? rowHeightAccumulation[rowHeightAccumulation.length - 1];
|
|
11159
|
+
const startX = columnWidthAccumulation[startColumn - 1] ?? 0;
|
|
11160
|
+
const endX = columnWidthAccumulation[endColumn] ?? columnWidthAccumulation[columnWidthAccumulation.length - 1];
|
|
11161
|
+
if (clearDevicePixels) {
|
|
11162
|
+
const left = Math.round(Math.round(startX * m.a) + m.e);
|
|
11163
|
+
const top = Math.round(Math.round(startY * m.d) + m.f);
|
|
11164
|
+
const right = Math.round(Math.round(endX * m.a) + m.e);
|
|
11165
|
+
const bottom = Math.round(Math.round(endY * m.d) + m.f);
|
|
11166
|
+
if (cullClip && (right + inkPadding < cullClip.left || left - inkPadding > cullClip.right || bottom + inkPadding < cullClip.top || top - inkPadding > cullClip.bottom)) continue;
|
|
11167
|
+
ctx.clearRect(left, top, right - left, bottom - top);
|
|
11168
|
+
} else ctx.clearRectByPrecision(startX, startY, endX - startX, endY - startY);
|
|
11169
|
+
bounds.push({
|
|
11170
|
+
left: startX,
|
|
11171
|
+
top: startY,
|
|
11172
|
+
right: endX,
|
|
11173
|
+
bottom: endY
|
|
11174
|
+
});
|
|
11175
|
+
clearedRanges.push(range);
|
|
11176
|
+
}
|
|
11177
|
+
} finally {
|
|
11178
|
+
if (clearDevicePixels) ctx.restore();
|
|
9914
11179
|
}
|
|
9915
|
-
redrawBackgrounds === null || redrawBackgrounds === void 0 || redrawBackgrounds(cellRanges);
|
|
11180
|
+
if (clearedRanges.length) redrawBackgrounds === null || redrawBackgrounds === void 0 || redrawBackgrounds(cullClip ? clearedRanges : cellRanges);
|
|
9916
11181
|
for (const { left, top, right, bottom } of bounds) {
|
|
9917
11182
|
ctx.beginPath();
|
|
9918
11183
|
ctx.moveToByPrecision(left, top);
|
|
@@ -9921,9 +11186,66 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
9921
11186
|
ctx.lineToByPrecision(left, bottom);
|
|
9922
11187
|
ctx.lineToByPrecision(left, top);
|
|
9923
11188
|
ctx.stroke();
|
|
11189
|
+
if (repairNativeGridlines) this._repairGridlineStroke(ctx, left, top, right, bottom, true);
|
|
9924
11190
|
ctx.closePath();
|
|
9925
11191
|
}
|
|
9926
11192
|
}
|
|
11193
|
+
_repairGridlineStroke(ctx, left, top, right, bottom, rectangle = false) {
|
|
11194
|
+
var _native$getContextAtt;
|
|
11195
|
+
const native = ctx._context;
|
|
11196
|
+
const m = native.getTransform();
|
|
11197
|
+
const colorSpace = (_native$getContextAtt = native.getContextAttributes) === null || _native$getContextAtt === void 0 || (_native$getContextAtt = _native$getContextAtt.call(native)) === null || _native$getContextAtt === void 0 ? void 0 : _native$getContextAtt.colorSpace;
|
|
11198
|
+
if (m.a !== m.d || m.a <= 0 || m.b || m.c || colorSpace && colorSpace !== "srgb" || native.globalAlpha !== 1 || native.globalCompositeOperation !== "source-over" || typeof native.strokeStyle !== "string" || !/^#[\da-f]{6}$/i.test(native.strokeStyle) || native.getLineDash().length || native.lineCap !== "butt" || native.lineJoin !== "miter" || native.shadowBlur || native.shadowOffsetX || native.shadowOffsetY || ![
|
|
11199
|
+
"rgba(0, 0, 0, 0)",
|
|
11200
|
+
"transparent",
|
|
11201
|
+
"#00000000"
|
|
11202
|
+
].includes(native.shadowColor) || native.filter && native.filter !== "none") return;
|
|
11203
|
+
const width = native.lineWidth * m.a;
|
|
11204
|
+
const padding = Math.round(width) * 2 + 2;
|
|
11205
|
+
const segments = [[
|
|
11206
|
+
left,
|
|
11207
|
+
top,
|
|
11208
|
+
right,
|
|
11209
|
+
top
|
|
11210
|
+
], [
|
|
11211
|
+
left,
|
|
11212
|
+
top,
|
|
11213
|
+
left,
|
|
11214
|
+
bottom
|
|
11215
|
+
]];
|
|
11216
|
+
if (rectangle) segments.push([
|
|
11217
|
+
left,
|
|
11218
|
+
bottom,
|
|
11219
|
+
right,
|
|
11220
|
+
bottom
|
|
11221
|
+
], [
|
|
11222
|
+
right,
|
|
11223
|
+
top,
|
|
11224
|
+
right,
|
|
11225
|
+
bottom
|
|
11226
|
+
]);
|
|
11227
|
+
native.save();
|
|
11228
|
+
try {
|
|
11229
|
+
native.setTransform(1, 0, 0, 1, 0, 0);
|
|
11230
|
+
native.fillStyle = native.strokeStyle;
|
|
11231
|
+
for (const [x0, y0, x1, y1] of segments) {
|
|
11232
|
+
const horizontal = y0 === y1;
|
|
11233
|
+
const start = Math.round((horizontal ? x0 : y0) * m.a) + (horizontal ? m.e : m.f);
|
|
11234
|
+
const end = Math.round((horizontal ? x1 : y1) * m.a) + (horizontal ? m.e : m.f);
|
|
11235
|
+
const center = Math.round((horizontal ? y0 : x0) * m.a) + (horizontal ? m.f : m.e);
|
|
11236
|
+
const low = center - width / 2;
|
|
11237
|
+
const high = center + width / 2;
|
|
11238
|
+
const lowPixel = Math.round(low);
|
|
11239
|
+
const highPixel = Math.round(high);
|
|
11240
|
+
const from = Math.ceil(Math.min(start, end) + padding);
|
|
11241
|
+
const to = Math.floor(Math.max(start, end) - padding);
|
|
11242
|
+
if (Math.abs(low - lowPixel) > 1e-6 || Math.abs(high - highPixel) > 1e-6 || highPixel <= lowPixel || to <= from) continue;
|
|
11243
|
+
native.fillRect(horizontal ? from : lowPixel, horizontal ? lowPixel : from, horizontal ? to - from : highPixel - lowPixel, horizontal ? highPixel - lowPixel : to - from);
|
|
11244
|
+
}
|
|
11245
|
+
} finally {
|
|
11246
|
+
native.restore();
|
|
11247
|
+
}
|
|
11248
|
+
}
|
|
9927
11249
|
/**
|
|
9928
11250
|
* Draw gap areas for row and column gaps.
|
|
9929
11251
|
* Clears gridlines in gap regions and fills with gap style.
|
|
@@ -10195,6 +11517,7 @@ var Layer = class extends Disposable {
|
|
|
10195
11517
|
_defineProperty(this, "_objects", []);
|
|
10196
11518
|
_defineProperty(this, "_cacheCanvas", void 0);
|
|
10197
11519
|
_defineProperty(this, "_cacheValid", false);
|
|
11520
|
+
_defineProperty(this, "_retainedCacheValid", false);
|
|
10198
11521
|
_defineProperty(this, "_dirty", true);
|
|
10199
11522
|
_defineProperty(this, "_debounceDirtyFunc", void 0);
|
|
10200
11523
|
this.addObjects(objects);
|
|
@@ -10216,6 +11539,7 @@ var Layer = class extends Disposable {
|
|
|
10216
11539
|
(_this$_cacheCanvas = this._cacheCanvas) === null || _this$_cacheCanvas === void 0 || _this$_cacheCanvas.dispose();
|
|
10217
11540
|
this._cacheCanvas = null;
|
|
10218
11541
|
this._cacheValid = false;
|
|
11542
|
+
this._retainedCacheValid = false;
|
|
10219
11543
|
}
|
|
10220
11544
|
isAllowCache() {
|
|
10221
11545
|
return this._allowCache;
|
|
@@ -10265,6 +11589,7 @@ var Layer = class extends Disposable {
|
|
|
10265
11589
|
return this;
|
|
10266
11590
|
}
|
|
10267
11591
|
removeObject(object) {
|
|
11592
|
+
this.makeDirty(true);
|
|
10268
11593
|
const objects = this.getObjects();
|
|
10269
11594
|
const objectsLength = objects.length;
|
|
10270
11595
|
if (object instanceof BaseObject) {
|
|
@@ -10289,6 +11614,7 @@ var Layer = class extends Disposable {
|
|
|
10289
11614
|
return this;
|
|
10290
11615
|
}
|
|
10291
11616
|
removeObjects(objects) {
|
|
11617
|
+
this.makeDirty(true);
|
|
10292
11618
|
const allObjects = this.getObjects();
|
|
10293
11619
|
const allObjectsLength = allObjects.length;
|
|
10294
11620
|
for (let i = allObjectsLength - 1; i >= 0; i--) {
|
|
@@ -10307,7 +11633,11 @@ var Layer = class extends Disposable {
|
|
|
10307
11633
|
}
|
|
10308
11634
|
makeDirty(state = true) {
|
|
10309
11635
|
this._dirty = state;
|
|
10310
|
-
if (state) this.
|
|
11636
|
+
if (!state) this._retainedCacheValid = false;
|
|
11637
|
+
if (state) {
|
|
11638
|
+
this._retainedCacheValid = false;
|
|
11639
|
+
this._cacheValid = false;
|
|
11640
|
+
}
|
|
10311
11641
|
/**
|
|
10312
11642
|
* parent is SceneViewer, make it dirty
|
|
10313
11643
|
*/
|
|
@@ -10315,7 +11645,19 @@ var Layer = class extends Disposable {
|
|
|
10315
11645
|
if (parent.classType === "SceneViewer") parent.makeDirty(true);
|
|
10316
11646
|
return this;
|
|
10317
11647
|
}
|
|
11648
|
+
canReuseViewportCache() {
|
|
11649
|
+
return this._allowCache && !!this._cacheCanvas && (this._cacheValid && !this._dirty || this._retainedCacheValid) && this.getObjectsByOrder().every((object) => !object.isDirty() && !object.isForceDirty() && object.canReuseViewportCache());
|
|
11650
|
+
}
|
|
11651
|
+
makeDirtyForViewportScroll() {
|
|
11652
|
+
this._retainedCacheValid = this.canReuseViewportCache();
|
|
11653
|
+
this._cacheValid = false;
|
|
11654
|
+
this._dirty = true;
|
|
11655
|
+
}
|
|
10318
11656
|
makeDirtyWithDebounce(state = true) {
|
|
11657
|
+
if (state) {
|
|
11658
|
+
this._cacheValid = false;
|
|
11659
|
+
this._retainedCacheValid = false;
|
|
11660
|
+
}
|
|
10319
11661
|
if (this._debounceDirtyFunc) this._debounceDirtyFunc();
|
|
10320
11662
|
this._debounceDirtyFunc = requestImmediateMacroTask(() => {
|
|
10321
11663
|
this.makeDirty(state);
|
|
@@ -10341,12 +11683,29 @@ var Layer = class extends Disposable {
|
|
|
10341
11683
|
return this;
|
|
10342
11684
|
}
|
|
10343
11685
|
if (this.isDirty() || !this._cacheValid) {
|
|
11686
|
+
var _this$scene$getEngine, _this$scene$getEngine2;
|
|
10344
11687
|
const ctx = this._cacheCanvas.getContext();
|
|
10345
|
-
this._cacheCanvas.
|
|
11688
|
+
const retained = options.retainedViewportCache && this._retainedCacheValid && Number.isInteger(options.retainedViewportCache.bottom * this._cacheCanvas.getPixelRatio()) && options.retainedViewportCache.bottom < this._cacheCanvas.getHeight() && this._cacheCanvas.getWidth() === ((_this$scene$getEngine = this.scene.getEngine()) === null || _this$scene$getEngine === void 0 ? void 0 : _this$scene$getEngine.getCanvas().getWidth()) && this._cacheCanvas.getHeight() === ((_this$scene$getEngine2 = this.scene.getEngine()) === null || _this$scene$getEngine2 === void 0 ? void 0 : _this$scene$getEngine2.getCanvas().getHeight()) && this.getObjectsByOrder().every((object) => !object.isDirty() && !object.isForceDirty() && object.canReuseViewportCache()) ? options.retainedViewportCache : void 0;
|
|
11689
|
+
if (retained) {
|
|
11690
|
+
var _this$scene$getEngine3;
|
|
11691
|
+
(_this$scene$getEngine3 = this.scene.getEngine()) === null || _this$scene$getEngine3 === void 0 || _this$scene$getEngine3.renderFrameTags$.next(["retainedViewportCache", this.zIndex]);
|
|
11692
|
+
ctx.save();
|
|
11693
|
+
try {
|
|
11694
|
+
const ratio = this._cacheCanvas.getPixelRatio();
|
|
11695
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
11696
|
+
ctx.clearRect(0, retained.bottom * ratio, this._cacheCanvas.getWidth() * ratio, (this._cacheCanvas.getHeight() - retained.bottom) * ratio);
|
|
11697
|
+
} finally {
|
|
11698
|
+
ctx.restore();
|
|
11699
|
+
}
|
|
11700
|
+
} else this._cacheCanvas.clear();
|
|
10346
11701
|
ctx.save();
|
|
10347
11702
|
ctx.setTransform(mainCtx.getTransform());
|
|
10348
|
-
|
|
10349
|
-
|
|
11703
|
+
try {
|
|
11704
|
+
this._draw(ctx, isMaxLayer, viewportInfos, retained === null || retained === void 0 ? void 0 : retained.viewportKeys);
|
|
11705
|
+
} finally {
|
|
11706
|
+
this._retainedCacheValid = false;
|
|
11707
|
+
ctx.restore();
|
|
11708
|
+
}
|
|
10350
11709
|
this._cacheValid = true;
|
|
10351
11710
|
}
|
|
10352
11711
|
this._applyCache(mainCtx);
|
|
@@ -10373,11 +11732,14 @@ var Layer = class extends Disposable {
|
|
|
10373
11732
|
}));
|
|
10374
11733
|
this._cacheCanvas = new Canvas({ colorService: engine === null || engine === void 0 ? void 0 : engine.canvasColorService });
|
|
10375
11734
|
this._cacheValid = false;
|
|
11735
|
+
this._retainedCacheValid = false;
|
|
11736
|
+
this._resizeCacheCanvas();
|
|
10376
11737
|
}
|
|
10377
|
-
_draw(mainCtx, isMaxLayer, viewportInfos) {
|
|
11738
|
+
_draw(mainCtx, isMaxLayer, viewportInfos, retainedViewportKeys) {
|
|
10378
11739
|
const viewports = this._scene.getViewports().filter((vp) => vp.shouldIntoRender());
|
|
10379
11740
|
const objects = this.getObjectsByOrder();
|
|
10380
|
-
for (const [_index, vp] of viewports.entries()) vp.
|
|
11741
|
+
for (const [_index, vp] of viewports.entries()) if (retainedViewportKeys === null || retainedViewportKeys === void 0 ? void 0 : retainedViewportKeys.has(vp.viewportKey)) vp.reuseCachedRender(objects, viewportInfos === null || viewportInfos === void 0 ? void 0 : viewportInfos.get(vp.viewportKey));
|
|
11742
|
+
else vp.render(mainCtx, objects, isMaxLayer, viewportInfos === null || viewportInfos === void 0 ? void 0 : viewportInfos.get(vp.viewportKey));
|
|
10381
11743
|
objects.forEach((o) => {
|
|
10382
11744
|
var _o$makeForceDirty;
|
|
10383
11745
|
o.makeDirty(false);
|
|
@@ -10399,6 +11761,7 @@ var Layer = class extends Disposable {
|
|
|
10399
11761
|
this.makeDirty(true);
|
|
10400
11762
|
}
|
|
10401
11763
|
clear() {
|
|
11764
|
+
this.makeDirty(true);
|
|
10402
11765
|
this._objects = [];
|
|
10403
11766
|
}
|
|
10404
11767
|
dispose() {
|
|
@@ -10413,6 +11776,7 @@ var Layer = class extends Disposable {
|
|
|
10413
11776
|
(_this$_cacheCanvas3 = this._cacheCanvas) === null || _this$_cacheCanvas3 === void 0 || _this$_cacheCanvas3.dispose();
|
|
10414
11777
|
this._cacheCanvas = null;
|
|
10415
11778
|
this._cacheValid = false;
|
|
11779
|
+
this._retainedCacheValid = false;
|
|
10416
11780
|
}
|
|
10417
11781
|
};
|
|
10418
11782
|
|
|
@@ -11325,7 +12689,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
11325
12689
|
|
|
11326
12690
|
// package.json
|
|
11327
12691
|
var name = "@univerjs/engine-render";
|
|
11328
|
-
var version = "1.
|
|
12692
|
+
var version = "1.5.1";
|
|
11329
12693
|
|
|
11330
12694
|
// src/config/config.ts
|
|
11331
12695
|
/**
|
|
@@ -11798,6 +13162,128 @@ var ScrollTimer = class ScrollTimer {
|
|
|
11798
13162
|
}
|
|
11799
13163
|
};
|
|
11800
13164
|
|
|
13165
|
+
// src/transformer-rotation.ts
|
|
13166
|
+
const EDGE_GAP = 8;
|
|
13167
|
+
const RETURN_GAP = 12;
|
|
13168
|
+
const CONTROL_GAP = 4;
|
|
13169
|
+
function distanceSquared(a, b) {
|
|
13170
|
+
return (a.x - b.x) ** 2 + (a.y - b.y) ** 2;
|
|
13171
|
+
}
|
|
13172
|
+
function contains(bounds, point, margin = 0) {
|
|
13173
|
+
return point.x >= bounds.left + margin && point.x <= bounds.right - margin && point.y >= bounds.top + margin && point.y <= bounds.bottom - margin;
|
|
13174
|
+
}
|
|
13175
|
+
function isClear(point, radius, obstacles) {
|
|
13176
|
+
return obstacles.every((obstacle) => distanceSquared(point, obstacle) >= (radius + obstacle.radius + CONTROL_GAP) ** 2);
|
|
13177
|
+
}
|
|
13178
|
+
function shorten(candidate, bounds) {
|
|
13179
|
+
let start = 0;
|
|
13180
|
+
let end = 1;
|
|
13181
|
+
for (const axis of ["x", "y"]) {
|
|
13182
|
+
const from = candidate.attachment[axis];
|
|
13183
|
+
const delta = candidate.center[axis] - from;
|
|
13184
|
+
const min = axis === "x" ? bounds.left : bounds.top;
|
|
13185
|
+
const max = axis === "x" ? bounds.right : bounds.bottom;
|
|
13186
|
+
if (Math.abs(delta) < 1e-8) {
|
|
13187
|
+
if (from < min || from > max) return;
|
|
13188
|
+
continue;
|
|
13189
|
+
}
|
|
13190
|
+
const first = (min - from) / delta;
|
|
13191
|
+
const last = (max - from) / delta;
|
|
13192
|
+
start = Math.max(start, Math.min(first, last));
|
|
13193
|
+
end = Math.min(end, Math.max(first, last));
|
|
13194
|
+
}
|
|
13195
|
+
if (start > end) return;
|
|
13196
|
+
return {
|
|
13197
|
+
x: candidate.attachment.x + (candidate.center.x - candidate.attachment.x) * end,
|
|
13198
|
+
y: candidate.attachment.y + (candidate.center.y - candidate.attachment.y) * end
|
|
13199
|
+
};
|
|
13200
|
+
}
|
|
13201
|
+
function nearestAttachment(point, corners) {
|
|
13202
|
+
return corners.map((a, index) => {
|
|
13203
|
+
const b = corners[(index + 1) % corners.length];
|
|
13204
|
+
const length = distanceSquared(a, b);
|
|
13205
|
+
const t = length ? Math.max(0, Math.min(1, ((point.x - a.x) * (b.x - a.x) + (point.y - a.y) * (b.y - a.y)) / length)) : 0;
|
|
13206
|
+
return {
|
|
13207
|
+
x: a.x + (b.x - a.x) * t,
|
|
13208
|
+
y: a.y + (b.y - a.y) * t
|
|
13209
|
+
};
|
|
13210
|
+
}).reduce((best, next) => distanceSquared(next, point) < distanceSquared(best, point) ? next : best);
|
|
13211
|
+
}
|
|
13212
|
+
function insetCandidates(layout, bounds) {
|
|
13213
|
+
const { preferred, opposite, obstacles, artworkRadius } = layout;
|
|
13214
|
+
const clamp = (point) => ({
|
|
13215
|
+
x: Math.max(bounds.left, Math.min(bounds.right, point.x)),
|
|
13216
|
+
y: Math.max(bounds.top, Math.min(bounds.bottom, point.y))
|
|
13217
|
+
});
|
|
13218
|
+
const candidates = [preferred.center, opposite.center];
|
|
13219
|
+
for (const x of [
|
|
13220
|
+
bounds.left,
|
|
13221
|
+
(bounds.left + bounds.right) / 2,
|
|
13222
|
+
bounds.right
|
|
13223
|
+
]) for (const y of [
|
|
13224
|
+
bounds.top,
|
|
13225
|
+
(bounds.top + bounds.bottom) / 2,
|
|
13226
|
+
bounds.bottom
|
|
13227
|
+
]) candidates.push({
|
|
13228
|
+
x,
|
|
13229
|
+
y
|
|
13230
|
+
});
|
|
13231
|
+
for (const obstacle of obstacles) {
|
|
13232
|
+
const gap = artworkRadius + obstacle.radius + CONTROL_GAP;
|
|
13233
|
+
candidates.push({
|
|
13234
|
+
x: obstacle.x - gap,
|
|
13235
|
+
y: obstacle.y
|
|
13236
|
+
}, {
|
|
13237
|
+
x: obstacle.x + gap,
|
|
13238
|
+
y: obstacle.y
|
|
13239
|
+
}, {
|
|
13240
|
+
x: obstacle.x,
|
|
13241
|
+
y: obstacle.y - gap
|
|
13242
|
+
}, {
|
|
13243
|
+
x: obstacle.x,
|
|
13244
|
+
y: obstacle.y + gap
|
|
13245
|
+
});
|
|
13246
|
+
}
|
|
13247
|
+
return candidates.map(clamp);
|
|
13248
|
+
}
|
|
13249
|
+
/** Keep the complete interaction target inside the viewport; all distances are screen pixels. */
|
|
13250
|
+
function placeRotationHandle(layout) {
|
|
13251
|
+
const { radius, artworkRadius, preferred, opposite, obstacles, previousSide } = layout;
|
|
13252
|
+
const inset = radius + EDGE_GAP;
|
|
13253
|
+
const bounds = {
|
|
13254
|
+
left: layout.bounds.left + inset,
|
|
13255
|
+
top: layout.bounds.top + inset,
|
|
13256
|
+
right: layout.bounds.right - inset,
|
|
13257
|
+
bottom: layout.bounds.bottom - inset
|
|
13258
|
+
};
|
|
13259
|
+
if (bounds.left > bounds.right || bounds.top > bounds.bottom) return;
|
|
13260
|
+
const candidates = !previousSide || previousSide === preferred.side || contains(bounds, preferred.center, RETURN_GAP) ? [preferred, opposite] : [opposite, preferred];
|
|
13261
|
+
for (const candidate of candidates) {
|
|
13262
|
+
const center = shorten(candidate, bounds);
|
|
13263
|
+
if (center && isClear(center, artworkRadius, obstacles)) return {
|
|
13264
|
+
...candidate,
|
|
13265
|
+
center,
|
|
13266
|
+
adjusted: candidate !== preferred || distanceSquared(center, preferred.center) > .01
|
|
13267
|
+
};
|
|
13268
|
+
}
|
|
13269
|
+
let center;
|
|
13270
|
+
let nearestDistance = Infinity;
|
|
13271
|
+
for (const point of insetCandidates(layout, bounds)) {
|
|
13272
|
+
const distance = distanceSquared(point, preferred.center);
|
|
13273
|
+
if (distance < nearestDistance && isClear(point, artworkRadius, obstacles)) {
|
|
13274
|
+
center = point;
|
|
13275
|
+
nearestDistance = distance;
|
|
13276
|
+
}
|
|
13277
|
+
}
|
|
13278
|
+
if (!center) return;
|
|
13279
|
+
return {
|
|
13280
|
+
center,
|
|
13281
|
+
attachment: nearestAttachment(center, layout.corners),
|
|
13282
|
+
side: "inset",
|
|
13283
|
+
adjusted: true
|
|
13284
|
+
};
|
|
13285
|
+
}
|
|
13286
|
+
|
|
11801
13287
|
// src/scene.transformer.ts
|
|
11802
13288
|
const TransformerManagerTypeArray = [
|
|
11803
13289
|
"__SpreadsheetTransformerResizeLT__",
|
|
@@ -11965,12 +13451,23 @@ var Transformer = class Transformer extends Disposable {
|
|
|
11965
13451
|
_defineProperty(this, "_cancelFocusSubscription", void 0);
|
|
11966
13452
|
_defineProperty(this, "_transformerControlMap", /* @__PURE__ */ new Map());
|
|
11967
13453
|
_defineProperty(this, "_selectedObjectMap", /* @__PURE__ */ new Map());
|
|
13454
|
+
_defineProperty(this, "_rotationControls", /* @__PURE__ */ new Map());
|
|
13455
|
+
_defineProperty(this, "_rotationSides", /* @__PURE__ */ new Map());
|
|
11968
13456
|
_defineProperty(this, "_subscriptionObjectMap", /* @__PURE__ */ new Map());
|
|
11969
13457
|
_defineProperty(this, "_copperControl", void 0);
|
|
11970
13458
|
_defineProperty(this, "_copperSelectedObject", void 0);
|
|
11971
13459
|
_defineProperty(this, "_moveBufferSkip", false);
|
|
11972
13460
|
_defineProperty(this, "_debounceClearFunc", void 0);
|
|
11973
13461
|
this._initialProps(config);
|
|
13462
|
+
this.disposeWithMe(this._scene.prepareRender$.subscribe(() => this._updateRotationControls()));
|
|
13463
|
+
}
|
|
13464
|
+
/** Hit-test the actual displayed handles using canvas coordinates, including viewport edge avoidance. */
|
|
13465
|
+
isPointOnControl(objectKey, coord, deviceType = 2) {
|
|
13466
|
+
const group = this._transformerControlMap.get(objectKey);
|
|
13467
|
+
if (!(group === null || group === void 0 ? void 0 : group.visible) || !this._scene.getActiveViewportByCoord(coord)) return false;
|
|
13468
|
+
this._updateRotationControls();
|
|
13469
|
+
const hit = this._scene.pick(coord, deviceType);
|
|
13470
|
+
return group.getObjects().some((object) => object === hit && object instanceof Control);
|
|
11974
13471
|
}
|
|
11975
13472
|
updateZeroPoint(left, top) {
|
|
11976
13473
|
this.zeroLeft = left;
|
|
@@ -12029,6 +13526,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12029
13526
|
clearSelectedObjects() {
|
|
12030
13527
|
var _this$_cancelFocusSub;
|
|
12031
13528
|
this._selectedObjectMap.clear();
|
|
13529
|
+
this._rotationSides.clear();
|
|
12032
13530
|
(_this$_cancelFocusSub = this._cancelFocusSubscription) === null || _this$_cancelFocusSub === void 0 || _this$_cancelFocusSub.unsubscribe();
|
|
12033
13531
|
this._cancelFocusSubscription = null;
|
|
12034
13532
|
this._clearControls(true);
|
|
@@ -12054,108 +13552,63 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12054
13552
|
this._createControl(realApplyObject);
|
|
12055
13553
|
}
|
|
12056
13554
|
_getConfig(applyObject) {
|
|
12057
|
-
const
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
12087
|
-
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
|
|
12096
|
-
|
|
12097
|
-
|
|
12098
|
-
|
|
12099
|
-
|
|
12100
|
-
|
|
12101
|
-
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
moveBoundaryEnabled = objectTransformerConfig.moveBoundaryEnabled ?? moveBoundaryEnabled;
|
|
12108
|
-
}
|
|
12109
|
-
return {
|
|
12110
|
-
isCropper,
|
|
12111
|
-
hoverEnabled,
|
|
12112
|
-
hoverEnterFunc,
|
|
12113
|
-
hoverLeaveFunc,
|
|
12114
|
-
moveEnabled,
|
|
12115
|
-
moveOnlyWhenSelected,
|
|
12116
|
-
resizeEnabled,
|
|
12117
|
-
rotateEnabled,
|
|
12118
|
-
rotationSnaps,
|
|
12119
|
-
rotationSnapTolerance,
|
|
12120
|
-
rotateAnchorOffset,
|
|
12121
|
-
rotateAnchorPosition,
|
|
12122
|
-
rotateLineEnabled,
|
|
12123
|
-
rotateSize,
|
|
12124
|
-
rotateCornerRadius,
|
|
12125
|
-
rotateFill,
|
|
12126
|
-
rotateStroke,
|
|
12127
|
-
rotateStrokeWidth,
|
|
12128
|
-
rotateIconEnabled,
|
|
12129
|
-
rotateIconStroke,
|
|
12130
|
-
rotateIconStrokeWidth,
|
|
12131
|
-
borderEnabled,
|
|
12132
|
-
borderStroke,
|
|
12133
|
-
borderStrokeWidth,
|
|
12134
|
-
borderDash,
|
|
12135
|
-
borderSpacing,
|
|
12136
|
-
anchorFill,
|
|
12137
|
-
anchorStroke,
|
|
12138
|
-
anchorStrokeWidth,
|
|
12139
|
-
anchorSize,
|
|
12140
|
-
anchorCornerRadius,
|
|
12141
|
-
anchorStyle,
|
|
12142
|
-
anchorSideLongSize,
|
|
12143
|
-
anchorSideShortSize,
|
|
12144
|
-
anchorSideCornerRadius,
|
|
12145
|
-
anchorShadowColor,
|
|
12146
|
-
anchorShadowBlur,
|
|
12147
|
-
anchorShadowOffsetX,
|
|
12148
|
-
anchorShadowOffsetY,
|
|
12149
|
-
keepRatio,
|
|
12150
|
-
centeredScaling,
|
|
12151
|
-
enabledAnchors,
|
|
12152
|
-
flipEnabled,
|
|
12153
|
-
ignoreStroke,
|
|
12154
|
-
boundBoxFunc,
|
|
12155
|
-
useSingleNodeRotation,
|
|
12156
|
-
shouldOverdrawWholeArea,
|
|
12157
|
-
moveBoundaryEnabled
|
|
13555
|
+
const config = {
|
|
13556
|
+
isCropper: this.isCropper,
|
|
13557
|
+
controlLayerIndex: this.controlLayerIndex,
|
|
13558
|
+
hoverEnabled: this.hoverEnabled,
|
|
13559
|
+
hoverEnterFunc: this.hoverEnterFunc,
|
|
13560
|
+
hoverLeaveFunc: this.hoverLeaveFunc,
|
|
13561
|
+
moveEnabled: this.moveEnabled,
|
|
13562
|
+
moveOnlyWhenSelected: this.moveOnlyWhenSelected,
|
|
13563
|
+
resizeEnabled: this.resizeEnabled,
|
|
13564
|
+
rotateEnabled: this.rotateEnabled,
|
|
13565
|
+
rotationSnaps: this.rotationSnaps,
|
|
13566
|
+
rotationSnapTolerance: this.rotationSnapTolerance,
|
|
13567
|
+
rotateAnchorOffset: this.rotateAnchorOffset,
|
|
13568
|
+
rotateAnchorPosition: this.rotateAnchorPosition,
|
|
13569
|
+
rotateLineEnabled: this.rotateLineEnabled,
|
|
13570
|
+
rotateSize: this.rotateSize,
|
|
13571
|
+
rotateCornerRadius: this.rotateCornerRadius,
|
|
13572
|
+
rotateFill: this.rotateFill,
|
|
13573
|
+
rotateStroke: this.rotateStroke,
|
|
13574
|
+
rotateStrokeWidth: this.rotateStrokeWidth,
|
|
13575
|
+
rotateIconEnabled: this.rotateIconEnabled,
|
|
13576
|
+
rotateIconStroke: this.rotateIconStroke,
|
|
13577
|
+
rotateIconStrokeWidth: this.rotateIconStrokeWidth,
|
|
13578
|
+
borderEnabled: this.borderEnabled,
|
|
13579
|
+
borderStroke: this.borderStroke,
|
|
13580
|
+
borderStrokeWidth: this.borderStrokeWidth,
|
|
13581
|
+
borderDash: this.borderDash,
|
|
13582
|
+
borderSpacing: this.borderSpacing,
|
|
13583
|
+
anchorFill: this.anchorFill,
|
|
13584
|
+
anchorStroke: this.anchorStroke,
|
|
13585
|
+
anchorStrokeWidth: this.anchorStrokeWidth,
|
|
13586
|
+
anchorSize: this.anchorSize,
|
|
13587
|
+
anchorCornerRadius: this.anchorCornerRadius,
|
|
13588
|
+
anchorStyle: this.anchorStyle,
|
|
13589
|
+
anchorSideLongSize: this.anchorSideLongSize,
|
|
13590
|
+
anchorSideShortSize: this.anchorSideShortSize,
|
|
13591
|
+
anchorSideCornerRadius: this.anchorSideCornerRadius,
|
|
13592
|
+
anchorShadowColor: this.anchorShadowColor,
|
|
13593
|
+
anchorShadowBlur: this.anchorShadowBlur,
|
|
13594
|
+
anchorShadowOffsetX: this.anchorShadowOffsetX,
|
|
13595
|
+
anchorShadowOffsetY: this.anchorShadowOffsetY,
|
|
13596
|
+
keepRatio: this.keepRatio,
|
|
13597
|
+
centeredScaling: this.centeredScaling,
|
|
13598
|
+
enabledAnchors: this.enabledAnchors,
|
|
13599
|
+
flipEnabled: this.flipEnabled,
|
|
13600
|
+
ignoreStroke: this.ignoreStroke,
|
|
13601
|
+
boundBoxFunc: this.boundBoxFunc,
|
|
13602
|
+
useSingleNodeRotation: this.useSingleNodeRotation,
|
|
13603
|
+
shouldOverdrawWholeArea: this.shouldOverdrawWholeArea,
|
|
13604
|
+
moveBoundaryEnabled: this.moveBoundaryEnabled
|
|
12158
13605
|
};
|
|
13606
|
+
for (const key of Object.keys(config)) {
|
|
13607
|
+
var _applyObject$transfor;
|
|
13608
|
+
const value = (_applyObject$transfor = applyObject.transformerConfig) === null || _applyObject$transfor === void 0 ? void 0 : _applyObject$transfor[key];
|
|
13609
|
+
if (value != null) Object.assign(config, { [key]: value });
|
|
13610
|
+
}
|
|
13611
|
+
return config;
|
|
12159
13612
|
}
|
|
12160
13613
|
attachTo(applyObject) {
|
|
12161
13614
|
this.detachFrom(applyObject);
|
|
@@ -12166,37 +13619,17 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12166
13619
|
this._startOffsetX = evtOffsetX;
|
|
12167
13620
|
this._startOffsetY = evtOffsetY;
|
|
12168
13621
|
const { isCropper, moveEnabled, moveOnlyWhenSelected } = this._getConfig(applyObject);
|
|
12169
|
-
if (!isCropper && moveOnlyWhenSelected && !this._selectedObjectMap.has(this._findGroupObject(applyObject).oKey))
|
|
12170
|
-
|
|
12171
|
-
if (!scene) {
|
|
12172
|
-
this._updateActiveObjectList(applyObject, evt);
|
|
12173
|
-
return;
|
|
12174
|
-
}
|
|
12175
|
-
let moved = false;
|
|
12176
|
-
let moveSubscription;
|
|
12177
|
-
let upSubscription;
|
|
12178
|
-
let cancelSubscription;
|
|
12179
|
-
const disposeGesture = () => {
|
|
12180
|
-
moveSubscription === null || moveSubscription === void 0 || moveSubscription.unsubscribe();
|
|
12181
|
-
upSubscription === null || upSubscription === void 0 || upSubscription.unsubscribe();
|
|
12182
|
-
cancelSubscription === null || cancelSubscription === void 0 || cancelSubscription.unsubscribe();
|
|
12183
|
-
};
|
|
12184
|
-
moveSubscription = scene.onPointerMove$.subscribeEvent((moveEvent) => {
|
|
12185
|
-
moved ||= Math.hypot(moveEvent.offsetX - evtOffsetX, moveEvent.offsetY - evtOffsetY) >= Transformer._selectionTapMovementThreshold;
|
|
12186
|
-
});
|
|
12187
|
-
upSubscription = scene.onPointerUp$.subscribeEvent(() => {
|
|
12188
|
-
disposeGesture();
|
|
12189
|
-
if (!moved) this._updateActiveObjectList(applyObject, evt);
|
|
12190
|
-
});
|
|
12191
|
-
cancelSubscription = scene.onPointerCancel$.subscribeEvent(disposeGesture);
|
|
12192
|
-
return;
|
|
12193
|
-
}
|
|
12194
|
-
if (!isCropper && !moveEnabled) {
|
|
12195
|
-
this._updateActiveObjectList(applyObject, evt);
|
|
12196
|
-
return;
|
|
12197
|
-
}
|
|
13622
|
+
if (!isCropper && moveOnlyWhenSelected && !this._selectedObjectMap.has(this._findGroupObject(applyObject).oKey)) return this._selectOnPointerUp(applyObject, evt);
|
|
13623
|
+
if (!isCropper && !moveEnabled) return this._updateActiveObjectList(applyObject, evt);
|
|
12198
13624
|
const scene = this._getTopScene();
|
|
12199
13625
|
if (!scene) return;
|
|
13626
|
+
let transformObjects;
|
|
13627
|
+
if (isCropper) transformObjects = /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]);
|
|
13628
|
+
else {
|
|
13629
|
+
this._updateActiveObjectList(applyObject, evt);
|
|
13630
|
+
transformObjects = this._getTransformObjects("moveEnabled");
|
|
13631
|
+
if (!transformObjects.size) return;
|
|
13632
|
+
}
|
|
12200
13633
|
this._addCancelObserver(scene);
|
|
12201
13634
|
(_scene$getEngine = scene.getEngine()) === null || _scene$getEngine === void 0 || _scene$getEngine.setCapture();
|
|
12202
13635
|
scene.disableObjectsEvent();
|
|
@@ -12205,28 +13638,20 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12205
13638
|
const { scrollX, scrollY } = getCurrentScrollXY(scrollTimer);
|
|
12206
13639
|
this._viewportScrollX = scrollX;
|
|
12207
13640
|
this._viewportScrollY = scrollY;
|
|
12208
|
-
if (
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
} else {
|
|
12216
|
-
this._copperSelectedObject = applyObject;
|
|
12217
|
-
this._changeStart$.next({
|
|
12218
|
-
target: applyObject,
|
|
12219
|
-
objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
|
|
12220
|
-
type: 0
|
|
12221
|
-
});
|
|
12222
|
-
}
|
|
13641
|
+
if (isCropper) this._copperSelectedObject = applyObject;
|
|
13642
|
+
const objects = isCropper ? /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]) : this._selectedObjectMap;
|
|
13643
|
+
this._changeStart$.next({
|
|
13644
|
+
target: applyObject,
|
|
13645
|
+
objects,
|
|
13646
|
+
type: 0
|
|
13647
|
+
});
|
|
12223
13648
|
this._moveBufferSkip = false;
|
|
12224
13649
|
const scenePointerMoveSub = scene.onPointerMove$.subscribeEvent((moveEvt) => {
|
|
12225
13650
|
const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt;
|
|
12226
|
-
this._moving(moveOffsetX, moveOffsetY, scrollTimer, isCropper);
|
|
13651
|
+
this._moving(moveOffsetX, moveOffsetY, scrollTimer, isCropper, transformObjects);
|
|
12227
13652
|
!isCropper && this._clearControlMap();
|
|
12228
13653
|
scrollTimer.scrolling(moveOffsetX, moveOffsetY, () => {
|
|
12229
|
-
this._moving(moveOffsetX, moveOffsetY, scrollTimer, isCropper);
|
|
13654
|
+
this._moving(moveOffsetX, moveOffsetY, scrollTimer, isCropper, transformObjects);
|
|
12230
13655
|
});
|
|
12231
13656
|
});
|
|
12232
13657
|
this._bindGestureEnd(scene, evt, (event) => {
|
|
@@ -12235,15 +13660,8 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12235
13660
|
!isCropper && this.refreshControls();
|
|
12236
13661
|
scrollTimer.dispose();
|
|
12237
13662
|
const { offsetX, offsetY } = event;
|
|
12238
|
-
|
|
12239
|
-
objects
|
|
12240
|
-
type: 2,
|
|
12241
|
-
offsetX,
|
|
12242
|
-
offsetY,
|
|
12243
|
-
event
|
|
12244
|
-
});
|
|
12245
|
-
else this._changeEnd$.next({
|
|
12246
|
-
objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
|
|
13663
|
+
this._changeEnd$.next({
|
|
13664
|
+
objects,
|
|
12247
13665
|
type: 2,
|
|
12248
13666
|
offsetX,
|
|
12249
13667
|
offsetY,
|
|
@@ -12259,6 +13677,30 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12259
13677
|
this._subscriptionObjectMap.set(applyObject.oKey, observer);
|
|
12260
13678
|
return applyObject;
|
|
12261
13679
|
}
|
|
13680
|
+
_selectOnPointerUp(applyObject, evt) {
|
|
13681
|
+
const scene = this._getTopScene();
|
|
13682
|
+
if (!scene) {
|
|
13683
|
+
this._updateActiveObjectList(applyObject, evt);
|
|
13684
|
+
return;
|
|
13685
|
+
}
|
|
13686
|
+
let moved = false;
|
|
13687
|
+
let moveSubscription;
|
|
13688
|
+
let upSubscription;
|
|
13689
|
+
let cancelSubscription;
|
|
13690
|
+
const disposeGesture = () => {
|
|
13691
|
+
moveSubscription === null || moveSubscription === void 0 || moveSubscription.unsubscribe();
|
|
13692
|
+
upSubscription === null || upSubscription === void 0 || upSubscription.unsubscribe();
|
|
13693
|
+
cancelSubscription === null || cancelSubscription === void 0 || cancelSubscription.unsubscribe();
|
|
13694
|
+
};
|
|
13695
|
+
moveSubscription = scene.onPointerMove$.subscribeEvent((moveEvent) => {
|
|
13696
|
+
moved ||= Math.hypot(moveEvent.offsetX - evt.offsetX, moveEvent.offsetY - evt.offsetY) >= Transformer._selectionTapMovementThreshold;
|
|
13697
|
+
});
|
|
13698
|
+
upSubscription = scene.onPointerUp$.subscribeEvent(() => {
|
|
13699
|
+
disposeGesture();
|
|
13700
|
+
if (!moved) this._updateActiveObjectList(applyObject, evt);
|
|
13701
|
+
});
|
|
13702
|
+
cancelSubscription = scene.onPointerCancel$.subscribeEvent(disposeGesture);
|
|
13703
|
+
}
|
|
12262
13704
|
detachFrom(applyObject) {
|
|
12263
13705
|
const subscription = this._subscriptionObjectMap.get(applyObject.oKey);
|
|
12264
13706
|
if (subscription) {
|
|
@@ -12278,6 +13720,8 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12278
13720
|
this._cancelFocusSubscription = null;
|
|
12279
13721
|
this._transformerControlMap.forEach((control) => control.dispose());
|
|
12280
13722
|
this._selectedObjectMap.forEach((control) => control.dispose());
|
|
13723
|
+
this._rotationControls.clear();
|
|
13724
|
+
this._rotationSides.clear();
|
|
12281
13725
|
this._changeStart$.complete();
|
|
12282
13726
|
this._changing$.complete();
|
|
12283
13727
|
this._changeEnd$.complete();
|
|
@@ -12288,27 +13732,34 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12288
13732
|
if (propsKeys.length === 0) return;
|
|
12289
13733
|
propsKeys.forEach((key) => {
|
|
12290
13734
|
if (props[key] === void 0) return true;
|
|
12291
|
-
this[key]
|
|
13735
|
+
Object.assign(this, { [key]: props[key] });
|
|
12292
13736
|
});
|
|
12293
13737
|
}
|
|
12294
|
-
_checkMoveBoundary(
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12298
|
-
|
|
12299
|
-
const
|
|
12300
|
-
|
|
12301
|
-
|
|
12302
|
-
|
|
12303
|
-
|
|
12304
|
-
|
|
12305
|
-
|
|
13738
|
+
_checkMoveBoundary(objects, moveLeft, moveTop, ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight) {
|
|
13739
|
+
let minX = -Infinity;
|
|
13740
|
+
let minY = -Infinity;
|
|
13741
|
+
let maxX = Infinity;
|
|
13742
|
+
let maxY = Infinity;
|
|
13743
|
+
for (const object of objects) {
|
|
13744
|
+
if (this._getConfig(object).moveBoundaryEnabled === false) continue;
|
|
13745
|
+
minX = Math.max(minX, this.zeroLeft - object.left - ancestorLeft);
|
|
13746
|
+
minY = Math.max(minY, this.zeroTop - object.top - ancestorTop);
|
|
13747
|
+
maxX = Math.min(maxX, topSceneWidth - object.left - object.width - ancestorLeft);
|
|
13748
|
+
maxY = Math.min(maxY, topSceneHeight - object.top - object.height - ancestorTop);
|
|
13749
|
+
}
|
|
12306
13750
|
return {
|
|
12307
|
-
moveLeft:
|
|
12308
|
-
moveTop:
|
|
13751
|
+
moveLeft: Math.max(minX, Math.min(moveLeft, maxX)),
|
|
13752
|
+
moveTop: Math.max(minY, Math.min(moveTop, maxY))
|
|
12309
13753
|
};
|
|
12310
13754
|
}
|
|
12311
|
-
|
|
13755
|
+
/**
|
|
13756
|
+
* Filters selected objects by the requested capability in their effective transformer config.
|
|
13757
|
+
* Objects without that capability stay selected but do not participate in the move or resize gesture.
|
|
13758
|
+
*/
|
|
13759
|
+
_getTransformObjects(capability) {
|
|
13760
|
+
return new Map(Array.from(this._selectedObjectMap).filter(([, object]) => this._getConfig(object)[capability]));
|
|
13761
|
+
}
|
|
13762
|
+
_moving(moveOffsetX, moveOffsetY, scrollTimer, isCropper, transformObjects) {
|
|
12312
13763
|
const { scrollX, scrollY } = getCurrentScrollXY(scrollTimer);
|
|
12313
13764
|
const x = moveOffsetX - this._viewportScrollX + scrollX;
|
|
12314
13765
|
const y = moveOffsetY - this._viewportScrollY + scrollY;
|
|
@@ -12320,14 +13771,11 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12320
13771
|
if (!topScene) return;
|
|
12321
13772
|
const { width: topSceneWidth, height: topSceneHeight } = topScene;
|
|
12322
13773
|
if (!isCropper) {
|
|
12323
|
-
const selectedObjects = Array.from(
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
moveTop = boundary.moveTop;
|
|
12329
|
-
}
|
|
12330
|
-
this._selectedObjectMap.forEach((moveObject) => {
|
|
13774
|
+
const selectedObjects = Array.from(transformObjects.values());
|
|
13775
|
+
const boundary = this._checkMoveBoundary(selectedObjects, moveLeft, moveTop, ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight);
|
|
13776
|
+
moveLeft = boundary.moveLeft;
|
|
13777
|
+
moveTop = boundary.moveTop;
|
|
13778
|
+
transformObjects.forEach((moveObject) => {
|
|
12331
13779
|
moveObject.translate(moveLeft + moveObject.left, moveTop + moveObject.top);
|
|
12332
13780
|
});
|
|
12333
13781
|
this._changing$.next({
|
|
@@ -12340,7 +13788,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12340
13788
|
});
|
|
12341
13789
|
} else if (this._copperSelectedObject) {
|
|
12342
13790
|
const cropper = this._copperSelectedObject;
|
|
12343
|
-
const boundary = this._checkMoveBoundary(cropper, moveLeft, moveTop, ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight);
|
|
13791
|
+
const boundary = this._checkMoveBoundary([cropper], moveLeft, moveTop, ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight);
|
|
12344
13792
|
moveLeft = boundary.moveLeft;
|
|
12345
13793
|
moveTop = boundary.moveTop;
|
|
12346
13794
|
cropper.translate(moveLeft + cropper.left, moveTop + cropper.top);
|
|
@@ -12361,14 +13809,14 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12361
13809
|
this._moveBufferSkip = true;
|
|
12362
13810
|
return false;
|
|
12363
13811
|
}
|
|
12364
|
-
_anchorMoving(type, moveOffsetX, moveOffsetY, scrollTimer, keepRatio, isCropper = false, applyObject) {
|
|
13812
|
+
_anchorMoving(type, moveOffsetX, moveOffsetY, scrollTimer, keepRatio, isCropper = false, applyObject, transformObjects) {
|
|
12365
13813
|
const { scrollX, scrollY } = getCurrentScrollXY(scrollTimer);
|
|
12366
13814
|
const x = moveOffsetX - this._viewportScrollX + scrollX;
|
|
12367
13815
|
const y = moveOffsetY - this._viewportScrollY + scrollY;
|
|
12368
13816
|
if (this._moveBufferBlocker(moveOffsetX, moveOffsetY)) return;
|
|
12369
13817
|
const isGroup = applyObject instanceof Group;
|
|
12370
13818
|
if (!isCropper) {
|
|
12371
|
-
|
|
13819
|
+
transformObjects.forEach((moveObject) => {
|
|
12372
13820
|
this._moveFunc(moveObject, type, x, y, keepRatio, isCropper, isGroup);
|
|
12373
13821
|
});
|
|
12374
13822
|
this._changing$.next({
|
|
@@ -12459,38 +13907,38 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12459
13907
|
};
|
|
12460
13908
|
switch (type) {
|
|
12461
13909
|
case "__SpreadsheetTransformerResizeLT__":
|
|
12462
|
-
state.width =
|
|
12463
|
-
state.height =
|
|
13910
|
+
state.width = Math.max(MINI_WIDTH_LIMIT, width - moveLeft);
|
|
13911
|
+
state.height = Math.max(MINI_HEIGHT_LIMIT, height - moveTop);
|
|
12464
13912
|
state.left = left + width - state.width;
|
|
12465
13913
|
state.top = top + height - state.height;
|
|
12466
13914
|
break;
|
|
12467
13915
|
case "__SpreadsheetTransformerResizeCT__":
|
|
12468
|
-
state.height =
|
|
13916
|
+
state.height = Math.max(MINI_HEIGHT_LIMIT, height - moveTop);
|
|
12469
13917
|
state.top = top + height - state.height;
|
|
12470
13918
|
break;
|
|
12471
13919
|
case "__SpreadsheetTransformerResizeRT__":
|
|
12472
|
-
state.width =
|
|
12473
|
-
state.height =
|
|
13920
|
+
state.width = Math.max(MINI_WIDTH_LIMIT, width + moveLeft);
|
|
13921
|
+
state.height = Math.max(MINI_HEIGHT_LIMIT, height - moveTop);
|
|
12474
13922
|
state.top = top + height - state.height;
|
|
12475
13923
|
break;
|
|
12476
13924
|
case "__SpreadsheetTransformerResizeLM__":
|
|
12477
|
-
state.width =
|
|
13925
|
+
state.width = Math.max(MINI_WIDTH_LIMIT, width - moveLeft);
|
|
12478
13926
|
state.left = left + width - state.width;
|
|
12479
13927
|
break;
|
|
12480
13928
|
case "__SpreadsheetTransformerResizeRM__":
|
|
12481
|
-
state.width =
|
|
13929
|
+
state.width = Math.max(MINI_WIDTH_LIMIT, moveLeft + width);
|
|
12482
13930
|
break;
|
|
12483
13931
|
case "__SpreadsheetTransformerResizeLB__":
|
|
12484
|
-
state.width =
|
|
12485
|
-
state.height =
|
|
13932
|
+
state.width = Math.max(MINI_WIDTH_LIMIT, width - moveLeft);
|
|
13933
|
+
state.height = Math.max(MINI_HEIGHT_LIMIT, height + moveTop);
|
|
12486
13934
|
state.left = state.width <= MINI_WIDTH_LIMIT ? left : left + moveLeft;
|
|
12487
13935
|
break;
|
|
12488
13936
|
case "__SpreadsheetTransformerResizeCB__":
|
|
12489
|
-
state.height =
|
|
13937
|
+
state.height = Math.max(MINI_HEIGHT_LIMIT, moveTop + height);
|
|
12490
13938
|
break;
|
|
12491
13939
|
case "__SpreadsheetTransformerResizeRB__":
|
|
12492
|
-
state.width =
|
|
12493
|
-
state.height =
|
|
13940
|
+
state.width = Math.max(MINI_WIDTH_LIMIT, moveLeft + width);
|
|
13941
|
+
state.height = Math.max(MINI_HEIGHT_LIMIT, moveTop + height);
|
|
12494
13942
|
}
|
|
12495
13943
|
return state;
|
|
12496
13944
|
}
|
|
@@ -12506,7 +13954,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12506
13954
|
}
|
|
12507
13955
|
_resizeLeftTop(moveObject, moveLeft, moveTop, originState) {
|
|
12508
13956
|
const { left = 0, top = 0, width = 0, height = 0 } = moveObject.getState();
|
|
12509
|
-
const { width: originWidth = width, height: originHeight = height
|
|
13957
|
+
const { width: originWidth = width, height: originHeight = height } = originState;
|
|
12510
13958
|
const aspectRatio = originWidth / originHeight;
|
|
12511
13959
|
const { moveLeft: moveLeftFix, moveTop: moveTopFix } = this._fixMoveLtRb(moveLeft, moveTop, originWidth, originHeight, aspectRatio);
|
|
12512
13960
|
let newWidth = originWidth - moveLeftFix;
|
|
@@ -12523,7 +13971,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12523
13971
|
}
|
|
12524
13972
|
_resizeRightBottom(moveObject, moveLeft, moveTop, originState) {
|
|
12525
13973
|
const { left = 0, top = 0, width = 0, height = 0 } = moveObject.getState();
|
|
12526
|
-
const { width: originWidth = width, height: originHeight = height
|
|
13974
|
+
const { width: originWidth = width, height: originHeight = height } = originState;
|
|
12527
13975
|
const aspectRatio = originWidth / originHeight;
|
|
12528
13976
|
const { moveLeft: moveLeftFix, moveTop: moveTopFix } = this._fixMoveLtRb(moveLeft, moveTop, originWidth, originHeight, aspectRatio);
|
|
12529
13977
|
let newWidth = originWidth + moveLeftFix;
|
|
@@ -12540,7 +13988,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12540
13988
|
}
|
|
12541
13989
|
_resizeLeftBottom(moveObject, moveLeft, moveTop, originState) {
|
|
12542
13990
|
const { left = 0, top = 0, width = 0, height = 0 } = moveObject.getState();
|
|
12543
|
-
const { width: originWidth = width, height: originHeight = height
|
|
13991
|
+
const { width: originWidth = width, height: originHeight = height } = originState;
|
|
12544
13992
|
const aspectRatio = originWidth / originHeight;
|
|
12545
13993
|
const { moveLeft: moveLeftFix, moveTop: moveTopFix } = this._fixMoveLbRt(moveLeft, moveTop, originWidth, originHeight, aspectRatio);
|
|
12546
13994
|
let newWidth = originWidth - moveLeftFix;
|
|
@@ -12557,7 +14005,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12557
14005
|
}
|
|
12558
14006
|
_resizeRightTop(moveObject, moveLeft, moveTop, originState) {
|
|
12559
14007
|
const { left = 0, top = 0, width = 0, height = 0 } = moveObject.getState();
|
|
12560
|
-
const { width: originWidth = width, height: originHeight = height
|
|
14008
|
+
const { width: originWidth = width, height: originHeight = height } = originState;
|
|
12561
14009
|
const aspectRatio = originWidth / originHeight;
|
|
12562
14010
|
const { moveLeft: moveLeftFix, moveTop: moveTopFix } = this._fixMoveLbRt(moveLeft, moveTop, originWidth, originHeight, aspectRatio);
|
|
12563
14011
|
let newWidth = originWidth + moveLeftFix;
|
|
@@ -12601,7 +14049,8 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12601
14049
|
this._startOffsetY = evtOffsetY;
|
|
12602
14050
|
const topScene = this._getTopScene();
|
|
12603
14051
|
const { keepRatio, isCropper } = this._getConfig(applyObject);
|
|
12604
|
-
|
|
14052
|
+
const transformObjects = this._getTransformObjects("resizeEnabled");
|
|
14053
|
+
if (topScene == null || !isCropper && !transformObjects.size) return;
|
|
12605
14054
|
(_topScene$getEngine = topScene.getEngine()) === null || _topScene$getEngine === void 0 || _topScene$getEngine.setCapture();
|
|
12606
14055
|
topScene.disableObjectsEvent();
|
|
12607
14056
|
const scrollTimer = ScrollTimer.create(topScene);
|
|
@@ -12618,7 +14067,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12618
14067
|
objects: this._selectedObjectMap,
|
|
12619
14068
|
type: 0
|
|
12620
14069
|
});
|
|
12621
|
-
|
|
14070
|
+
transformObjects.forEach((moveObject) => {
|
|
12622
14071
|
const { width, height, left, top } = moveObject.getState();
|
|
12623
14072
|
this._startStateMap.set(moveObject.oKey, {
|
|
12624
14073
|
width,
|
|
@@ -12643,9 +14092,9 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12643
14092
|
this._moveBufferSkip = false;
|
|
12644
14093
|
const moveSubscription = topScene.onPointerMove$.subscribeEvent((moveEvt) => {
|
|
12645
14094
|
const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt;
|
|
12646
|
-
this._anchorMoving(type, moveOffsetX, moveOffsetY, scrollTimer, keepRatio, isCropper, applyObject);
|
|
14095
|
+
this._anchorMoving(type, moveOffsetX, moveOffsetY, scrollTimer, keepRatio, isCropper, applyObject, transformObjects);
|
|
12647
14096
|
scrollTimer.scrolling(moveOffsetX, moveOffsetY, () => {
|
|
12648
|
-
this._anchorMoving(type, moveOffsetX, moveOffsetY, scrollTimer, keepRatio, isCropper, applyObject);
|
|
14097
|
+
this._anchorMoving(type, moveOffsetX, moveOffsetY, scrollTimer, keepRatio, isCropper, applyObject, transformObjects);
|
|
12649
14098
|
});
|
|
12650
14099
|
topScene.setCursor(cursor);
|
|
12651
14100
|
});
|
|
@@ -12656,25 +14105,16 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12656
14105
|
scrollTimer.dispose();
|
|
12657
14106
|
this._startStateMap.clear();
|
|
12658
14107
|
const { offsetX, offsetY } = event;
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
}
|
|
12669
|
-
this._recoverySizeBoundary([applyObject], ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight);
|
|
12670
|
-
this._changeEnd$.next({
|
|
12671
|
-
objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
|
|
12672
|
-
type: 2,
|
|
12673
|
-
offsetX,
|
|
12674
|
-
offsetY,
|
|
12675
|
-
event
|
|
12676
|
-
});
|
|
12677
|
-
}
|
|
14108
|
+
const objects = isCropper ? /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]) : this._selectedObjectMap;
|
|
14109
|
+
const transformedObjects = isCropper ? [applyObject] : Array.from(transformObjects.values());
|
|
14110
|
+
this._recoverySizeBoundary(transformedObjects, ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight);
|
|
14111
|
+
this._changeEnd$.next({
|
|
14112
|
+
objects,
|
|
14113
|
+
type: 2,
|
|
14114
|
+
offsetX,
|
|
14115
|
+
offsetY,
|
|
14116
|
+
event
|
|
14117
|
+
});
|
|
12678
14118
|
this.refreshControls();
|
|
12679
14119
|
});
|
|
12680
14120
|
state.stopPropagation();
|
|
@@ -12688,12 +14128,12 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12688
14128
|
const newTransform = {};
|
|
12689
14129
|
if (left + ancestorLeft < this.zeroLeft) {
|
|
12690
14130
|
newTransform.left = this.zeroLeft - ancestorLeft;
|
|
12691
|
-
newTransform.width = width + left;
|
|
12692
|
-
} else if (left + width + ancestorLeft > topSceneWidth
|
|
14131
|
+
newTransform.width = width + left + ancestorLeft - this.zeroLeft;
|
|
14132
|
+
} else if (left + width + ancestorLeft > topSceneWidth) newTransform.width = topSceneWidth - left - ancestorLeft;
|
|
12693
14133
|
if (top + ancestorTop < this.zeroTop) {
|
|
12694
14134
|
newTransform.top = this.zeroTop - ancestorTop;
|
|
12695
|
-
newTransform.height = height + top;
|
|
12696
|
-
} else if (top + height + ancestorTop > topSceneHeight
|
|
14135
|
+
newTransform.height = height + top + ancestorTop - this.zeroTop;
|
|
14136
|
+
} else if (top + height + ancestorTop > topSceneHeight) newTransform.height = topSceneHeight - top - ancestorTop;
|
|
12697
14137
|
moveObject.transformByState(newTransform);
|
|
12698
14138
|
}
|
|
12699
14139
|
}
|
|
@@ -12964,7 +14404,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
12964
14404
|
return anchor;
|
|
12965
14405
|
}
|
|
12966
14406
|
_createCopperResizeAnchor(type, applyObject, zIndex) {
|
|
12967
|
-
var _applyObject$
|
|
14407
|
+
var _applyObject$transfor2;
|
|
12968
14408
|
const { height = 0, width = 0 } = this._getControlState(applyObject);
|
|
12969
14409
|
const { anchorFill, anchorStroke, anchorStrokeWidth, anchorSize } = this._getConfig(applyObject);
|
|
12970
14410
|
const { left, top } = this._getCopperAnchorPosition(type, height, width, applyObject);
|
|
@@ -13017,7 +14457,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
13017
14457
|
y: config.height ?? 0
|
|
13018
14458
|
}
|
|
13019
14459
|
]];
|
|
13020
|
-
const anchor = new TransformerCropAnchor(oKey, config, ((_applyObject$
|
|
14460
|
+
const anchor = new TransformerCropAnchor(oKey, config, ((_applyObject$transfor2 = applyObject.transformerConfig) === null || _applyObject$transfor2 === void 0 ? void 0 : _applyObject$transfor2.cropAnchorHitSize) ?? 0);
|
|
13021
14461
|
this._attachHover(anchor, cursor, "default");
|
|
13022
14462
|
return anchor;
|
|
13023
14463
|
}
|
|
@@ -13165,8 +14605,8 @@ var Transformer = class Transformer extends Disposable {
|
|
|
13165
14605
|
});
|
|
13166
14606
|
}
|
|
13167
14607
|
_getControlState(applyObject) {
|
|
13168
|
-
var _applyObject$
|
|
13169
|
-
return ((_applyObject$
|
|
14608
|
+
var _applyObject$transfor3, _applyObject$transfor4;
|
|
14609
|
+
return ((_applyObject$transfor3 = applyObject.transformerConfig) === null || _applyObject$transfor3 === void 0 || (_applyObject$transfor4 = _applyObject$transfor3.controlStateResolver) === null || _applyObject$transfor4 === void 0 ? void 0 : _applyObject$transfor4.call(_applyObject$transfor3, applyObject)) ?? applyObject.getState();
|
|
13170
14610
|
}
|
|
13171
14611
|
_updateControl() {
|
|
13172
14612
|
this._updateControlIterator((control, applyObject) => {
|
|
@@ -13180,6 +14620,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
13180
14620
|
});
|
|
13181
14621
|
control.show();
|
|
13182
14622
|
control.makeDirty(true);
|
|
14623
|
+
this._updateRotationControl(control, applyObject);
|
|
13183
14624
|
});
|
|
13184
14625
|
}
|
|
13185
14626
|
_hideControl() {
|
|
@@ -13205,7 +14646,10 @@ var Transformer = class Transformer extends Disposable {
|
|
|
13205
14646
|
* @param {string[]} ids the id of the object to be cleared
|
|
13206
14647
|
*/
|
|
13207
14648
|
clearControlByIds(ids) {
|
|
13208
|
-
for (const id of ids)
|
|
14649
|
+
for (const id of ids) {
|
|
14650
|
+
this._selectedObjectMap.delete(id);
|
|
14651
|
+
this._rotationSides.delete(id);
|
|
14652
|
+
}
|
|
13209
14653
|
this.refreshControls();
|
|
13210
14654
|
}
|
|
13211
14655
|
_clearControlMap() {
|
|
@@ -13213,15 +14657,15 @@ var Transformer = class Transformer extends Disposable {
|
|
|
13213
14657
|
control.dispose();
|
|
13214
14658
|
});
|
|
13215
14659
|
this._transformerControlMap.clear();
|
|
14660
|
+
this._rotationControls.clear();
|
|
13216
14661
|
}
|
|
13217
14662
|
_createControl(applyObject, isSkipOnCropper = true) {
|
|
13218
|
-
var _applyObject$transfor4;
|
|
13219
14663
|
const { left = 0, top = 0, height = 0, width = 0, angle = 0 } = this._getControlState(applyObject);
|
|
13220
|
-
const { isCropper, resizeEnabled, rotateEnabled,
|
|
14664
|
+
const { isCropper, resizeEnabled, rotateEnabled, borderEnabled, borderStroke, borderStrokeWidth, borderSpacing, enabledAnchors } = this._getConfig(applyObject);
|
|
13221
14665
|
if (isSkipOnCropper && isCropper) return;
|
|
13222
14666
|
const oKey = applyObject.oKey;
|
|
13223
14667
|
const zIndex = this._selectedObjectMap.size + applyObject.maxZIndex + DEFAULT_CONTROL_PLUS_INDEX;
|
|
13224
|
-
const layerIndex = (
|
|
14668
|
+
const layerIndex = this._getConfig(applyObject).controlLayerIndex ?? (applyObject.getLayerIndex() || DEFAULT_TRANSFORMER_LAYER_INDEX);
|
|
13225
14669
|
const groupElements = [];
|
|
13226
14670
|
if (borderEnabled && !isCropper) {
|
|
13227
14671
|
const outline = new Rect(`__SpreadsheetTransformerOutline___${zIndex}`, {
|
|
@@ -13233,53 +14677,8 @@ var Transformer = class Transformer extends Disposable {
|
|
|
13233
14677
|
});
|
|
13234
14678
|
groupElements.push(outline);
|
|
13235
14679
|
}
|
|
13236
|
-
if (resizeEnabled && !isCropper)
|
|
13237
|
-
|
|
13238
|
-
if (rotateEnabled) {
|
|
13239
|
-
const rotateLine = new Line(`__SpreadsheetTransformerRotateLine___${zIndex}`, {
|
|
13240
|
-
zIndex: zIndex - 1,
|
|
13241
|
-
evented: false,
|
|
13242
|
-
startX: lineLeft,
|
|
13243
|
-
startY: lineTop,
|
|
13244
|
-
endX: lineLeft,
|
|
13245
|
-
endY: lineTop + rotateAnchorOffset,
|
|
13246
|
-
strokeWidth: borderStrokeWidth,
|
|
13247
|
-
strokeLineCap: "butt",
|
|
13248
|
-
stroke: rotateStroke ?? borderStroke
|
|
13249
|
-
});
|
|
13250
|
-
const { left: rotateLeft, top: rotateTop } = this._getRotateAnchorPosition("__SpreadsheetTransformerRotate__", height, width, applyObject);
|
|
13251
|
-
const cursor = this._getRotateAnchorCursor("__SpreadsheetTransformerRotate__");
|
|
13252
|
-
const rotate = new TransformerAnchor(`__SpreadsheetTransformerRotate___${zIndex}`, {
|
|
13253
|
-
zIndex: zIndex - 1,
|
|
13254
|
-
left: rotateLeft,
|
|
13255
|
-
top: rotateTop,
|
|
13256
|
-
height: rotateSize,
|
|
13257
|
-
width: rotateSize,
|
|
13258
|
-
radius: rotateCornerRadius,
|
|
13259
|
-
fill: rotateFill,
|
|
13260
|
-
strokeWidth: rotateStrokeWidth ?? borderStrokeWidth * 2,
|
|
13261
|
-
stroke: rotateStroke ?? borderStroke,
|
|
13262
|
-
shadowColor: anchorShadowColor,
|
|
13263
|
-
shadowBlur: anchorShadowBlur,
|
|
13264
|
-
shadowOffsetX: anchorShadowOffsetX,
|
|
13265
|
-
shadowOffsetY: anchorShadowOffsetY
|
|
13266
|
-
});
|
|
13267
|
-
this._attachEventToRotate(rotate, applyObject);
|
|
13268
|
-
this._attachHover(rotate, cursor, "default");
|
|
13269
|
-
if (rotateLineEnabled) groupElements.push(rotateLine);
|
|
13270
|
-
groupElements.push(rotate);
|
|
13271
|
-
if (rotateIconEnabled) groupElements.push(this._createRotateIcon(applyObject, zIndex, rotateLeft, rotateTop));
|
|
13272
|
-
}
|
|
13273
|
-
}
|
|
13274
|
-
if (resizeEnabled) for (let i = 0, len = enabledAnchors.length; i < len; i++) {
|
|
13275
|
-
if (enabledAnchors[i] !== 1) continue;
|
|
13276
|
-
const type = TransformerManagerTypeArray[i];
|
|
13277
|
-
let anchor;
|
|
13278
|
-
if (!isCropper) anchor = this._createResizeAnchor(type, applyObject, zIndex);
|
|
13279
|
-
else anchor = this._createCopperResizeAnchor(type, applyObject, zIndex);
|
|
13280
|
-
this._attachEventToAnchor(anchor, type, applyObject);
|
|
13281
|
-
groupElements.push(anchor);
|
|
13282
|
-
}
|
|
14680
|
+
if (resizeEnabled && rotateEnabled && !isCropper) groupElements.push(...this._createRotationControls(applyObject, zIndex, width, height));
|
|
14681
|
+
if (resizeEnabled) groupElements.push(...this._createResizeControls(applyObject, zIndex, isCropper, enabledAnchors));
|
|
13283
14682
|
const transformerControl = new Group(`__SpreadsheetTransformer___${oKey}`, ...groupElements);
|
|
13284
14683
|
transformerControl.zIndex = zIndex;
|
|
13285
14684
|
transformerControl.evented = false;
|
|
@@ -13293,12 +14692,214 @@ var Transformer = class Transformer extends Disposable {
|
|
|
13293
14692
|
});
|
|
13294
14693
|
this.getScene().addObject(transformerControl, layerIndex);
|
|
13295
14694
|
if (!isCropper) {
|
|
13296
|
-
|
|
14695
|
+
var _this$_transformerCon;
|
|
14696
|
+
(_this$_transformerCon = this._transformerControlMap.get(oKey)) === null || _this$_transformerCon === void 0 || _this$_transformerCon.dispose();
|
|
13297
14697
|
this._transformerControlMap.set(oKey, transformerControl);
|
|
14698
|
+
this._updateRotationControl(transformerControl, applyObject);
|
|
13298
14699
|
this._createControl$.next(transformerControl);
|
|
13299
14700
|
} else this._copperControl = transformerControl;
|
|
13300
14701
|
return transformerControl;
|
|
13301
14702
|
}
|
|
14703
|
+
_createResizeControls(applyObject, zIndex, isCropper, enabledAnchors) {
|
|
14704
|
+
const anchors = [];
|
|
14705
|
+
for (let i = 0, len = enabledAnchors.length; i < len; i++) {
|
|
14706
|
+
if (enabledAnchors[i] !== 1) continue;
|
|
14707
|
+
const type = TransformerManagerTypeArray[i];
|
|
14708
|
+
let anchor;
|
|
14709
|
+
if (!isCropper) anchor = this._createResizeAnchor(type, applyObject, zIndex);
|
|
14710
|
+
else anchor = this._createCopperResizeAnchor(type, applyObject, zIndex);
|
|
14711
|
+
this._attachEventToAnchor(anchor, type, applyObject);
|
|
14712
|
+
anchors.push(anchor);
|
|
14713
|
+
}
|
|
14714
|
+
return anchors;
|
|
14715
|
+
}
|
|
14716
|
+
_createRotationControls(applyObject, zIndex, width, height) {
|
|
14717
|
+
const config = this._getConfig(applyObject);
|
|
14718
|
+
const { rotateSize, borderStrokeWidth, borderStroke } = config;
|
|
14719
|
+
const position = this._getRotateAnchorPosition("__SpreadsheetTransformerRotate__", height, width, applyObject);
|
|
14720
|
+
const line = new Line(`__SpreadsheetTransformerRotateLine___${zIndex}`, {
|
|
14721
|
+
startX: 0,
|
|
14722
|
+
startY: 0,
|
|
14723
|
+
endX: 0,
|
|
14724
|
+
endY: 0,
|
|
14725
|
+
zIndex: zIndex - 1,
|
|
14726
|
+
evented: false,
|
|
14727
|
+
strokeWidth: borderStrokeWidth,
|
|
14728
|
+
strokeLineCap: "butt",
|
|
14729
|
+
stroke: config.rotateStroke ?? borderStroke
|
|
14730
|
+
});
|
|
14731
|
+
const handle = new TransformerAnchor(`__SpreadsheetTransformerRotate___${zIndex}`, {
|
|
14732
|
+
zIndex: zIndex - 1,
|
|
14733
|
+
...position,
|
|
14734
|
+
width: rotateSize,
|
|
14735
|
+
height: rotateSize,
|
|
14736
|
+
radius: config.rotateCornerRadius,
|
|
14737
|
+
fill: config.rotateFill,
|
|
14738
|
+
strokeWidth: config.rotateStrokeWidth ?? borderStrokeWidth * 2,
|
|
14739
|
+
stroke: config.rotateStroke ?? borderStroke,
|
|
14740
|
+
shadowColor: config.anchorShadowColor,
|
|
14741
|
+
shadowBlur: config.anchorShadowBlur,
|
|
14742
|
+
shadowOffsetX: config.anchorShadowOffsetX,
|
|
14743
|
+
shadowOffsetY: config.anchorShadowOffsetY
|
|
14744
|
+
});
|
|
14745
|
+
const icon = config.rotateIconEnabled ? this._createRotateIcon(applyObject, zIndex, position.left, position.top) : void 0;
|
|
14746
|
+
this._attachEventToRotate(handle, applyObject);
|
|
14747
|
+
this._attachHover(handle, this._getRotateAnchorCursor("__SpreadsheetTransformerRotate__"), "default");
|
|
14748
|
+
this._rotationControls.set(applyObject.oKey, {
|
|
14749
|
+
handle,
|
|
14750
|
+
icon,
|
|
14751
|
+
line
|
|
14752
|
+
});
|
|
14753
|
+
return icon ? [
|
|
14754
|
+
line,
|
|
14755
|
+
handle,
|
|
14756
|
+
icon
|
|
14757
|
+
] : [line, handle];
|
|
14758
|
+
}
|
|
14759
|
+
_updateRotationControls() {
|
|
14760
|
+
if (this._finishGesture) return;
|
|
14761
|
+
const obstaclesByViewport = /* @__PURE__ */ new Map();
|
|
14762
|
+
this._updateControlIterator((control, object) => this._updateRotationControl(control, object, obstaclesByViewport));
|
|
14763
|
+
}
|
|
14764
|
+
_getRotationViewport(control) {
|
|
14765
|
+
let best;
|
|
14766
|
+
let maxArea = 0;
|
|
14767
|
+
const corners = [
|
|
14768
|
+
new Vector2(0, 0),
|
|
14769
|
+
new Vector2(control.width, 0),
|
|
14770
|
+
new Vector2(control.width, control.height),
|
|
14771
|
+
new Vector2(0, control.height)
|
|
14772
|
+
].map((point) => control.ancestorTransform.applyPoint(point));
|
|
14773
|
+
for (const viewport of this._scene.getViewports()) {
|
|
14774
|
+
if (!viewport.shouldIntoRender()) continue;
|
|
14775
|
+
const bar = viewport.getScrollBar();
|
|
14776
|
+
const bounds = {
|
|
14777
|
+
left: Math.max(viewport.left, this.zeroLeft * this._scene.scaleX),
|
|
14778
|
+
top: Math.max(viewport.top, this.zeroTop * this._scene.scaleY),
|
|
14779
|
+
right: viewport.left + (viewport.width ?? 0) - ((bar === null || bar === void 0 ? void 0 : bar.enableVertical) ? bar.totalSize : 0),
|
|
14780
|
+
bottom: viewport.top + (viewport.height ?? 0) - ((bar === null || bar === void 0 ? void 0 : bar.enableHorizontal) ? bar.totalSize : 0)
|
|
14781
|
+
};
|
|
14782
|
+
const screenCorners = corners.map((point) => viewport.getAbsoluteVector(point.clone()));
|
|
14783
|
+
const left = Math.max(bounds.left, Math.min(...screenCorners.map((point) => point.x)));
|
|
14784
|
+
const top = Math.max(bounds.top, Math.min(...screenCorners.map((point) => point.y)));
|
|
14785
|
+
const right = Math.min(bounds.right, Math.max(...screenCorners.map((point) => point.x)));
|
|
14786
|
+
const bottom = Math.min(bounds.bottom, Math.max(...screenCorners.map((point) => point.y)));
|
|
14787
|
+
const area = Math.max(0, right - left) * Math.max(0, bottom - top);
|
|
14788
|
+
if (area > maxArea) {
|
|
14789
|
+
maxArea = area;
|
|
14790
|
+
best = {
|
|
14791
|
+
viewport,
|
|
14792
|
+
bounds,
|
|
14793
|
+
corners: screenCorners
|
|
14794
|
+
};
|
|
14795
|
+
}
|
|
14796
|
+
}
|
|
14797
|
+
return best;
|
|
14798
|
+
}
|
|
14799
|
+
_getRotationObstacles(viewport) {
|
|
14800
|
+
return this._scene.getAllObjectsByOrderForPick().filter((object) => object instanceof Control && object.visible && object.evented && !object.oKey.includes("__SpreadsheetTransformerRotate__")).map((object) => {
|
|
14801
|
+
const transform = object.ancestorTransform;
|
|
14802
|
+
const center = viewport.getAbsoluteVector(transform.applyPoint(new Vector2(object.width / 2, object.height / 2)));
|
|
14803
|
+
const corner = viewport.getAbsoluteVector(transform.applyPoint(new Vector2(0, 0)));
|
|
14804
|
+
return {
|
|
14805
|
+
...center,
|
|
14806
|
+
radius: Math.hypot(corner.x - center.x, corner.y - center.y)
|
|
14807
|
+
};
|
|
14808
|
+
});
|
|
14809
|
+
}
|
|
14810
|
+
_updateRotationControl(control, applyObject, obstaclesByViewport = /* @__PURE__ */ new Map()) {
|
|
14811
|
+
const controls = this._rotationControls.get(applyObject.oKey);
|
|
14812
|
+
if (!controls) return;
|
|
14813
|
+
const view = this._getRotationViewport(control);
|
|
14814
|
+
if (!view) {
|
|
14815
|
+
this._hideRotationControls(controls);
|
|
14816
|
+
return;
|
|
14817
|
+
}
|
|
14818
|
+
const { viewport, bounds, corners } = view;
|
|
14819
|
+
let obstacles = obstaclesByViewport.get(viewport);
|
|
14820
|
+
if (!obstacles) {
|
|
14821
|
+
obstacles = this._getRotationObstacles(viewport);
|
|
14822
|
+
obstaclesByViewport.set(viewport, obstacles);
|
|
14823
|
+
}
|
|
14824
|
+
const config = this._getConfig(applyObject);
|
|
14825
|
+
const transform = control.ancestorTransform;
|
|
14826
|
+
const toScreen = (point) => viewport.getAbsoluteVector(transform.applyPoint(point));
|
|
14827
|
+
const candidate = (side) => {
|
|
14828
|
+
const direction = side === "top" ? -1 : 1;
|
|
14829
|
+
const edge = side === "top" ? 0 : control.height;
|
|
14830
|
+
return {
|
|
14831
|
+
side,
|
|
14832
|
+
center: toScreen(new Vector2(control.width / 2, edge + direction * (config.rotateAnchorOffset + config.borderSpacing + config.borderStrokeWidth * 2 + config.rotateSize / 2))),
|
|
14833
|
+
attachment: toScreen(new Vector2(control.width / 2, edge + direction * (config.borderSpacing + config.borderStrokeWidth)))
|
|
14834
|
+
};
|
|
14835
|
+
};
|
|
14836
|
+
const center = toScreen(new Vector2(control.width / 2, control.height / 2));
|
|
14837
|
+
const scale = this._scene.getAncestorScale();
|
|
14838
|
+
const artworkRadius = (config.rotateSize / 2 + controls.handle.strokeWidth) * Math.max(scale.scaleX, scale.scaleY);
|
|
14839
|
+
const placement = placeRotationHandle({
|
|
14840
|
+
bounds,
|
|
14841
|
+
corners,
|
|
14842
|
+
radius: Math.max(22, artworkRadius),
|
|
14843
|
+
artworkRadius,
|
|
14844
|
+
preferred: candidate(config.rotateAnchorPosition),
|
|
14845
|
+
opposite: candidate(config.rotateAnchorPosition === "top" ? "bottom" : "top"),
|
|
14846
|
+
obstacles: [...obstacles, {
|
|
14847
|
+
...center,
|
|
14848
|
+
radius: 0
|
|
14849
|
+
}],
|
|
14850
|
+
previousSide: this._rotationSides.get(applyObject.oKey)
|
|
14851
|
+
});
|
|
14852
|
+
if (!placement) {
|
|
14853
|
+
this._hideRotationControls(controls);
|
|
14854
|
+
return;
|
|
14855
|
+
}
|
|
14856
|
+
this._rotationSides.set(applyObject.oKey, placement.side);
|
|
14857
|
+
const toLocal = (point) => transform.clone().invert().applyPoint(viewport.transformVector2SceneCoord(new Vector2(point.x, point.y)));
|
|
14858
|
+
this._positionRotationControls(controls, toLocal(placement.center), toLocal(placement.attachment), config.rotateLineEnabled || placement.adjusted);
|
|
14859
|
+
}
|
|
14860
|
+
_hideRotationControls(controls) {
|
|
14861
|
+
for (const control of Object.values(controls)) if (control === null || control === void 0 ? void 0 : control.visible) {
|
|
14862
|
+
control.hide();
|
|
14863
|
+
this._scene.makeDirty();
|
|
14864
|
+
}
|
|
14865
|
+
}
|
|
14866
|
+
_positionRotationControls(controls, center, attachment, showLine) {
|
|
14867
|
+
const { handle, icon, line } = controls;
|
|
14868
|
+
const left = center.x - handle.width / 2 - handle.strokeWidth / 2;
|
|
14869
|
+
const top = center.y - handle.height / 2 - handle.strokeWidth / 2;
|
|
14870
|
+
if (Math.abs(handle.left - left) > .01 || Math.abs(handle.top - top) > .01) {
|
|
14871
|
+
this._scene.makeDirty();
|
|
14872
|
+
handle.transformByState({
|
|
14873
|
+
left,
|
|
14874
|
+
top
|
|
14875
|
+
});
|
|
14876
|
+
icon === null || icon === void 0 || icon.transformByState({
|
|
14877
|
+
left: center.x - icon.width / 2 - icon.strokeWidth / 2,
|
|
14878
|
+
top: center.y - icon.height / 2 - icon.strokeWidth / 2
|
|
14879
|
+
});
|
|
14880
|
+
}
|
|
14881
|
+
if (!handle.visible) {
|
|
14882
|
+
this._scene.makeDirty();
|
|
14883
|
+
handle.show();
|
|
14884
|
+
}
|
|
14885
|
+
if (icon && !icon.visible) icon.show();
|
|
14886
|
+
const distance = Math.hypot(center.x - attachment.x, center.y - attachment.y);
|
|
14887
|
+
const t = Math.max(0, 1 - handle.width / 2 / Math.max(distance, 1));
|
|
14888
|
+
const endX = attachment.x + (center.x - attachment.x) * t;
|
|
14889
|
+
const endY = attachment.y + (center.y - attachment.y) * t;
|
|
14890
|
+
if (line.startX !== attachment.x || line.startY !== attachment.y || line.endX !== endX || line.endY !== endY) {
|
|
14891
|
+
this._scene.makeDirty();
|
|
14892
|
+
line.setProps({
|
|
14893
|
+
startX: attachment.x,
|
|
14894
|
+
startY: attachment.y,
|
|
14895
|
+
endX,
|
|
14896
|
+
endY
|
|
14897
|
+
});
|
|
14898
|
+
}
|
|
14899
|
+
if (showLine !== line.visible) this._scene.makeDirty();
|
|
14900
|
+
if (showLine && !line.visible) line.show();
|
|
14901
|
+
else if (!showLine && line.visible) line.hide();
|
|
14902
|
+
}
|
|
13302
14903
|
_getTopScene() {
|
|
13303
14904
|
var _currentScene$getEngi;
|
|
13304
14905
|
return (_currentScene$getEngi = this.getScene().getEngine()) === null || _currentScene$getEngi === void 0 ? void 0 : _currentScene$getEngi.activeScene;
|
|
@@ -13320,6 +14921,7 @@ var Transformer = class Transformer extends Disposable {
|
|
|
13320
14921
|
}
|
|
13321
14922
|
if (!evt.ctrlKey) {
|
|
13322
14923
|
this._selectedObjectMap.clear();
|
|
14924
|
+
this._rotationSides.clear();
|
|
13323
14925
|
this._clearControlMap();
|
|
13324
14926
|
}
|
|
13325
14927
|
if (!isCropper) this._selectedObjectMap.set(targetObject.oKey, targetObject);
|
|
@@ -13464,6 +15066,10 @@ var Scene = class extends Disposable {
|
|
|
13464
15066
|
_defineProperty(this, "_layers", []);
|
|
13465
15067
|
_defineProperty(this, "_viewports", []);
|
|
13466
15068
|
_defineProperty(this, "_preserveEngineOnRender", false);
|
|
15069
|
+
_defineProperty(this, "_viewportCacheReuseKey", null);
|
|
15070
|
+
_defineProperty(this, "_viewportCacheReuseBlocked", true);
|
|
15071
|
+
_defineProperty(this, "_viewportCacheReusePending", false);
|
|
15072
|
+
_defineProperty(this, "_renderedViewportCacheKey", null);
|
|
13467
15073
|
_defineProperty(this, "_hasPostRenderCanvasMutation", false);
|
|
13468
15074
|
_defineProperty(this, "_scrollbarDragViewport", null);
|
|
13469
15075
|
_defineProperty(this, "_isScrollbarSeeking", false);
|
|
@@ -13493,6 +15099,8 @@ var Scene = class extends Disposable {
|
|
|
13493
15099
|
_defineProperty(this, "onDblclick$", new EventSubject());
|
|
13494
15100
|
_defineProperty(this, "onTripleClick$", new EventSubject());
|
|
13495
15101
|
_defineProperty(this, "onMouseWheel$", new EventSubject());
|
|
15102
|
+
_defineProperty(this, "_prepareRender$", new Subject());
|
|
15103
|
+
_defineProperty(this, "prepareRender$", this._prepareRender$.asObservable());
|
|
13496
15104
|
_defineProperty(this, "_beforeRender$", new BehaviorSubject(null));
|
|
13497
15105
|
_defineProperty(this, "beforeRender$", this._beforeRender$.asObservable());
|
|
13498
15106
|
_defineProperty(this, "_afterRender$", new BehaviorSubject(null));
|
|
@@ -13602,6 +15210,7 @@ var Scene = class extends Disposable {
|
|
|
13602
15210
|
return this;
|
|
13603
15211
|
}
|
|
13604
15212
|
makeDirty(state = true) {
|
|
15213
|
+
if (state) this.invalidateViewportCacheReuse();
|
|
13605
15214
|
this._preserveEngineOnRender = false;
|
|
13606
15215
|
this._layers.forEach((layer) => {
|
|
13607
15216
|
layer.makeDirty(state);
|
|
@@ -13613,12 +15222,68 @@ var Scene = class extends Disposable {
|
|
|
13613
15222
|
return this;
|
|
13614
15223
|
}
|
|
13615
15224
|
makeDirtyForScrolling() {
|
|
15225
|
+
if (this._viewportCacheReusePending) return this;
|
|
13616
15226
|
this._preserveEngineOnRender = true;
|
|
13617
15227
|
this._layers.forEach((layer) => {
|
|
13618
15228
|
layer.makeDirty(true);
|
|
13619
15229
|
});
|
|
13620
15230
|
return this;
|
|
13621
15231
|
}
|
|
15232
|
+
setViewportCacheReuseKey(key) {
|
|
15233
|
+
this._viewportCacheReuseKey = key;
|
|
15234
|
+
this._renderedViewportCacheKey = null;
|
|
15235
|
+
this.invalidateViewportCacheReuse();
|
|
15236
|
+
}
|
|
15237
|
+
invalidateViewportCacheReuse() {
|
|
15238
|
+
this._viewportCacheReuseBlocked = true;
|
|
15239
|
+
this._viewportCacheReusePending = false;
|
|
15240
|
+
}
|
|
15241
|
+
isViewportCacheReusePending() {
|
|
15242
|
+
return this._viewportCacheReusePending;
|
|
15243
|
+
}
|
|
15244
|
+
makeDirtyForViewportScroll(viewport) {
|
|
15245
|
+
const geometry = this._getViewportCacheGeometry();
|
|
15246
|
+
if (!(viewport.viewportKey === this._viewportCacheReuseKey && !this._viewportCacheReuseBlocked && !this._preserveEngineOnRender && (!this.isDirty() || this._viewportCacheReusePending) && geometry != null && geometry.key === this._renderedViewportCacheKey && this._layers.some((layer) => layer.canReuseViewportCache()) && this._layers.every((layer) => layer.getObjectsByOrder().every((object) => !object.isDirty() && !object.isForceDirty())) && this._viewports.every((view) => !view.shouldIntoRender() || !view.isDirty && !view.isForceDirty))) {
|
|
15247
|
+
this.makeDirty(true);
|
|
15248
|
+
return;
|
|
15249
|
+
}
|
|
15250
|
+
this._viewportCacheReusePending = true;
|
|
15251
|
+
this._layers.forEach((layer) => layer.makeDirtyForViewportScroll());
|
|
15252
|
+
}
|
|
15253
|
+
_getViewportCacheGeometry() {
|
|
15254
|
+
var _this$getEngine;
|
|
15255
|
+
const main = this._viewportCacheReuseKey ? this.getViewport(this._viewportCacheReuseKey) : null;
|
|
15256
|
+
const canvas = (_this$getEngine = this.getEngine()) === null || _this$getEngine === void 0 ? void 0 : _this$getEngine.getCanvas();
|
|
15257
|
+
if (!main || !canvas || this._parent.classType !== "Engine" || this._beforeRender$.observed) return null;
|
|
15258
|
+
const bottom = main.top;
|
|
15259
|
+
const physicalBottom = bottom * canvas.getPixelRatio();
|
|
15260
|
+
if (!Number.isInteger(bottom) || !Number.isInteger(physicalBottom) || bottom <= 0 || bottom >= canvas.getHeight()) return null;
|
|
15261
|
+
const viewports = this._viewports.filter((viewport) => viewport.shouldIntoRender());
|
|
15262
|
+
if (viewports.some((viewport) => viewport.top < bottom && viewport.top + viewport.height > bottom)) return null;
|
|
15263
|
+
const stationary = viewports.filter((viewport) => viewport.top + viewport.height <= bottom);
|
|
15264
|
+
if (stationary.length === 0) return null;
|
|
15265
|
+
const viewportKeys = new Set(stationary.map((viewport) => viewport.viewportKey));
|
|
15266
|
+
return {
|
|
15267
|
+
key: JSON.stringify({
|
|
15268
|
+
width: canvas.getWidth(),
|
|
15269
|
+
height: canvas.getHeight(),
|
|
15270
|
+
ratio: canvas.getPixelRatio(),
|
|
15271
|
+
bottom,
|
|
15272
|
+
transform: this.transform.getMatrix(),
|
|
15273
|
+
viewports: viewports.map((viewport) => [
|
|
15274
|
+
viewport.viewportKey,
|
|
15275
|
+
viewport.left,
|
|
15276
|
+
viewport.top,
|
|
15277
|
+
viewport.width,
|
|
15278
|
+
viewport.height,
|
|
15279
|
+
viewport.viewportScrollX,
|
|
15280
|
+
viewportKeys.has(viewport.viewportKey) ? viewport.viewportScrollY : null
|
|
15281
|
+
])
|
|
15282
|
+
}),
|
|
15283
|
+
bottom,
|
|
15284
|
+
viewportKeys
|
|
15285
|
+
};
|
|
15286
|
+
}
|
|
13622
15287
|
beginScrollbarDrag(viewport) {
|
|
13623
15288
|
if (this._parent.classType !== "Engine") return;
|
|
13624
15289
|
this._scrollbarDragViewport = viewport;
|
|
@@ -13648,6 +15313,7 @@ var Scene = class extends Disposable {
|
|
|
13648
15313
|
return this._preserveEngineOnRender;
|
|
13649
15314
|
}
|
|
13650
15315
|
makeDirtyNoParent(state = true) {
|
|
15316
|
+
if (state) this.invalidateViewportCacheReuse();
|
|
13651
15317
|
this._preserveEngineOnRender = false;
|
|
13652
15318
|
this._layers.forEach((layer) => {
|
|
13653
15319
|
layer.makeDirty(state);
|
|
@@ -13993,10 +15659,10 @@ var Scene = class extends Disposable {
|
|
|
13993
15659
|
this._isScrollbarPreviewDirty = false;
|
|
13994
15660
|
}
|
|
13995
15661
|
_shouldDeferScrollbarSeekRender(now) {
|
|
13996
|
-
var _this$
|
|
15662
|
+
var _this$getEngine2;
|
|
13997
15663
|
if (!this._isScrollbarSeeking) return false;
|
|
13998
15664
|
if (now - this._lastScrollbarSeekInputAt >= SCROLLBAR_SEEK_SETTLE_MS) return false;
|
|
13999
|
-
const frameInterval = ((_this$
|
|
15665
|
+
const frameInterval = ((_this$getEngine2 = this.getEngine()) === null || _this$getEngine2 === void 0 ? void 0 : _this$getEngine2.getEstimatedFrameInterval()) ?? 1e3 / 60;
|
|
14000
15666
|
const expensiveRenderThreshold = Math.max(SCROLLBAR_SEEK_EXPENSIVE_RENDER_MIN_MS, frameInterval * SCROLLBAR_SEEK_EXPENSIVE_RENDER_FRAME_INTERVALS);
|
|
14001
15667
|
return this._estimatedFullRenderDuration >= expensiveRenderThreshold;
|
|
14002
15668
|
}
|
|
@@ -14021,20 +15687,24 @@ var Scene = class extends Disposable {
|
|
|
14021
15687
|
return canvasInstance.getContext().detectBitmapMutation(() => this._afterRender$.next(canvasInstance));
|
|
14022
15688
|
}
|
|
14023
15689
|
render(parentCtx) {
|
|
14024
|
-
var _this$
|
|
15690
|
+
var _this$getEngine3, _this$getEngine7, _this$_getViewportCac;
|
|
14025
15691
|
if (!this.isDirty()) return;
|
|
14026
15692
|
const layers = this._layers.sort(sortRules);
|
|
14027
|
-
const canvasInstance = (_this$
|
|
15693
|
+
const canvasInstance = (_this$getEngine3 = this.getEngine()) === null || _this$getEngine3 === void 0 ? void 0 : _this$getEngine3.getCanvas();
|
|
15694
|
+
this._prepareRender$.next();
|
|
14028
15695
|
const shouldTryPreservingEngine = this._preserveEngineOnRender && !this._hasPostRenderCanvasMutation && parentCtx == null && canvasInstance != null;
|
|
14029
15696
|
const isScrollbarSeekRender = this._isScrollbarSeeking && parentCtx == null && canvasInstance != null;
|
|
14030
15697
|
const shouldMeasureFullRender = parentCtx == null && canvasInstance != null;
|
|
14031
15698
|
const fullRenderStartedAt = Tools.now();
|
|
14032
15699
|
if (isScrollbarSeekRender) this._renderScrollbarSeekPreview(canvasInstance);
|
|
14033
15700
|
if (isScrollbarSeekRender && this._shouldDeferScrollbarSeekRender(fullRenderStartedAt)) {
|
|
14034
|
-
var _this$
|
|
14035
|
-
(_this$
|
|
15701
|
+
var _this$getEngine4;
|
|
15702
|
+
(_this$getEngine4 = this.getEngine()) === null || _this$getEngine4 === void 0 || _this$getEngine4.renderFrameTags$.next(["scrollDetailDeferred", true]);
|
|
14036
15703
|
return;
|
|
14037
15704
|
}
|
|
15705
|
+
const retainedViewportCache = !parentCtx && !shouldTryPreservingEngine && this._viewportCacheReusePending && !this._viewportCacheReuseBlocked ? this._getViewportCacheGeometry() : null;
|
|
15706
|
+
const canRetainViewportCache = (retainedViewportCache === null || retainedViewportCache === void 0 ? void 0 : retainedViewportCache.key) === this._renderedViewportCacheKey && this._viewports.every((viewport) => !viewport.shouldIntoRender() || !viewport.isDirty && !viewport.isForceDirty);
|
|
15707
|
+
this._viewportCacheReusePending = false;
|
|
14038
15708
|
this._preserveEngineOnRender = false;
|
|
14039
15709
|
let layerRenderOptions;
|
|
14040
15710
|
if (shouldTryPreservingEngine) {
|
|
@@ -14047,16 +15717,29 @@ var Scene = class extends Disposable {
|
|
|
14047
15717
|
viewportInfos
|
|
14048
15718
|
};
|
|
14049
15719
|
} else {
|
|
14050
|
-
var _this$
|
|
14051
|
-
(_this$
|
|
15720
|
+
var _this$getEngine5;
|
|
15721
|
+
(_this$getEngine5 = this.getEngine()) === null || _this$getEngine5 === void 0 || _this$getEngine5.clearCanvas();
|
|
14052
15722
|
layerRenderOptions = { viewportInfos };
|
|
14053
15723
|
}
|
|
14054
15724
|
} else if (!parentCtx) {
|
|
14055
|
-
var _this$
|
|
14056
|
-
(_this$
|
|
15725
|
+
var _this$getEngine6;
|
|
15726
|
+
(_this$getEngine6 = this.getEngine()) === null || _this$getEngine6 === void 0 || _this$getEngine6.clearCanvas();
|
|
14057
15727
|
}
|
|
15728
|
+
if (retainedViewportCache && canRetainViewportCache) layerRenderOptions = {
|
|
15729
|
+
...layerRenderOptions,
|
|
15730
|
+
retainedViewportCache
|
|
15731
|
+
};
|
|
15732
|
+
(_this$getEngine7 = this.getEngine()) === null || _this$getEngine7 === void 0 || _this$getEngine7.renderFrameTags$.next(["retainedViewportCache", false]);
|
|
14058
15733
|
this._beforeRender$.next(canvasInstance);
|
|
14059
|
-
|
|
15734
|
+
try {
|
|
15735
|
+
for (let i = 0, len = layers.length; i < len; i++) layers[i].render(parentCtx, i === len - 1, layerRenderOptions);
|
|
15736
|
+
} catch (error) {
|
|
15737
|
+
this.invalidateViewportCacheReuse();
|
|
15738
|
+
this._renderedViewportCacheKey = null;
|
|
15739
|
+
throw error;
|
|
15740
|
+
}
|
|
15741
|
+
this._renderedViewportCacheKey = parentCtx ? null : ((_this$_getViewportCac = this._getViewportCacheGeometry()) === null || _this$_getViewportCac === void 0 ? void 0 : _this$_getViewportCac.key) ?? null;
|
|
15742
|
+
this._viewportCacheReuseBlocked = parentCtx != null;
|
|
14060
15743
|
this._hasPostRenderCanvasMutation = this._notifyAfterRender(canvasInstance);
|
|
14061
15744
|
this._recordRenderedViewportScrollPositions();
|
|
14062
15745
|
if (shouldMeasureFullRender) this._recordFullRenderDuration(Tools.now() - fullRenderStartedAt, isScrollbarSeekRender);
|
|
@@ -14171,8 +15854,8 @@ var Scene = class extends Disposable {
|
|
|
14171
15854
|
this._viewports = [];
|
|
14172
15855
|
}
|
|
14173
15856
|
getPrecisionScale() {
|
|
14174
|
-
var _this$
|
|
14175
|
-
const pixelRatio = ((_this$
|
|
15857
|
+
var _this$getEngine8;
|
|
15858
|
+
const pixelRatio = ((_this$getEngine8 = this.getEngine()) === null || _this$getEngine8 === void 0 ? void 0 : _this$getEngine8.getPixelRatio()) || 1;
|
|
14176
15859
|
const { scaleX, scaleY } = this.getAncestorScale();
|
|
14177
15860
|
return {
|
|
14178
15861
|
scaleX: scaleX * pixelRatio,
|
|
@@ -14201,6 +15884,7 @@ var Scene = class extends Disposable {
|
|
|
14201
15884
|
this._inputManager = null;
|
|
14202
15885
|
(_this$_transformer4 = this._transformer) === null || _this$_transformer4 === void 0 || _this$_transformer4.dispose();
|
|
14203
15886
|
this._transformer = null;
|
|
15887
|
+
this._prepareRender$.complete();
|
|
14204
15888
|
this.onFileLoaded$.complete();
|
|
14205
15889
|
this.onClick$.complete();
|
|
14206
15890
|
this.onPointerDown$.complete();
|
|
@@ -15508,6 +17192,15 @@ var Viewport = class {
|
|
|
15508
17192
|
}
|
|
15509
17193
|
this._afterRender();
|
|
15510
17194
|
}
|
|
17195
|
+
reuseCachedRender(objects, viewportInfo) {
|
|
17196
|
+
const info = viewportInfo ?? this.calcViewportInfo();
|
|
17197
|
+
for (const object of objects) object.onViewportCacheReuse(info);
|
|
17198
|
+
this.markDirty(false);
|
|
17199
|
+
this.markForceDirty(false);
|
|
17200
|
+
this._preViewBound = this._viewBound;
|
|
17201
|
+
if (info.shouldCacheUpdate) this.preCacheBound = this._cacheBound;
|
|
17202
|
+
this._afterRender();
|
|
17203
|
+
}
|
|
15511
17204
|
_makeDefaultViewport() {
|
|
15512
17205
|
return {
|
|
15513
17206
|
viewBound: {
|
|
@@ -15756,9 +17449,11 @@ var Viewport = class {
|
|
|
15756
17449
|
const scrollBarThicknessTotalSize = ((_this$getScrollBar = this.getScrollBar()) === null || _this$getScrollBar === void 0 ? void 0 : _this$getScrollBar.totalSize) ?? 0;
|
|
15757
17450
|
const maxViewportScrollX = this._sceneWidthAfterScale - this._marginLeft * scaleX - freezeWidth * scaleX - width + scrollBarThicknessTotalSize;
|
|
15758
17451
|
const maxViewportScrollY = this._sceneHeightAfterScale - this._marginTop * scaleY - freezeHeight * scaleY - height + scrollBarThicknessTotalSize;
|
|
17452
|
+
const limitX = hasScrollableOverflow(this._sceneWCurrVpAfterScale, width) ? Math.max(this._paddingStartX, maxViewportScrollX / scaleX) : this._paddingStartX;
|
|
17453
|
+
const limitY = hasScrollableOverflow(this._sceneHCurrVpAfterScale, height) ? Math.max(this._paddingStartY, maxViewportScrollY / scaleY) : this._paddingStartY;
|
|
15759
17454
|
return {
|
|
15760
|
-
viewportScrollX: Tools.clamp(viewportScrollX, this._paddingStartX,
|
|
15761
|
-
viewportScrollY: Tools.clamp(viewportScrollY, this._paddingStartY,
|
|
17455
|
+
viewportScrollX: Tools.clamp(viewportScrollX, this._paddingStartX, limitX),
|
|
17456
|
+
viewportScrollY: Tools.clamp(viewportScrollY, this._paddingStartY, limitY),
|
|
15762
17457
|
isLimitedX: viewportScrollX > maxViewportScrollX,
|
|
15763
17458
|
isLimitedY: viewportScrollY > maxViewportScrollY
|
|
15764
17459
|
};
|
|
@@ -15897,7 +17592,7 @@ var Viewport = class {
|
|
|
15897
17592
|
isBarDragging: options === null || options === void 0 ? void 0 : options.isBarDragging,
|
|
15898
17593
|
isBarDragEnd: options === null || options === void 0 ? void 0 : options.isBarDragEnd
|
|
15899
17594
|
};
|
|
15900
|
-
(_this$_scrollBar8 = this._scrollBar) === null || _this$_scrollBar8 === void 0 || _this$_scrollBar8.makeDirty(true);
|
|
17595
|
+
(_this$_scrollBar8 = this._scrollBar) === null || _this$_scrollBar8 === void 0 || _this$_scrollBar8.makeDirty(true, true);
|
|
15901
17596
|
this.onScrollAfter$.emitEvent(scrollSubParam);
|
|
15902
17597
|
this._emitScrollEnd$(scrollSubParam);
|
|
15903
17598
|
this.onScrollByBar$.emitEvent({
|
|
@@ -15920,7 +17615,7 @@ var Viewport = class {
|
|
|
15920
17615
|
* @param isTrigger
|
|
15921
17616
|
*/
|
|
15922
17617
|
_scrollToViewportPosCore(scrollVpPos, isTrigger = true) {
|
|
15923
|
-
var _this$_scrollBar11, _this$_scrollBar12
|
|
17618
|
+
var _this$_scrollBar11, _this$_scrollBar12;
|
|
15924
17619
|
if (this._scrollBar == null) return;
|
|
15925
17620
|
let viewportScrollX = scrollVpPos.viewportScrollX ?? this.viewportScrollX;
|
|
15926
17621
|
let viewportScrollY = scrollVpPos.viewportScrollY ?? this.viewportScrollY;
|
|
@@ -15931,6 +17626,7 @@ var Viewport = class {
|
|
|
15931
17626
|
const afterLimitScrollXY = this.transViewportScroll2ScrollValue(viewportScrollX, viewportScrollY);
|
|
15932
17627
|
const scrollX = afterLimitScrollXY.x;
|
|
15933
17628
|
const scrollY = afterLimitScrollXY.y;
|
|
17629
|
+
const needsScrollPaint = viewportScrollX !== this.viewportScrollX || viewportScrollY !== this.viewportScrollY || scrollX !== this.scrollX || scrollY !== this.scrollY || this.isDirty || this.isForceDirty;
|
|
15934
17630
|
this._preScrollX = this.scrollX;
|
|
15935
17631
|
this._preScrollY = this.scrollY;
|
|
15936
17632
|
this._preViewportScrollX = this.viewportScrollX;
|
|
@@ -15951,7 +17647,7 @@ var Viewport = class {
|
|
|
15951
17647
|
limitX: (_this$_scrollBar11 = this._scrollBar) === null || _this$_scrollBar11 === void 0 ? void 0 : _this$_scrollBar11.limitX,
|
|
15952
17648
|
limitY: (_this$_scrollBar12 = this._scrollBar) === null || _this$_scrollBar12 === void 0 ? void 0 : _this$_scrollBar12.limitY
|
|
15953
17649
|
};
|
|
15954
|
-
(
|
|
17650
|
+
if (needsScrollPaint) this._scrollBar.makeDirty(true, true);
|
|
15955
17651
|
this.onScrollAfter$.emitEvent(scrollSubParam);
|
|
15956
17652
|
this._emitScrollEnd$(scrollSubParam);
|
|
15957
17653
|
return afterLimitViewportXY;
|
|
@@ -16068,4 +17764,4 @@ var Viewport = class {
|
|
|
16068
17764
|
}
|
|
16069
17765
|
};
|
|
16070
17766
|
|
|
16071
|
-
export { AlignmentSnapSession, BASE_OBJECT_ARRAY, BG_Z_INDEX, BORDER_TYPE, BORDER_Z_INDEX, Background, BaseObject, Border, BreakType, CHECK_OBJECT_ARRAY, CIRCLE_OBJECT_ARRAY, COLOR_BLACK_RGB, CURSOR_TYPE, Canvas, CanvasColorService, CanvasRenderMode, CheckboxShape, Circle, ColumnHeaderLayout, ComponentExtension, Control, Custom, CustomObject, DEFAULT_DOCUMENT_FONTSIZE, DEFAULT_FONTFACE_PLANE, DEFAULT_FRAME_LIST_SIZE, DEFAULT_FRAME_SAMPLE_SIZE, DEFAULT_MEASURE_TEXT, DEFAULT_OFFSET_SPACING, DEFAULT_PADDING_DATA, DEFAULT_SKELETON_FOOTER, DEFAULT_SKELETON_HEADER, DEFAULT_TRANSFORMER_CONFIG, DOCS_EXTENSION_TYPE, DOCUMENT_CONTEXT_CLIP_TYPE, DRAWING_OBJECT_LAYER_INDEX, DRAWING_OBJECT_LOWER_LAYER_INDEX, DRAWING_OBJECT_UPPER_LAYER_INDEX, DashedRect, DataStreamTreeNode, DeviceInputEventType, DeviceType, DocBackground, DocSimpleSkeleton, DocumentEditArea,
|
|
17767
|
+
export { AlignmentSnapSession, BASE_OBJECT_ARRAY, BG_Z_INDEX, BORDER_TYPE, BORDER_Z_INDEX, Background, BaseObject, Border, BreakType, CHECK_OBJECT_ARRAY, CIRCLE_OBJECT_ARRAY, COLOR_BLACK_RGB, CONTROL_TOUCH_HIT_RADIUS, CURSOR_TYPE, Canvas, CanvasColorService, CanvasRenderMode, CheckboxShape, Circle, ColumnHeaderLayout, ComponentExtension, Control, Custom, CustomObject, DEFAULT_DOCUMENT_FONTSIZE, DEFAULT_FONTFACE_PLANE, DEFAULT_FRAME_LIST_SIZE, DEFAULT_FRAME_SAMPLE_SIZE, DEFAULT_MEASURE_TEXT, DEFAULT_OFFSET_SPACING, DEFAULT_PADDING_DATA, DEFAULT_SKELETON_FOOTER, DEFAULT_SKELETON_HEADER, DEFAULT_TRANSFORMER_CONFIG, DOCS_EXTENSION_TYPE, DOCUMENT_CONTEXT_CLIP_TYPE, DRAWING_OBJECT_LAYER_INDEX, DRAWING_OBJECT_LOWER_LAYER_INDEX, DRAWING_OBJECT_UPPER_LAYER_INDEX, DashedRect, DataStreamTreeNode, DeviceInputEventType, DeviceType, DocBackground, DocSimpleSkeleton, DocumentEditArea, DocumentSkeleton, DocumentSkeletonPageType, DocumentViewModel, Documents, DocumentsSpanAndLineExtensionRegistry, Drawing, DrawingGroupObject, DumbCanvasColorService, EXPAND_SIZE_FOR_RENDER_OVERFLOW, Engine, EventConstants, FIX_ONE_PIXEL_BLUR_OFFSET, FONT_EXTENSION_Z_INDEX, FULL_WIDTH_HORIZONTAL_ALIGNMENTS, Font, FontCache, GlyphType, Group, HitCanvas, ICanvasColorService, INITIAL_MATRIX, INITIAL_Path2, IRenderManagerService, IWatermarkTypeEnum, Image$1 as Image, IsSafari, LINK_VIEW_PORT_TYPE, Layer, Line, LineType, Liquid, MAIN_VIEW_PORT_KEY, MAXIMUM_COL_WIDTH, MAXIMUM_ROW_HEIGHT, MEASURE_EXTENT, MEASURE_EXTENT_FOR_PARAGRAPH, MIDDLE_CELL_POS_MAGIC_NUMBER, MIN_COL_WIDTH, MIN_TEXT_RENDER_HEIGHT_IN_SCREEN_PX, Marker, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, ORIENTATION_TYPE, ObjectType, PATH_OBJECT_ARRAY, PRINTING_BG_Z_INDEX, PageLayoutType, Path, Path2, PerformanceMonitor, PointerInput, RECT_OBJECT_ARRAY, REGULAR_POLYGON_OBJECT_ARRAY, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, Rect, RegularPolygon, RenderComponent, RenderManagerService, RenderUnit, RollingAverage, RowHeaderLayout, SHAPE_OBJECT_ARRAY, SHAPE_TYPE, SHEET_EXTENSION_PREFIX, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, Scene, SceneCanvas, SceneViewer, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetCellDocumentViewModel, SheetColumnHeaderExtensionRegistry, SheetComponent, SheetExtension, SheetRowHeaderExtensionRegistry, ShowGridlinesState, SkeletonType, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetExtensionRegistry, SpreadsheetHeader, SpreadsheetRowHeader, SpreadsheetSkeleton, TEXT_OBJECT_ARRAY, TRANSFORM_CHANGE_OBSERVABLE_TYPE, Text, Transform, UNIVER_WATERMARK_LAYER_INDEX, UNIVER_WATERMARK_STORAGE_KEY, UniverPrintingContext, UniverRenderEnginePlugin, UniverRenderingContext, UniverRenderingContext2D, VERTICAL_ROTATE_ANGLE, Vector2, Viewport, WatermarkLayer, calculateCellImageRect, calculateRectRotate, cancelRequestFrame, checkStyle, cjk, clampRange, clearLineByBorderType, combineDrawingEffectFilter, compareDocumentSkeletonNestedPagePathOrder, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, createCanvasElement, createDrawingEffectFilter, createImageElement, degToRad, documentSkeletonLineIterator, documentSkeletonTableIterator, drawDiagonalLineByBorderType, drawLineByBorderType, expandDrawingEffectBounds, expandRangeIfIntersects, fixLineWidthByScale, generateRandomKey, getAlignmentRectXAnchors, getAlignmentRectYAnchors, getCellPositionByIndex, getCharSpaceApply, getCheckboxShapeSize, getClosestAlignmentOffset, getColor, getCurrentScrollXY, getCurrentTypeOfRenderer, getCustomNumberDisplayText, getDPI, getDevicePixelRatio, getDocCustomGlyphRenderer, getDocsCustomBlockRenderViewport, getDocsSkeletonPageSize, getDocsTableLayoutViewportWidth, getDocsTableRenderViewport, getDocsTableViewportLeft, getDocumentLayoutPresentation, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, getDrawingGroupState, getFirstGrapheme, getFontStyleString, getGeneralNumberDisplayText, getGroupState, getLastColumn, getLastLine, getLineOffset, getLineWidth, getLineWith, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getPointerPrefix, getRenderTransformBaseOnParentBound, getRotateOffsetAndFarthestHypotenuse, getRotateOrientation, getRotatedBoundInGroup, getScale, getShrinkToFitScale, getSizeForDom, getSystemHighlightColor, getTableIdAndSliceIndex, getTextWithCaps, getTopmostDocsTableHit, getTranslateInSpreadContextWithPixelRatio, getValueType, glyphIterator, graphemeSegmenter, hasAllLatin, hasArabic, hasBasicLatin, hasLatinExtendedA, hasLatinExtendedB, hasLatinOneSupplement, hasListGlyph, hasScrollableOverflow, hasSpace, hasThai, hasTibetan, inViewRanges, injectStyle, invalidateDocumentFontMetrics, isArray, isCheckboxGlyph, isCjkCenterAlignedPunctuation, isCjkLeftAlignedPunctuation, isCjkRightAlignedPunctuation, isDate, isEmojiGrapheme, isFirstGlyph, isFunction, isIndentByGlyph, isLastGlyph, isNumber, isObject, isPlaceholderOrSpace, isRectIntersect, isRegExp, isSameLine, isString, lineIterator, measureDocumentNoWrapTextRangeWidth, measureDocumentNoWrapTextWidth, measureDocumentUnbreakableTextWidth, measureDocumentWrappedTextWidth, mergeInfoOffset, normalizeAlignmentRect, parseDataStreamToTree, pixelToPt, precisionTo, ptToMM, ptToPixel, ptToPx, pxToInch, pxToNum, pxToPt, radToDeg, registerDocCustomGlyphRenderer, registerDocumentLayoutPresentation, renderImageWatermark, renderTextWatermark, renderUserInfoWatermark, renderWatermark, requestNewFrame, resolveDrawingEffectMasks, resolveGlowEffect, resolveOuterShadowEffect, scaleDocumentDataForShrinkToFit, scrollAndClearCanvas, setDocsCustomBlockRenderViewportProvider, setDocsTableRenderViewportProvider, setLineType, sheetContentViewportKeys, sheetHeaderViewportKeys, shouldRenderRowText, startWithEmoji, toPx, transformObjectOutOfGroup, withCurrentTypeOfRenderer };
|