@univerjs/engine-render 1.6.1 → 1.6.2
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/lib/cjs/{doc-skeleton-Bgbeuuel.js → doc-skeleton-BET2eguM.js} +12 -10
- package/lib/cjs/index.js +55 -26
- package/lib/cjs/worker.js +1 -1
- package/lib/{doc-skeleton-DlOLv6WJ.js → doc-skeleton-Cwms151V.js} +12 -10
- package/lib/es/{doc-skeleton-DlOLv6WJ.js → doc-skeleton-Cwms151V.js} +12 -10
- package/lib/es/index.js +56 -27
- package/lib/es/worker.js +1 -1
- package/lib/index.js +56 -27
- package/lib/umd/index.js +5 -5
- package/lib/worker.js +1 -1
- package/package.json +3 -4
package/lib/es/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { $ as getSmallCapsFontStyle, $n as radToDeg, $t as checkStyle, A as getTableCellSpacing, An as injectStyle, Ar as _defineProperty, At as setLineType, B as DataStreamTreeNode, Bn as isRectIntersect, Bt as INITIAL_MATRIX, C as resolveDocumentParagraphNumbering, Cn as hasLatinExtendedB, Cr as MAXIMUM_COL_WIDTH, Ct as getDevicePixelRatio, D as getColorStyleForCanvas, Dn as hasThai, Dr as ORIENTATION_TYPE, Dt as getRotateOffsetAndFarthestHypotenuse, E as getDocumentBorderWidth, En as hasSpace, Er as MIN_COL_WIDTH, Et as getLineWith, F as formatNoteNumber, Fn as isDate, Ft as PageLayoutType, G as getDocsTableRenderViewport, Gn as pixelToPt, Gt as getGroupState, H as hasDocumentHeaderFooterReferenceLayout, Hn as isString, Ht as getTransformBoundingBox, I as resolveNoteReferences, In as isEmojiGrapheme, It as SkeletonType, J as setDocsTableRenderViewportProvider, Jn as ptToPixel, Jt as transformObjectOutOfGroup, K as getDocsTableViewportLeft, Kn as precisionTo, Kt as getRenderTransformBaseOnParentBound, L as DocumentEditArea, Ln as isFunction, Lt as BASE_OBJECT_ARRAY, M as getTableOuterBorder, Mn as isCjkCenterAlignedPunctuation, Mt as DocumentSkeletonPageType, N as hasTableCellSpacing, Nn as isCjkLeftAlignedPunctuation, Nt as GlyphType, O as getTableIdAndSliceIndex, On as hasTibetan, Or as RENDER_CLASS_TYPE, Ot as getRotateOrientation, P as resolveHeaderFooterFieldGlyph, Pn as isCjkRightAlignedPunctuation, Pt as LineType, Q as getDocumentFontStyle, Qn as pxToPt, Qt as cancelRequestFrame, R as DocumentViewModel, Rn as isNumber, Rt as BaseObject, S as lineIterator, Sn as hasLatinExtendedA, Sr as LINK_VIEW_PORT_TYPE, St as drawLineByBorderType, T as getDocumentBorderBands, Tn as hasScrollableOverflow, Tr as MIDDLE_CELL_POS_MAGIC_NUMBER, Tt as getLineWidth, U as registerDocumentHeaderFooterReferenceResolver, Un as isWesternHangingPunctuation, Ut as TRANSFORM_CHANGE_OBSERVABLE_TYPE, V as createDocumentLineBreaker, Vn as isRegExp, Vt as Transform, W as getDocsTableLayoutViewportWidth, Wn as mergeInfoOffset, Wt as getDrawingGroupState, X as registerDocumentLayoutPresentation, Xn as pxToInch, Xt as offsetRotationAxis, Y as getDocumentLayoutPresentation, Yn as ptToPx, Yt as Vector2, Z as getDocumentCompatibilityPolicy, Zn as pxToNum, Zt as IsSafari, _ as getLastColumn, _n as getValueType, _r as DOCUMENT_CONTEXT_CLIP_TYPE, _t as INITIAL_Path2, a as hasDocumentReferenceLayout, an as fixLineWidthByScale, ar as cjk, at as isCheckboxGlyph, b as getPageFromPath, bn as hasArabic, br as DRAWING_OBJECT_UPPER_LAYER_INDEX, bt as clearLineByBorderType, c as getTextHorizontalScale, cn as getColor, cr as invalidateDocumentFontMetrics, ct as getDocsCustomBlockRenderViewport, d as compareDocumentSkeletonNestedPagePathOrder, dn as getFontStyleString, dr as CURSOR_TYPE, dt as CanvasRenderMode, en as clampRange, er as requestNewFrame, et as Liquid, f as documentSkeletonLineIterator, fn as getPointerPrefix, fr as DEFAULT_DOCUMENT_FONTSIZE, ft as HitCanvas, g as getDocumentSkeletonNestedPageOffset, gn as getTextWithCaps, gr as DEFAULT_SKELETON_HEADER, gt as UniverRenderingContext2D, h as getDocumentSkeletonColumnPagePathInfo, hn as getSystemHighlightColor, hr as DEFAULT_SKELETON_FOOTER, ht as UniverRenderingContext, in as expandRangeIfIntersects, ir as toPx, it as getCheckboxShapeSize, j as getTableCellSpacingInsets, jn as isArray, jt as BreakType, k as getCellBorderWidth, kn as inViewRanges, kr as SHAPE_TYPE, kt as getTranslateInSpreadContextWithPixelRatio, l as measureTextWithCharacterSpacing, ln as getDPI, lr as BORDER_TYPE, lt as setDocsCustomBlockRenderViewportProvider, m as getCharSpaceApply, mn as getSizeForDom, mr as DEFAULT_OFFSET_SPACING, mt as UniverPrintingContext, nn as createImageElement, nr as resolveTextStyleEastAsiaFont, nt as CHECK_OBJECT_ARRAY, o as registerDocumentReferenceLayoutResolver, on as generateRandomKey, or as DEFAULT_MEASURE_TEXT, ot as SHAPE_OBJECT_ARRAY, p as documentSkeletonTableIterator, pn as getScale, pr as DEFAULT_FONTFACE_PLANE, pt as SceneCanvas, q as hasDocsTableHorizontalViewport, qn as ptToMM, qt as getRotatedBoundInGroup, rn as degToRad, rr as startWithEmoji, rt as CheckboxShape, s as getPairKerningAdjustment, sn as getCellPositionByIndex, sr as FontCache, st as Shape, t as DocumentSkeleton, tn as createCanvasElement, tr as resolveDocumentDefaultFont, tt as LineBreaker, u as columnIterator, un as getFirstGrapheme, ur as COLOR_BLACK_RGB, ut as Canvas, v as getLastLine, vn as graphemeSegmenter, vr as DRAWING_OBJECT_LAYER_INDEX, vt as Path2, w as drawPageBorders, wn as hasLatinOneSupplement, wr as MAXIMUM_ROW_HEIGHT, wt as getLineOffset, x as glyphIterator, xn as hasBasicLatin, xr as FIX_ONE_PIXEL_BLUR_OFFSET, xt as drawDiagonalLineByBorderType, y as getNumberUnitValue, yn as hasAllLatin, yr as DRAWING_OBJECT_LOWER_LAYER_INDEX, yt as calculateRectRotate, z as parseDataStreamToTree, zn as isObject, zt as ObjectType } from "./doc-skeleton-
|
|
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";
|
|
1
|
+
import { $ as getSmallCapsFontStyle, $n as radToDeg, $t as checkStyle, A as getTableCellSpacing, An as injectStyle, Ar as _defineProperty, At as setLineType, B as DataStreamTreeNode, Bn as isRectIntersect, Bt as INITIAL_MATRIX, C as resolveDocumentParagraphNumbering, Cn as hasLatinExtendedB, Cr as MAXIMUM_COL_WIDTH, Ct as getDevicePixelRatio, D as getColorStyleForCanvas, Dn as hasThai, Dr as ORIENTATION_TYPE, Dt as getRotateOffsetAndFarthestHypotenuse, E as getDocumentBorderWidth, En as hasSpace, Er as MIN_COL_WIDTH, Et as getLineWith, F as formatNoteNumber, Fn as isDate, Ft as PageLayoutType, G as getDocsTableRenderViewport, Gn as pixelToPt, Gt as getGroupState, H as hasDocumentHeaderFooterReferenceLayout, Hn as isString, Ht as getTransformBoundingBox, I as resolveNoteReferences, In as isEmojiGrapheme, It as SkeletonType, J as setDocsTableRenderViewportProvider, Jn as ptToPixel, Jt as transformObjectOutOfGroup, K as getDocsTableViewportLeft, Kn as precisionTo, Kt as getRenderTransformBaseOnParentBound, L as DocumentEditArea, Ln as isFunction, Lt as BASE_OBJECT_ARRAY, M as getTableOuterBorder, Mn as isCjkCenterAlignedPunctuation, Mt as DocumentSkeletonPageType, N as hasTableCellSpacing, Nn as isCjkLeftAlignedPunctuation, Nt as GlyphType, O as getTableIdAndSliceIndex, On as hasTibetan, Or as RENDER_CLASS_TYPE, Ot as getRotateOrientation, P as resolveHeaderFooterFieldGlyph, Pn as isCjkRightAlignedPunctuation, Pt as LineType, Q as getDocumentFontStyle, Qn as pxToPt, Qt as cancelRequestFrame, R as DocumentViewModel, Rn as isNumber, Rt as BaseObject, S as lineIterator, Sn as hasLatinExtendedA, Sr as LINK_VIEW_PORT_TYPE, St as drawLineByBorderType, T as getDocumentBorderBands, Tn as hasScrollableOverflow, Tr as MIDDLE_CELL_POS_MAGIC_NUMBER, Tt as getLineWidth, U as registerDocumentHeaderFooterReferenceResolver, Un as isWesternHangingPunctuation, Ut as TRANSFORM_CHANGE_OBSERVABLE_TYPE, V as createDocumentLineBreaker, Vn as isRegExp, Vt as Transform, W as getDocsTableLayoutViewportWidth, Wn as mergeInfoOffset, Wt as getDrawingGroupState, X as registerDocumentLayoutPresentation, Xn as pxToInch, Xt as offsetRotationAxis, Y as getDocumentLayoutPresentation, Yn as ptToPx, Yt as Vector2, Z as getDocumentCompatibilityPolicy, Zn as pxToNum, Zt as IsSafari, _ as getLastColumn, _n as getValueType, _r as DOCUMENT_CONTEXT_CLIP_TYPE, _t as INITIAL_Path2, a as hasDocumentReferenceLayout, an as fixLineWidthByScale, ar as cjk, at as isCheckboxGlyph, b as getPageFromPath, bn as hasArabic, br as DRAWING_OBJECT_UPPER_LAYER_INDEX, bt as clearLineByBorderType, c as getTextHorizontalScale, cn as getColor, cr as invalidateDocumentFontMetrics, ct as getDocsCustomBlockRenderViewport, d as compareDocumentSkeletonNestedPagePathOrder, dn as getFontStyleString, dr as CURSOR_TYPE, dt as CanvasRenderMode, en as clampRange, er as requestNewFrame, et as Liquid, f as documentSkeletonLineIterator, fn as getPointerPrefix, fr as DEFAULT_DOCUMENT_FONTSIZE, ft as HitCanvas, g as getDocumentSkeletonNestedPageOffset, gn as getTextWithCaps, gr as DEFAULT_SKELETON_HEADER, gt as UniverRenderingContext2D, h as getDocumentSkeletonColumnPagePathInfo, hn as getSystemHighlightColor, hr as DEFAULT_SKELETON_FOOTER, ht as UniverRenderingContext, in as expandRangeIfIntersects, ir as toPx, it as getCheckboxShapeSize, j as getTableCellSpacingInsets, jn as isArray, jt as BreakType, k as getCellBorderWidth, kn as inViewRanges, kr as SHAPE_TYPE, kt as getTranslateInSpreadContextWithPixelRatio, l as measureTextWithCharacterSpacing, ln as getDPI, lr as BORDER_TYPE, lt as setDocsCustomBlockRenderViewportProvider, m as getCharSpaceApply, mn as getSizeForDom, mr as DEFAULT_OFFSET_SPACING, mt as UniverPrintingContext, nn as createImageElement, nr as resolveTextStyleEastAsiaFont, nt as CHECK_OBJECT_ARRAY, o as registerDocumentReferenceLayoutResolver, on as generateRandomKey, or as DEFAULT_MEASURE_TEXT, ot as SHAPE_OBJECT_ARRAY, p as documentSkeletonTableIterator, pn as getScale, pr as DEFAULT_FONTFACE_PLANE, pt as SceneCanvas, q as hasDocsTableHorizontalViewport, qn as ptToMM, qt as getRotatedBoundInGroup, rn as degToRad, rr as startWithEmoji, rt as CheckboxShape, s as getPairKerningAdjustment, sn as getCellPositionByIndex, sr as FontCache, st as Shape, t as DocumentSkeleton, tn as createCanvasElement, tr as resolveDocumentDefaultFont, tt as LineBreaker, u as columnIterator, un as getFirstGrapheme, ur as COLOR_BLACK_RGB, ut as Canvas, v as getLastLine, vn as graphemeSegmenter, vr as DRAWING_OBJECT_LAYER_INDEX, vt as Path2, w as drawPageBorders, wn as hasLatinOneSupplement, wr as MAXIMUM_ROW_HEIGHT, wt as getLineOffset, x as glyphIterator, xn as hasBasicLatin, xr as FIX_ONE_PIXEL_BLUR_OFFSET, xt as drawDiagonalLineByBorderType, y as getNumberUnitValue, yn as hasAllLatin, yr as DRAWING_OBJECT_LOWER_LAYER_INDEX, yt as calculateRectRotate, z as parseDataStreamToTree, zn as isObject, zt as ObjectType } from "./doc-skeleton-Cwms151V.js";
|
|
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, binSearchFirstGreaterThanTarget, 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";
|
|
5
|
-
import { floor, max, min } from "@floating-ui/utils";
|
|
6
|
-
import { getDocumentElement } from "@floating-ui/utils/dom";
|
|
7
5
|
import { drawCanvasIcon } from "@univerjs/icons-svg";
|
|
8
6
|
|
|
9
7
|
// src/alignment-snap.ts
|
|
@@ -8167,6 +8165,25 @@ const RENDER_RAW_FORMULA_KEY = "RENDER_RAW_FORMULA";
|
|
|
8167
8165
|
const GENERAL_NUMBER_MAX_SIGNIFICANT_DIGITS = 15;
|
|
8168
8166
|
const GENERAL_NUMBER_RESERVE_GLYPH = "0";
|
|
8169
8167
|
const FULL_WIDTH_HORIZONTAL_ALIGNMENTS = /* @__PURE__ */ new Set([HorizontalAlign.JUSTIFIED, HorizontalAlign.DISTRIBUTED]);
|
|
8168
|
+
function isNumericCell(cell) {
|
|
8169
|
+
return cell.t === CellValueType.NUMBER || !Tools.isDefine(cell.t) && typeof cell.v === "number";
|
|
8170
|
+
}
|
|
8171
|
+
function getGeneralNumberReserveWidth(fontString) {
|
|
8172
|
+
return FontCache.getMeasureText(GENERAL_NUMBER_RESERVE_GLYPH, fontString).width;
|
|
8173
|
+
}
|
|
8174
|
+
function shouldUseCellDocumentLayout(cell, style, { vertexAngle, centerAngle }) {
|
|
8175
|
+
return Boolean((cell === null || cell === void 0 ? void 0 : cell.p) || vertexAngle || centerAngle) || FULL_WIDTH_HORIZONTAL_ALIGNMENTS.has((style === null || style === void 0 ? void 0 : style.ht) ?? HorizontalAlign.UNSPECIFIED);
|
|
8176
|
+
}
|
|
8177
|
+
function measureNumericCellWidth(cell, style) {
|
|
8178
|
+
var _style$n;
|
|
8179
|
+
const displayText = getDisplayValueFromCell(cell);
|
|
8180
|
+
if (!displayText) return 0;
|
|
8181
|
+
const fontString = getFontStyleString(style).fontCache;
|
|
8182
|
+
const roundingReserveWidth = isDefaultFormat((_style$n = style.n) === null || _style$n === void 0 ? void 0 : _style$n.pattern) && Number.isFinite(Number(cell.v)) ? getGeneralNumberReserveWidth(fontString) : 0;
|
|
8183
|
+
const padding = style.pd ?? DEFAULT_PADDING_DATA;
|
|
8184
|
+
const horizontalPadding = (padding.l ?? DEFAULT_PADDING_DATA.l) + (padding.r ?? DEFAULT_PADDING_DATA.r);
|
|
8185
|
+
return Math.ceil(FontCache.getMeasureText(displayText, fontString).width + roundingReserveWidth + horizontalPadding);
|
|
8186
|
+
}
|
|
8170
8187
|
function getNumberOverflowText(fontString, availableWidth) {
|
|
8171
8188
|
const hashWidth = FontCache.getMeasureText("#", fontString).width;
|
|
8172
8189
|
if (hashWidth <= 0) return "#";
|
|
@@ -8178,7 +8195,7 @@ function getShrinkToFitScale(contentWidth, availableWidth, fontSize) {
|
|
|
8178
8195
|
}
|
|
8179
8196
|
function getGeneralNumberDisplayText(value, displayText, fontString, availableWidth) {
|
|
8180
8197
|
if (availableWidth <= 0) return displayText;
|
|
8181
|
-
const roundingReserveWidth =
|
|
8198
|
+
const roundingReserveWidth = getGeneralNumberReserveWidth(fontString);
|
|
8182
8199
|
if (FontCache.getMeasureText(displayText, fontString).width + roundingReserveWidth <= availableWidth) return displayText;
|
|
8183
8200
|
let bestFit = "";
|
|
8184
8201
|
for (let decimalPlaces = 0; decimalPlaces < GENERAL_NUMBER_MAX_SIGNIFICANT_DIGITS; decimalPlaces++) {
|
|
@@ -8697,11 +8714,10 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8697
8714
|
for (let colIndex = startColumn; colIndex <= endColumn; colIndex++) {
|
|
8698
8715
|
if (!this.worksheet.getColVisible(colIndex)) continue;
|
|
8699
8716
|
if (calculatedCols.has(colIndex)) continue;
|
|
8700
|
-
const autoWidth = this._calculateColWidth(colIndex);
|
|
8701
8717
|
calculatedCols.add(colIndex);
|
|
8702
8718
|
results.push({
|
|
8703
8719
|
col: colIndex,
|
|
8704
|
-
width:
|
|
8720
|
+
width: this._calculateColWidth(colIndex)
|
|
8705
8721
|
});
|
|
8706
8722
|
}
|
|
8707
8723
|
}
|
|
@@ -8715,9 +8731,10 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8715
8731
|
*/
|
|
8716
8732
|
_calculateColWidth(colIndex) {
|
|
8717
8733
|
const worksheet = this.worksheet;
|
|
8734
|
+
const { defaultColumnWidth } = this._worksheetData;
|
|
8718
8735
|
let colWidth = 0;
|
|
8719
8736
|
const visibleRangeViewMain = this.visibleRangeByViewportKey("viewMain");
|
|
8720
|
-
if (!visibleRangeViewMain) return
|
|
8737
|
+
if (!visibleRangeViewMain) return defaultColumnWidth;
|
|
8721
8738
|
const { startRow: startRowOfViewMain, endRow: endRowOfViewMain } = visibleRangeViewMain;
|
|
8722
8739
|
const rowCount = this.worksheet.getRowCount();
|
|
8723
8740
|
const otherRowIndex = /* @__PURE__ */ new Set();
|
|
@@ -8737,7 +8754,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8737
8754
|
if (colIndex === 0) currColWidth = this.columnWidthAccumulation[colIndex];
|
|
8738
8755
|
for (let i = 0; i < rowIdxArr.length; i++) {
|
|
8739
8756
|
const row = rowIdxArr[i];
|
|
8740
|
-
const { isMerged, isMergedMainCell } =
|
|
8757
|
+
const { isMerged, isMergedMainCell } = worksheet.getCellInfoInMergeData(row, colIndex);
|
|
8741
8758
|
if (isMerged && !isMergedMainCell) continue;
|
|
8742
8759
|
if (!this.worksheet.getRowVisible(row)) continue;
|
|
8743
8760
|
const cell = worksheet.getCell(row, colIndex);
|
|
@@ -8753,7 +8770,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8753
8770
|
colWidth = Math.max(colWidth, measuredWidth);
|
|
8754
8771
|
if (colWidth >= 2e3) return MAXIMUM_COL_WIDTH;
|
|
8755
8772
|
}
|
|
8756
|
-
if (colWidth === 0) return currColWidth;
|
|
8773
|
+
if (colWidth === 0) return Math.max(defaultColumnWidth, currColWidth);
|
|
8757
8774
|
return Math.max(2, colWidth);
|
|
8758
8775
|
}
|
|
8759
8776
|
getColWidth(colIndex) {
|
|
@@ -8772,16 +8789,18 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8772
8789
|
_getMeasuredWidthByCell(cell, row, column, currColWidth) {
|
|
8773
8790
|
var _cell$fontRenderExten5;
|
|
8774
8791
|
let measuredWidth = 0;
|
|
8775
|
-
if (((_cell$fontRenderExten5 = cell.fontRenderExtension) === null || _cell$fontRenderExten5 === void 0 ? void 0 : _cell$fontRenderExten5.isSkip) &&
|
|
8776
|
-
|
|
8777
|
-
const cellWidth = (_cell$interceptorAuto = cell.interceptorAutoWidth) === null || _cell$interceptorAuto === void 0 ? void 0 : _cell$interceptorAuto.call(cell);
|
|
8792
|
+
if (((_cell$fontRenderExten5 = cell.fontRenderExtension) === null || _cell$fontRenderExten5 === void 0 ? void 0 : _cell$fontRenderExten5.isSkip) && cell.interceptorAutoWidth) {
|
|
8793
|
+
const cellWidth = cell.interceptorAutoWidth();
|
|
8778
8794
|
if (cellWidth) return cellWidth;
|
|
8779
8795
|
}
|
|
8796
|
+
if (!cell.p && (cell.v == null || cell.v === "")) return 0;
|
|
8780
8797
|
const style = this.worksheet.getComposedCellStyleByCellData(row, column, cell);
|
|
8798
|
+
if (isNumericCell(cell) && style.stf !== BooleanNumber.TRUE && !shouldUseCellDocumentLayout(cell, style, convertTextRotation(style.tr ?? void 0))) return measureNumericCellWidth(cell, style);
|
|
8781
8799
|
const modelObject = this.worksheet.getCellDocumentModel(cell, style, { isDeepClone: true });
|
|
8782
8800
|
if (modelObject == null) return measuredWidth;
|
|
8783
8801
|
const { documentModel, textRotation } = modelObject;
|
|
8784
8802
|
if (documentModel == null) return measuredWidth;
|
|
8803
|
+
documentModel.updateDocumentRenderConfig({ zeroWidthParagraphBreak: BooleanNumber.TRUE });
|
|
8785
8804
|
const documentViewModel = new SheetCellDocumentViewModel(documentModel);
|
|
8786
8805
|
const { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
8787
8806
|
if ((style === null || style === void 0 ? void 0 : style.tb) === WrapStrategy.WRAP) {
|
|
@@ -9115,10 +9134,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
9115
9134
|
}).fontCache;
|
|
9116
9135
|
}
|
|
9117
9136
|
_applyNumberDisplay(row, col, fontCache, style) {
|
|
9118
|
-
var _style$
|
|
9137
|
+
var _style$n2;
|
|
9119
9138
|
const cellData = fontCache.cellData;
|
|
9120
|
-
if (!cellData || style.stf === BooleanNumber.TRUE || fontCache.documentSkeleton) return;
|
|
9121
|
-
if (cellData.t !== CellValueType.NUMBER && (Tools.isDefine(cellData.t) || typeof cellData.v !== "number")) return;
|
|
9139
|
+
if (!cellData || style.stf === BooleanNumber.TRUE || fontCache.documentSkeleton || !isNumericCell(cellData)) return;
|
|
9122
9140
|
const cellInfo = this.getCellWithCoordByIndex(row, col, false);
|
|
9123
9141
|
const startX = cellInfo.isMergedMainCell ? cellInfo.mergeInfo.startX : cellInfo.startX;
|
|
9124
9142
|
const endX = cellInfo.isMergedMainCell ? cellInfo.mergeInfo.endX : cellInfo.endX;
|
|
@@ -9126,7 +9144,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
9126
9144
|
const extension = cellData.fontRenderExtension;
|
|
9127
9145
|
const availableWidth = endX - startX - (padding.l ?? DEFAULT_PADDING_DATA.l) - (padding.r ?? DEFAULT_PADDING_DATA.r) - ((extension === null || extension === void 0 ? void 0 : extension.leftOffset) ?? 0) - ((extension === null || extension === void 0 ? void 0 : extension.rightOffset) ?? 0);
|
|
9128
9146
|
const displayText = fontCache.displayText ?? getDisplayValueFromCell(cellData);
|
|
9129
|
-
if (isDefaultFormat((_style$
|
|
9147
|
+
if (isDefaultFormat((_style$n2 = style.n) === null || _style$n2 === void 0 ? void 0 : _style$n2.pattern)) {
|
|
9130
9148
|
const value = Number(cellData.v);
|
|
9131
9149
|
if (Number.isFinite(value)) fontCache.displayText = getGeneralNumberDisplayText(value, displayText, fontCache.fontString, availableWidth);
|
|
9132
9150
|
} else fontCache.displayText = getCustomNumberDisplayText(displayText, fontCache.fontString, availableWidth);
|
|
@@ -9151,8 +9169,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
9151
9169
|
this._stylesCache.fontMatrix.setValue(row, col, cacheValue);
|
|
9152
9170
|
return;
|
|
9153
9171
|
}
|
|
9154
|
-
const
|
|
9155
|
-
const
|
|
9172
|
+
const rotation = convertTextRotation((style === null || style === void 0 ? void 0 : style.tr) ?? void 0);
|
|
9173
|
+
const { vertexAngle, centerAngle } = rotation;
|
|
9174
|
+
const modelObject = shouldUseCellDocumentLayout(cellData, style, rotation) ? this.worksheet.getCellDocumentModel(cellData, style, {
|
|
9156
9175
|
isDeepClone: true,
|
|
9157
9176
|
displayRawFormula: this._renderRawFormula
|
|
9158
9177
|
}) : null;
|
|
@@ -11439,6 +11458,7 @@ var Spreadsheet = class Spreadsheet extends SheetComponent {
|
|
|
11439
11458
|
if (repairNativeGridlines) this._repairGridlineStroke(ctx, startX, startY, endX, endY);
|
|
11440
11459
|
const mergeVisibleRanges = [];
|
|
11441
11460
|
let mergeVisibleRangeStartRow = startRow;
|
|
11461
|
+
let lastRowPosition = startY;
|
|
11442
11462
|
for (let r = rowStart; r <= rowEnd; r++) {
|
|
11443
11463
|
if (hasMergeData) {
|
|
11444
11464
|
if (worksheet.getRowVisible(r) === false) {
|
|
@@ -11460,20 +11480,29 @@ var Spreadsheet = class Spreadsheet extends SheetComponent {
|
|
|
11460
11480
|
}
|
|
11461
11481
|
if (r < 0 || r > rowHeightAccumulationLength - 1) continue;
|
|
11462
11482
|
const rowEndPosition = rowHeightAccumulation[r];
|
|
11483
|
+
if (rowEndPosition === lastRowPosition) continue;
|
|
11463
11484
|
ctx.beginPath();
|
|
11464
11485
|
ctx.moveToByPrecision(startX, rowEndPosition);
|
|
11465
11486
|
ctx.lineToByPrecision(endX, rowEndPosition);
|
|
11466
11487
|
ctx.closePathByEnv();
|
|
11467
11488
|
ctx.stroke();
|
|
11489
|
+
lastRowPosition = rowEndPosition;
|
|
11468
11490
|
}
|
|
11491
|
+
let lastColumnPosition = startX;
|
|
11469
11492
|
for (let c = columnStart; c <= columnEnd; c++) {
|
|
11470
11493
|
if (c < 0 || c > columnWidthAccumulationLength - 1) continue;
|
|
11471
11494
|
const columnEndPosition = columnWidthAccumulation[c];
|
|
11495
|
+
if (columnEndPosition === lastColumnPosition) {
|
|
11496
|
+
if (columnWidthAccumulation[columnEnd] === columnEndPosition) break;
|
|
11497
|
+
c = binSearchFirstGreaterThanTarget(columnWidthAccumulation, columnEndPosition) - 1;
|
|
11498
|
+
continue;
|
|
11499
|
+
}
|
|
11472
11500
|
ctx.beginPath();
|
|
11473
11501
|
ctx.moveToByPrecision(columnEndPosition, startY);
|
|
11474
11502
|
ctx.lineToByPrecision(columnEndPosition, endY);
|
|
11475
11503
|
ctx.closePathByEnv();
|
|
11476
11504
|
ctx.stroke();
|
|
11505
|
+
lastColumnPosition = columnEndPosition;
|
|
11477
11506
|
}
|
|
11478
11507
|
const mergeCellRanges = [];
|
|
11479
11508
|
if (hasMergeData) for (const mergeVisibleRange of mergeVisibleRanges) {
|
|
@@ -12235,7 +12264,7 @@ function observeClientRect(containerElement) {
|
|
|
12235
12264
|
function observeMove(element, onMove) {
|
|
12236
12265
|
let io = null;
|
|
12237
12266
|
let timeoutId;
|
|
12238
|
-
const root =
|
|
12267
|
+
const root = element.ownerDocument.documentElement;
|
|
12239
12268
|
function cleanup() {
|
|
12240
12269
|
clearTimeout(timeoutId);
|
|
12241
12270
|
io === null || io === void 0 || io.disconnect();
|
|
@@ -12246,13 +12275,13 @@ function observeMove(element, onMove) {
|
|
|
12246
12275
|
const { left, top, width, height } = element.getBoundingClientRect();
|
|
12247
12276
|
if (!skip) onMove();
|
|
12248
12277
|
if (!width || !height) return;
|
|
12249
|
-
const insetTop = floor(top);
|
|
12250
|
-
const insetRight = floor(root.clientWidth - (left + width));
|
|
12251
|
-
const insetBottom = floor(root.clientHeight - (top + height));
|
|
12252
|
-
const insetLeft = floor(left);
|
|
12278
|
+
const insetTop = Math.floor(top);
|
|
12279
|
+
const insetRight = Math.floor(root.clientWidth - (left + width));
|
|
12280
|
+
const insetBottom = Math.floor(root.clientHeight - (top + height));
|
|
12281
|
+
const insetLeft = Math.floor(left);
|
|
12253
12282
|
const options = {
|
|
12254
12283
|
rootMargin: `${-insetTop}px ${-insetRight}px ${-insetBottom}px ${-insetLeft}px`,
|
|
12255
|
-
threshold: max(0, min(1, threshold)) || 1
|
|
12284
|
+
threshold: Math.max(0, Math.min(1, threshold)) || 1
|
|
12256
12285
|
};
|
|
12257
12286
|
let isFirstUpdate = true;
|
|
12258
12287
|
function handleObserve(entries) {
|
|
@@ -12271,7 +12300,7 @@ function observeMove(element, onMove) {
|
|
|
12271
12300
|
...options,
|
|
12272
12301
|
root: root.ownerDocument
|
|
12273
12302
|
});
|
|
12274
|
-
} catch
|
|
12303
|
+
} catch {
|
|
12275
12304
|
io = new IntersectionObserver(handleObserve, options);
|
|
12276
12305
|
}
|
|
12277
12306
|
io.observe(element);
|
|
@@ -13039,7 +13068,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
13039
13068
|
|
|
13040
13069
|
// package.json
|
|
13041
13070
|
var name = "@univerjs/engine-render";
|
|
13042
|
-
var version = "1.6.
|
|
13071
|
+
var version = "1.6.2";
|
|
13043
13072
|
|
|
13044
13073
|
// src/config/config.ts
|
|
13045
13074
|
/**
|
package/lib/es/worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ar as _defineProperty, R as DocumentViewModel, i as serializeDocumentSkeletonPage, lt as setDocsCustomBlockRenderViewportProvider, n as hydrateDocumentSkeletonPage, r as serializeDocumentSkeletonContinuousBlock, sr as FontCache, t as DocumentSkeleton } from "./doc-skeleton-
|
|
1
|
+
import { Ar as _defineProperty, R as DocumentViewModel, i as serializeDocumentSkeletonPage, lt as setDocsCustomBlockRenderViewportProvider, n as hydrateDocumentSkeletonPage, r as serializeDocumentSkeletonContinuousBlock, sr as FontCache, t as DocumentSkeleton } from "./doc-skeleton-Cwms151V.js";
|
|
2
2
|
import { Disposable } from "@univerjs/core";
|
|
3
3
|
|
|
4
4
|
// src/worker-layout.ts
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { $ as getSmallCapsFontStyle, $n as radToDeg, $t as checkStyle, A as getTableCellSpacing, An as injectStyle, Ar as _defineProperty, At as setLineType, B as DataStreamTreeNode, Bn as isRectIntersect, Bt as INITIAL_MATRIX, C as resolveDocumentParagraphNumbering, Cn as hasLatinExtendedB, Cr as MAXIMUM_COL_WIDTH, Ct as getDevicePixelRatio, D as getColorStyleForCanvas, Dn as hasThai, Dr as ORIENTATION_TYPE, Dt as getRotateOffsetAndFarthestHypotenuse, E as getDocumentBorderWidth, En as hasSpace, Er as MIN_COL_WIDTH, Et as getLineWith, F as formatNoteNumber, Fn as isDate, Ft as PageLayoutType, G as getDocsTableRenderViewport, Gn as pixelToPt, Gt as getGroupState, H as hasDocumentHeaderFooterReferenceLayout, Hn as isString, Ht as getTransformBoundingBox, I as resolveNoteReferences, In as isEmojiGrapheme, It as SkeletonType, J as setDocsTableRenderViewportProvider, Jn as ptToPixel, Jt as transformObjectOutOfGroup, K as getDocsTableViewportLeft, Kn as precisionTo, Kt as getRenderTransformBaseOnParentBound, L as DocumentEditArea, Ln as isFunction, Lt as BASE_OBJECT_ARRAY, M as getTableOuterBorder, Mn as isCjkCenterAlignedPunctuation, Mt as DocumentSkeletonPageType, N as hasTableCellSpacing, Nn as isCjkLeftAlignedPunctuation, Nt as GlyphType, O as getTableIdAndSliceIndex, On as hasTibetan, Or as RENDER_CLASS_TYPE, Ot as getRotateOrientation, P as resolveHeaderFooterFieldGlyph, Pn as isCjkRightAlignedPunctuation, Pt as LineType, Q as getDocumentFontStyle, Qn as pxToPt, Qt as cancelRequestFrame, R as DocumentViewModel, Rn as isNumber, Rt as BaseObject, S as lineIterator, Sn as hasLatinExtendedA, Sr as LINK_VIEW_PORT_TYPE, St as drawLineByBorderType, T as getDocumentBorderBands, Tn as hasScrollableOverflow, Tr as MIDDLE_CELL_POS_MAGIC_NUMBER, Tt as getLineWidth, U as registerDocumentHeaderFooterReferenceResolver, Un as isWesternHangingPunctuation, Ut as TRANSFORM_CHANGE_OBSERVABLE_TYPE, V as createDocumentLineBreaker, Vn as isRegExp, Vt as Transform, W as getDocsTableLayoutViewportWidth, Wn as mergeInfoOffset, Wt as getDrawingGroupState, X as registerDocumentLayoutPresentation, Xn as pxToInch, Xt as offsetRotationAxis, Y as getDocumentLayoutPresentation, Yn as ptToPx, Yt as Vector2, Z as getDocumentCompatibilityPolicy, Zn as pxToNum, Zt as IsSafari, _ as getLastColumn, _n as getValueType, _r as DOCUMENT_CONTEXT_CLIP_TYPE, _t as INITIAL_Path2, a as hasDocumentReferenceLayout, an as fixLineWidthByScale, ar as cjk, at as isCheckboxGlyph, b as getPageFromPath, bn as hasArabic, br as DRAWING_OBJECT_UPPER_LAYER_INDEX, bt as clearLineByBorderType, c as getTextHorizontalScale, cn as getColor, cr as invalidateDocumentFontMetrics, ct as getDocsCustomBlockRenderViewport, d as compareDocumentSkeletonNestedPagePathOrder, dn as getFontStyleString, dr as CURSOR_TYPE, dt as CanvasRenderMode, en as clampRange, er as requestNewFrame, et as Liquid, f as documentSkeletonLineIterator, fn as getPointerPrefix, fr as DEFAULT_DOCUMENT_FONTSIZE, ft as HitCanvas, g as getDocumentSkeletonNestedPageOffset, gn as getTextWithCaps, gr as DEFAULT_SKELETON_HEADER, gt as UniverRenderingContext2D, h as getDocumentSkeletonColumnPagePathInfo, hn as getSystemHighlightColor, hr as DEFAULT_SKELETON_FOOTER, ht as UniverRenderingContext, in as expandRangeIfIntersects, ir as toPx, it as getCheckboxShapeSize, j as getTableCellSpacingInsets, jn as isArray, jt as BreakType, k as getCellBorderWidth, kn as inViewRanges, kr as SHAPE_TYPE, kt as getTranslateInSpreadContextWithPixelRatio, l as measureTextWithCharacterSpacing, ln as getDPI, lr as BORDER_TYPE, lt as setDocsCustomBlockRenderViewportProvider, m as getCharSpaceApply, mn as getSizeForDom, mr as DEFAULT_OFFSET_SPACING, mt as UniverPrintingContext, nn as createImageElement, nr as resolveTextStyleEastAsiaFont, nt as CHECK_OBJECT_ARRAY, o as registerDocumentReferenceLayoutResolver, on as generateRandomKey, or as DEFAULT_MEASURE_TEXT, ot as SHAPE_OBJECT_ARRAY, p as documentSkeletonTableIterator, pn as getScale, pr as DEFAULT_FONTFACE_PLANE, pt as SceneCanvas, q as hasDocsTableHorizontalViewport, qn as ptToMM, qt as getRotatedBoundInGroup, rn as degToRad, rr as startWithEmoji, rt as CheckboxShape, s as getPairKerningAdjustment, sn as getCellPositionByIndex, sr as FontCache, st as Shape, t as DocumentSkeleton, tn as createCanvasElement, tr as resolveDocumentDefaultFont, tt as LineBreaker, u as columnIterator, un as getFirstGrapheme, ur as COLOR_BLACK_RGB, ut as Canvas, v as getLastLine, vn as graphemeSegmenter, vr as DRAWING_OBJECT_LAYER_INDEX, vt as Path2, w as drawPageBorders, wn as hasLatinOneSupplement, wr as MAXIMUM_ROW_HEIGHT, wt as getLineOffset, x as glyphIterator, xn as hasBasicLatin, xr as FIX_ONE_PIXEL_BLUR_OFFSET, xt as drawDiagonalLineByBorderType, y as getNumberUnitValue, yn as hasAllLatin, yr as DRAWING_OBJECT_LOWER_LAYER_INDEX, yt as calculateRectRotate, z as parseDataStreamToTree, zn as isObject, zt as ObjectType } from "./doc-skeleton-
|
|
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";
|
|
1
|
+
import { $ as getSmallCapsFontStyle, $n as radToDeg, $t as checkStyle, A as getTableCellSpacing, An as injectStyle, Ar as _defineProperty, At as setLineType, B as DataStreamTreeNode, Bn as isRectIntersect, Bt as INITIAL_MATRIX, C as resolveDocumentParagraphNumbering, Cn as hasLatinExtendedB, Cr as MAXIMUM_COL_WIDTH, Ct as getDevicePixelRatio, D as getColorStyleForCanvas, Dn as hasThai, Dr as ORIENTATION_TYPE, Dt as getRotateOffsetAndFarthestHypotenuse, E as getDocumentBorderWidth, En as hasSpace, Er as MIN_COL_WIDTH, Et as getLineWith, F as formatNoteNumber, Fn as isDate, Ft as PageLayoutType, G as getDocsTableRenderViewport, Gn as pixelToPt, Gt as getGroupState, H as hasDocumentHeaderFooterReferenceLayout, Hn as isString, Ht as getTransformBoundingBox, I as resolveNoteReferences, In as isEmojiGrapheme, It as SkeletonType, J as setDocsTableRenderViewportProvider, Jn as ptToPixel, Jt as transformObjectOutOfGroup, K as getDocsTableViewportLeft, Kn as precisionTo, Kt as getRenderTransformBaseOnParentBound, L as DocumentEditArea, Ln as isFunction, Lt as BASE_OBJECT_ARRAY, M as getTableOuterBorder, Mn as isCjkCenterAlignedPunctuation, Mt as DocumentSkeletonPageType, N as hasTableCellSpacing, Nn as isCjkLeftAlignedPunctuation, Nt as GlyphType, O as getTableIdAndSliceIndex, On as hasTibetan, Or as RENDER_CLASS_TYPE, Ot as getRotateOrientation, P as resolveHeaderFooterFieldGlyph, Pn as isCjkRightAlignedPunctuation, Pt as LineType, Q as getDocumentFontStyle, Qn as pxToPt, Qt as cancelRequestFrame, R as DocumentViewModel, Rn as isNumber, Rt as BaseObject, S as lineIterator, Sn as hasLatinExtendedA, Sr as LINK_VIEW_PORT_TYPE, St as drawLineByBorderType, T as getDocumentBorderBands, Tn as hasScrollableOverflow, Tr as MIDDLE_CELL_POS_MAGIC_NUMBER, Tt as getLineWidth, U as registerDocumentHeaderFooterReferenceResolver, Un as isWesternHangingPunctuation, Ut as TRANSFORM_CHANGE_OBSERVABLE_TYPE, V as createDocumentLineBreaker, Vn as isRegExp, Vt as Transform, W as getDocsTableLayoutViewportWidth, Wn as mergeInfoOffset, Wt as getDrawingGroupState, X as registerDocumentLayoutPresentation, Xn as pxToInch, Xt as offsetRotationAxis, Y as getDocumentLayoutPresentation, Yn as ptToPx, Yt as Vector2, Z as getDocumentCompatibilityPolicy, Zn as pxToNum, Zt as IsSafari, _ as getLastColumn, _n as getValueType, _r as DOCUMENT_CONTEXT_CLIP_TYPE, _t as INITIAL_Path2, a as hasDocumentReferenceLayout, an as fixLineWidthByScale, ar as cjk, at as isCheckboxGlyph, b as getPageFromPath, bn as hasArabic, br as DRAWING_OBJECT_UPPER_LAYER_INDEX, bt as clearLineByBorderType, c as getTextHorizontalScale, cn as getColor, cr as invalidateDocumentFontMetrics, ct as getDocsCustomBlockRenderViewport, d as compareDocumentSkeletonNestedPagePathOrder, dn as getFontStyleString, dr as CURSOR_TYPE, dt as CanvasRenderMode, en as clampRange, er as requestNewFrame, et as Liquid, f as documentSkeletonLineIterator, fn as getPointerPrefix, fr as DEFAULT_DOCUMENT_FONTSIZE, ft as HitCanvas, g as getDocumentSkeletonNestedPageOffset, gn as getTextWithCaps, gr as DEFAULT_SKELETON_HEADER, gt as UniverRenderingContext2D, h as getDocumentSkeletonColumnPagePathInfo, hn as getSystemHighlightColor, hr as DEFAULT_SKELETON_FOOTER, ht as UniverRenderingContext, in as expandRangeIfIntersects, ir as toPx, it as getCheckboxShapeSize, j as getTableCellSpacingInsets, jn as isArray, jt as BreakType, k as getCellBorderWidth, kn as inViewRanges, kr as SHAPE_TYPE, kt as getTranslateInSpreadContextWithPixelRatio, l as measureTextWithCharacterSpacing, ln as getDPI, lr as BORDER_TYPE, lt as setDocsCustomBlockRenderViewportProvider, m as getCharSpaceApply, mn as getSizeForDom, mr as DEFAULT_OFFSET_SPACING, mt as UniverPrintingContext, nn as createImageElement, nr as resolveTextStyleEastAsiaFont, nt as CHECK_OBJECT_ARRAY, o as registerDocumentReferenceLayoutResolver, on as generateRandomKey, or as DEFAULT_MEASURE_TEXT, ot as SHAPE_OBJECT_ARRAY, p as documentSkeletonTableIterator, pn as getScale, pr as DEFAULT_FONTFACE_PLANE, pt as SceneCanvas, q as hasDocsTableHorizontalViewport, qn as ptToMM, qt as getRotatedBoundInGroup, rn as degToRad, rr as startWithEmoji, rt as CheckboxShape, s as getPairKerningAdjustment, sn as getCellPositionByIndex, sr as FontCache, st as Shape, t as DocumentSkeleton, tn as createCanvasElement, tr as resolveDocumentDefaultFont, tt as LineBreaker, u as columnIterator, un as getFirstGrapheme, ur as COLOR_BLACK_RGB, ut as Canvas, v as getLastLine, vn as graphemeSegmenter, vr as DRAWING_OBJECT_LAYER_INDEX, vt as Path2, w as drawPageBorders, wn as hasLatinOneSupplement, wr as MAXIMUM_ROW_HEIGHT, wt as getLineOffset, x as glyphIterator, xn as hasBasicLatin, xr as FIX_ONE_PIXEL_BLUR_OFFSET, xt as drawDiagonalLineByBorderType, y as getNumberUnitValue, yn as hasAllLatin, yr as DRAWING_OBJECT_LOWER_LAYER_INDEX, yt as calculateRectRotate, z as parseDataStreamToTree, zn as isObject, zt as ObjectType } from "./doc-skeleton-Cwms151V.js";
|
|
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, binSearchFirstGreaterThanTarget, 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";
|
|
5
|
-
import { floor, max, min } from "@floating-ui/utils";
|
|
6
|
-
import { getDocumentElement } from "@floating-ui/utils/dom";
|
|
7
5
|
import { drawCanvasIcon } from "@univerjs/icons-svg";
|
|
8
6
|
|
|
9
7
|
// src/alignment-snap.ts
|
|
@@ -8167,6 +8165,25 @@ const RENDER_RAW_FORMULA_KEY = "RENDER_RAW_FORMULA";
|
|
|
8167
8165
|
const GENERAL_NUMBER_MAX_SIGNIFICANT_DIGITS = 15;
|
|
8168
8166
|
const GENERAL_NUMBER_RESERVE_GLYPH = "0";
|
|
8169
8167
|
const FULL_WIDTH_HORIZONTAL_ALIGNMENTS = /* @__PURE__ */ new Set([HorizontalAlign.JUSTIFIED, HorizontalAlign.DISTRIBUTED]);
|
|
8168
|
+
function isNumericCell(cell) {
|
|
8169
|
+
return cell.t === CellValueType.NUMBER || !Tools.isDefine(cell.t) && typeof cell.v === "number";
|
|
8170
|
+
}
|
|
8171
|
+
function getGeneralNumberReserveWidth(fontString) {
|
|
8172
|
+
return FontCache.getMeasureText(GENERAL_NUMBER_RESERVE_GLYPH, fontString).width;
|
|
8173
|
+
}
|
|
8174
|
+
function shouldUseCellDocumentLayout(cell, style, { vertexAngle, centerAngle }) {
|
|
8175
|
+
return Boolean((cell === null || cell === void 0 ? void 0 : cell.p) || vertexAngle || centerAngle) || FULL_WIDTH_HORIZONTAL_ALIGNMENTS.has((style === null || style === void 0 ? void 0 : style.ht) ?? HorizontalAlign.UNSPECIFIED);
|
|
8176
|
+
}
|
|
8177
|
+
function measureNumericCellWidth(cell, style) {
|
|
8178
|
+
var _style$n;
|
|
8179
|
+
const displayText = getDisplayValueFromCell(cell);
|
|
8180
|
+
if (!displayText) return 0;
|
|
8181
|
+
const fontString = getFontStyleString(style).fontCache;
|
|
8182
|
+
const roundingReserveWidth = isDefaultFormat((_style$n = style.n) === null || _style$n === void 0 ? void 0 : _style$n.pattern) && Number.isFinite(Number(cell.v)) ? getGeneralNumberReserveWidth(fontString) : 0;
|
|
8183
|
+
const padding = style.pd ?? DEFAULT_PADDING_DATA;
|
|
8184
|
+
const horizontalPadding = (padding.l ?? DEFAULT_PADDING_DATA.l) + (padding.r ?? DEFAULT_PADDING_DATA.r);
|
|
8185
|
+
return Math.ceil(FontCache.getMeasureText(displayText, fontString).width + roundingReserveWidth + horizontalPadding);
|
|
8186
|
+
}
|
|
8170
8187
|
function getNumberOverflowText(fontString, availableWidth) {
|
|
8171
8188
|
const hashWidth = FontCache.getMeasureText("#", fontString).width;
|
|
8172
8189
|
if (hashWidth <= 0) return "#";
|
|
@@ -8178,7 +8195,7 @@ function getShrinkToFitScale(contentWidth, availableWidth, fontSize) {
|
|
|
8178
8195
|
}
|
|
8179
8196
|
function getGeneralNumberDisplayText(value, displayText, fontString, availableWidth) {
|
|
8180
8197
|
if (availableWidth <= 0) return displayText;
|
|
8181
|
-
const roundingReserveWidth =
|
|
8198
|
+
const roundingReserveWidth = getGeneralNumberReserveWidth(fontString);
|
|
8182
8199
|
if (FontCache.getMeasureText(displayText, fontString).width + roundingReserveWidth <= availableWidth) return displayText;
|
|
8183
8200
|
let bestFit = "";
|
|
8184
8201
|
for (let decimalPlaces = 0; decimalPlaces < GENERAL_NUMBER_MAX_SIGNIFICANT_DIGITS; decimalPlaces++) {
|
|
@@ -8697,11 +8714,10 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8697
8714
|
for (let colIndex = startColumn; colIndex <= endColumn; colIndex++) {
|
|
8698
8715
|
if (!this.worksheet.getColVisible(colIndex)) continue;
|
|
8699
8716
|
if (calculatedCols.has(colIndex)) continue;
|
|
8700
|
-
const autoWidth = this._calculateColWidth(colIndex);
|
|
8701
8717
|
calculatedCols.add(colIndex);
|
|
8702
8718
|
results.push({
|
|
8703
8719
|
col: colIndex,
|
|
8704
|
-
width:
|
|
8720
|
+
width: this._calculateColWidth(colIndex)
|
|
8705
8721
|
});
|
|
8706
8722
|
}
|
|
8707
8723
|
}
|
|
@@ -8715,9 +8731,10 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8715
8731
|
*/
|
|
8716
8732
|
_calculateColWidth(colIndex) {
|
|
8717
8733
|
const worksheet = this.worksheet;
|
|
8734
|
+
const { defaultColumnWidth } = this._worksheetData;
|
|
8718
8735
|
let colWidth = 0;
|
|
8719
8736
|
const visibleRangeViewMain = this.visibleRangeByViewportKey("viewMain");
|
|
8720
|
-
if (!visibleRangeViewMain) return
|
|
8737
|
+
if (!visibleRangeViewMain) return defaultColumnWidth;
|
|
8721
8738
|
const { startRow: startRowOfViewMain, endRow: endRowOfViewMain } = visibleRangeViewMain;
|
|
8722
8739
|
const rowCount = this.worksheet.getRowCount();
|
|
8723
8740
|
const otherRowIndex = /* @__PURE__ */ new Set();
|
|
@@ -8737,7 +8754,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8737
8754
|
if (colIndex === 0) currColWidth = this.columnWidthAccumulation[colIndex];
|
|
8738
8755
|
for (let i = 0; i < rowIdxArr.length; i++) {
|
|
8739
8756
|
const row = rowIdxArr[i];
|
|
8740
|
-
const { isMerged, isMergedMainCell } =
|
|
8757
|
+
const { isMerged, isMergedMainCell } = worksheet.getCellInfoInMergeData(row, colIndex);
|
|
8741
8758
|
if (isMerged && !isMergedMainCell) continue;
|
|
8742
8759
|
if (!this.worksheet.getRowVisible(row)) continue;
|
|
8743
8760
|
const cell = worksheet.getCell(row, colIndex);
|
|
@@ -8753,7 +8770,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8753
8770
|
colWidth = Math.max(colWidth, measuredWidth);
|
|
8754
8771
|
if (colWidth >= 2e3) return MAXIMUM_COL_WIDTH;
|
|
8755
8772
|
}
|
|
8756
|
-
if (colWidth === 0) return currColWidth;
|
|
8773
|
+
if (colWidth === 0) return Math.max(defaultColumnWidth, currColWidth);
|
|
8757
8774
|
return Math.max(2, colWidth);
|
|
8758
8775
|
}
|
|
8759
8776
|
getColWidth(colIndex) {
|
|
@@ -8772,16 +8789,18 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
8772
8789
|
_getMeasuredWidthByCell(cell, row, column, currColWidth) {
|
|
8773
8790
|
var _cell$fontRenderExten5;
|
|
8774
8791
|
let measuredWidth = 0;
|
|
8775
|
-
if (((_cell$fontRenderExten5 = cell.fontRenderExtension) === null || _cell$fontRenderExten5 === void 0 ? void 0 : _cell$fontRenderExten5.isSkip) &&
|
|
8776
|
-
|
|
8777
|
-
const cellWidth = (_cell$interceptorAuto = cell.interceptorAutoWidth) === null || _cell$interceptorAuto === void 0 ? void 0 : _cell$interceptorAuto.call(cell);
|
|
8792
|
+
if (((_cell$fontRenderExten5 = cell.fontRenderExtension) === null || _cell$fontRenderExten5 === void 0 ? void 0 : _cell$fontRenderExten5.isSkip) && cell.interceptorAutoWidth) {
|
|
8793
|
+
const cellWidth = cell.interceptorAutoWidth();
|
|
8778
8794
|
if (cellWidth) return cellWidth;
|
|
8779
8795
|
}
|
|
8796
|
+
if (!cell.p && (cell.v == null || cell.v === "")) return 0;
|
|
8780
8797
|
const style = this.worksheet.getComposedCellStyleByCellData(row, column, cell);
|
|
8798
|
+
if (isNumericCell(cell) && style.stf !== BooleanNumber.TRUE && !shouldUseCellDocumentLayout(cell, style, convertTextRotation(style.tr ?? void 0))) return measureNumericCellWidth(cell, style);
|
|
8781
8799
|
const modelObject = this.worksheet.getCellDocumentModel(cell, style, { isDeepClone: true });
|
|
8782
8800
|
if (modelObject == null) return measuredWidth;
|
|
8783
8801
|
const { documentModel, textRotation } = modelObject;
|
|
8784
8802
|
if (documentModel == null) return measuredWidth;
|
|
8803
|
+
documentModel.updateDocumentRenderConfig({ zeroWidthParagraphBreak: BooleanNumber.TRUE });
|
|
8785
8804
|
const documentViewModel = new SheetCellDocumentViewModel(documentModel);
|
|
8786
8805
|
const { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
8787
8806
|
if ((style === null || style === void 0 ? void 0 : style.tb) === WrapStrategy.WRAP) {
|
|
@@ -9115,10 +9134,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
9115
9134
|
}).fontCache;
|
|
9116
9135
|
}
|
|
9117
9136
|
_applyNumberDisplay(row, col, fontCache, style) {
|
|
9118
|
-
var _style$
|
|
9137
|
+
var _style$n2;
|
|
9119
9138
|
const cellData = fontCache.cellData;
|
|
9120
|
-
if (!cellData || style.stf === BooleanNumber.TRUE || fontCache.documentSkeleton) return;
|
|
9121
|
-
if (cellData.t !== CellValueType.NUMBER && (Tools.isDefine(cellData.t) || typeof cellData.v !== "number")) return;
|
|
9139
|
+
if (!cellData || style.stf === BooleanNumber.TRUE || fontCache.documentSkeleton || !isNumericCell(cellData)) return;
|
|
9122
9140
|
const cellInfo = this.getCellWithCoordByIndex(row, col, false);
|
|
9123
9141
|
const startX = cellInfo.isMergedMainCell ? cellInfo.mergeInfo.startX : cellInfo.startX;
|
|
9124
9142
|
const endX = cellInfo.isMergedMainCell ? cellInfo.mergeInfo.endX : cellInfo.endX;
|
|
@@ -9126,7 +9144,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
9126
9144
|
const extension = cellData.fontRenderExtension;
|
|
9127
9145
|
const availableWidth = endX - startX - (padding.l ?? DEFAULT_PADDING_DATA.l) - (padding.r ?? DEFAULT_PADDING_DATA.r) - ((extension === null || extension === void 0 ? void 0 : extension.leftOffset) ?? 0) - ((extension === null || extension === void 0 ? void 0 : extension.rightOffset) ?? 0);
|
|
9128
9146
|
const displayText = fontCache.displayText ?? getDisplayValueFromCell(cellData);
|
|
9129
|
-
if (isDefaultFormat((_style$
|
|
9147
|
+
if (isDefaultFormat((_style$n2 = style.n) === null || _style$n2 === void 0 ? void 0 : _style$n2.pattern)) {
|
|
9130
9148
|
const value = Number(cellData.v);
|
|
9131
9149
|
if (Number.isFinite(value)) fontCache.displayText = getGeneralNumberDisplayText(value, displayText, fontCache.fontString, availableWidth);
|
|
9132
9150
|
} else fontCache.displayText = getCustomNumberDisplayText(displayText, fontCache.fontString, availableWidth);
|
|
@@ -9151,8 +9169,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
9151
9169
|
this._stylesCache.fontMatrix.setValue(row, col, cacheValue);
|
|
9152
9170
|
return;
|
|
9153
9171
|
}
|
|
9154
|
-
const
|
|
9155
|
-
const
|
|
9172
|
+
const rotation = convertTextRotation((style === null || style === void 0 ? void 0 : style.tr) ?? void 0);
|
|
9173
|
+
const { vertexAngle, centerAngle } = rotation;
|
|
9174
|
+
const modelObject = shouldUseCellDocumentLayout(cellData, style, rotation) ? this.worksheet.getCellDocumentModel(cellData, style, {
|
|
9156
9175
|
isDeepClone: true,
|
|
9157
9176
|
displayRawFormula: this._renderRawFormula
|
|
9158
9177
|
}) : null;
|
|
@@ -11439,6 +11458,7 @@ var Spreadsheet = class Spreadsheet extends SheetComponent {
|
|
|
11439
11458
|
if (repairNativeGridlines) this._repairGridlineStroke(ctx, startX, startY, endX, endY);
|
|
11440
11459
|
const mergeVisibleRanges = [];
|
|
11441
11460
|
let mergeVisibleRangeStartRow = startRow;
|
|
11461
|
+
let lastRowPosition = startY;
|
|
11442
11462
|
for (let r = rowStart; r <= rowEnd; r++) {
|
|
11443
11463
|
if (hasMergeData) {
|
|
11444
11464
|
if (worksheet.getRowVisible(r) === false) {
|
|
@@ -11460,20 +11480,29 @@ var Spreadsheet = class Spreadsheet extends SheetComponent {
|
|
|
11460
11480
|
}
|
|
11461
11481
|
if (r < 0 || r > rowHeightAccumulationLength - 1) continue;
|
|
11462
11482
|
const rowEndPosition = rowHeightAccumulation[r];
|
|
11483
|
+
if (rowEndPosition === lastRowPosition) continue;
|
|
11463
11484
|
ctx.beginPath();
|
|
11464
11485
|
ctx.moveToByPrecision(startX, rowEndPosition);
|
|
11465
11486
|
ctx.lineToByPrecision(endX, rowEndPosition);
|
|
11466
11487
|
ctx.closePathByEnv();
|
|
11467
11488
|
ctx.stroke();
|
|
11489
|
+
lastRowPosition = rowEndPosition;
|
|
11468
11490
|
}
|
|
11491
|
+
let lastColumnPosition = startX;
|
|
11469
11492
|
for (let c = columnStart; c <= columnEnd; c++) {
|
|
11470
11493
|
if (c < 0 || c > columnWidthAccumulationLength - 1) continue;
|
|
11471
11494
|
const columnEndPosition = columnWidthAccumulation[c];
|
|
11495
|
+
if (columnEndPosition === lastColumnPosition) {
|
|
11496
|
+
if (columnWidthAccumulation[columnEnd] === columnEndPosition) break;
|
|
11497
|
+
c = binSearchFirstGreaterThanTarget(columnWidthAccumulation, columnEndPosition) - 1;
|
|
11498
|
+
continue;
|
|
11499
|
+
}
|
|
11472
11500
|
ctx.beginPath();
|
|
11473
11501
|
ctx.moveToByPrecision(columnEndPosition, startY);
|
|
11474
11502
|
ctx.lineToByPrecision(columnEndPosition, endY);
|
|
11475
11503
|
ctx.closePathByEnv();
|
|
11476
11504
|
ctx.stroke();
|
|
11505
|
+
lastColumnPosition = columnEndPosition;
|
|
11477
11506
|
}
|
|
11478
11507
|
const mergeCellRanges = [];
|
|
11479
11508
|
if (hasMergeData) for (const mergeVisibleRange of mergeVisibleRanges) {
|
|
@@ -12235,7 +12264,7 @@ function observeClientRect(containerElement) {
|
|
|
12235
12264
|
function observeMove(element, onMove) {
|
|
12236
12265
|
let io = null;
|
|
12237
12266
|
let timeoutId;
|
|
12238
|
-
const root =
|
|
12267
|
+
const root = element.ownerDocument.documentElement;
|
|
12239
12268
|
function cleanup() {
|
|
12240
12269
|
clearTimeout(timeoutId);
|
|
12241
12270
|
io === null || io === void 0 || io.disconnect();
|
|
@@ -12246,13 +12275,13 @@ function observeMove(element, onMove) {
|
|
|
12246
12275
|
const { left, top, width, height } = element.getBoundingClientRect();
|
|
12247
12276
|
if (!skip) onMove();
|
|
12248
12277
|
if (!width || !height) return;
|
|
12249
|
-
const insetTop = floor(top);
|
|
12250
|
-
const insetRight = floor(root.clientWidth - (left + width));
|
|
12251
|
-
const insetBottom = floor(root.clientHeight - (top + height));
|
|
12252
|
-
const insetLeft = floor(left);
|
|
12278
|
+
const insetTop = Math.floor(top);
|
|
12279
|
+
const insetRight = Math.floor(root.clientWidth - (left + width));
|
|
12280
|
+
const insetBottom = Math.floor(root.clientHeight - (top + height));
|
|
12281
|
+
const insetLeft = Math.floor(left);
|
|
12253
12282
|
const options = {
|
|
12254
12283
|
rootMargin: `${-insetTop}px ${-insetRight}px ${-insetBottom}px ${-insetLeft}px`,
|
|
12255
|
-
threshold: max(0, min(1, threshold)) || 1
|
|
12284
|
+
threshold: Math.max(0, Math.min(1, threshold)) || 1
|
|
12256
12285
|
};
|
|
12257
12286
|
let isFirstUpdate = true;
|
|
12258
12287
|
function handleObserve(entries) {
|
|
@@ -12271,7 +12300,7 @@ function observeMove(element, onMove) {
|
|
|
12271
12300
|
...options,
|
|
12272
12301
|
root: root.ownerDocument
|
|
12273
12302
|
});
|
|
12274
|
-
} catch
|
|
12303
|
+
} catch {
|
|
12275
12304
|
io = new IntersectionObserver(handleObserve, options);
|
|
12276
12305
|
}
|
|
12277
12306
|
io.observe(element);
|
|
@@ -13039,7 +13068,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
13039
13068
|
|
|
13040
13069
|
// package.json
|
|
13041
13070
|
var name = "@univerjs/engine-render";
|
|
13042
|
-
var version = "1.6.
|
|
13071
|
+
var version = "1.6.2";
|
|
13043
13072
|
|
|
13044
13073
|
// src/config/config.ts
|
|
13045
13074
|
/**
|