@univerjs/engine-render 1.6.0 → 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 +86 -46
- 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 +87 -47
- package/lib/es/worker.js +1 -1
- package/lib/index.js +87 -47
- package/lib/umd/index.js +5 -5
- package/lib/worker.js +1 -1
- package/package.json +3 -4
|
@@ -3291,7 +3291,7 @@ function drawLineByBorderType(ctx, type, lineWidthBuffer, position) {
|
|
|
3291
3291
|
} else if (type === "b") {
|
|
3292
3292
|
drawStartX = startX - lineWidthBuffer;
|
|
3293
3293
|
drawStartY = endY;
|
|
3294
|
-
drawEndX = endX
|
|
3294
|
+
drawEndX = endX + lineWidthBuffer;
|
|
3295
3295
|
drawEndY = endY;
|
|
3296
3296
|
} else if (type === "l") {
|
|
3297
3297
|
drawStartX = startX;
|
|
@@ -18477,11 +18477,11 @@ function __avoidNonOverlappingFloatingTables(table, page) {
|
|
|
18477
18477
|
}
|
|
18478
18478
|
}
|
|
18479
18479
|
function _updateAndPositionTable(ctx, lineTop, lineHeight, page, pages, column, section, skeTablesInParagraph, paragraphIndex, sectionBreakConfig, drawingAnchorTop) {
|
|
18480
|
-
var _tableSource$position, _ctx$dataModel3;
|
|
18480
|
+
var _tableSource$position, _ctx$dataModel3, _documentStyle$compat, _ctx$viewModel$getSel, _documentStyle$compat2;
|
|
18481
18481
|
if (skeTablesInParagraph.length === 0) return false;
|
|
18482
18482
|
const firstUnPositionedTable = skeTablesInParagraph.find((table) => table.hasPositioned === false);
|
|
18483
18483
|
if (firstUnPositionedTable == null) return false;
|
|
18484
|
-
const { tableId, table } = firstUnPositionedTable;
|
|
18484
|
+
const { tableId, table, tableNode } = firstUnPositionedTable;
|
|
18485
18485
|
const { tableSource } = table;
|
|
18486
18486
|
if (firstUnPositionedTable.isSlideTable === false || tableSource.textWrap === _univerjs_core.TableTextWrapType.NONE) switch (tableSource.textWrap) {
|
|
18487
18487
|
case _univerjs_core.TableTextWrapType.NONE:
|
|
@@ -18509,10 +18509,14 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, pages, column,
|
|
|
18509
18509
|
const verticalPosition = (_tableSource$position = tableSource.position) === null || _tableSource$position === void 0 ? void 0 : _tableSource$position.positionV;
|
|
18510
18510
|
const usesPhysicalPageBounds = tableSource.textWrap === _univerjs_core.TableTextWrapType.WRAP && (verticalPosition === null || verticalPosition === void 0 ? void 0 : verticalPosition.relativeFrom) === _univerjs_core.ObjectRelativeFromV.PAGE && (verticalPosition.posOffset != null || verticalPosition.align != null || verticalPosition.percent != null) && top < 0;
|
|
18511
18511
|
const fitsPhysicalPage = usesPhysicalPageBounds && top + height <= page.pageHeight - page.marginTop + LINE_LAYOUT_OVERFLOW_TOLERANCE;
|
|
18512
|
-
const
|
|
18513
|
-
const
|
|
18514
|
-
|
|
18515
|
-
|
|
18512
|
+
const documentStyle = (_ctx$dataModel3 = ctx.dataModel) === null || _ctx$dataModel3 === void 0 ? void 0 : _ctx$dataModel3.documentStyle;
|
|
18513
|
+
const wordCompatibilityMode = Number(documentStyle === null || documentStyle === void 0 || (_documentStyle$compat = documentStyle.compatibilitySettings) === null || _documentStyle$compat === void 0 ? void 0 : _documentStyle$compat.compatibilityMode);
|
|
18514
|
+
const legacyWordLayout = wordCompatibilityMode >= 11 && wordCompatibilityMode < 15;
|
|
18515
|
+
const floating = tableSource.textWrap === _univerjs_core.TableTextWrapType.WRAP;
|
|
18516
|
+
const renderedTableBreak = floating && legacyWordLayout && ((_ctx$viewModel$getSel = ctx.viewModel.getSelfOrHeaderFooterViewModel(page.segmentId).getBody()) === null || _ctx$viewModel$getSel === void 0 || (_ctx$viewModel$getSel = _ctx$viewModel$getSel.renderedPageBreaks) === null || _ctx$viewModel$getSel === void 0 ? void 0 : _ctx$viewModel$getSel.some((index) => !tableNode.exclude(index))) === true;
|
|
18517
|
+
const keepFloatingTableTogether = floating && (documentStyle === null || documentStyle === void 0 || (_documentStyle$compat2 = documentStyle.compatibilityFlags) === null || _documentStyle$compat2 === void 0 ? void 0 : _documentStyle$compat2.doNotBreakWrappedTables) === _univerjs_core.BooleanNumber.TRUE;
|
|
18518
|
+
if ((tableSource.textWrap === _univerjs_core.TableTextWrapType.NONE || page.type === 0 && isTraditionalDocumentCompatibility(sectionBreakConfig.documentCompatibilityPolicy)) && (localTop + height > section.height && !fitsPhysicalPage && !keepFloatingTableTogether || table.hasPageBreak === true) && firstUnPositionedTable.isSlideTable === false) {
|
|
18519
|
+
if (floating && !renderedTableBreak && ((verticalPosition === null || verticalPosition === void 0 ? void 0 : verticalPosition.relativeFrom) === _univerjs_core.ObjectRelativeFromV.PARAGRAPH || (verticalPosition === null || verticalPosition === void 0 ? void 0 : verticalPosition.relativeFrom) === _univerjs_core.ObjectRelativeFromV.LINE) && table.hasPageBreak !== true && column.lines.length > 0) {
|
|
18516
18520
|
const nextPosition = __getWrapTablePosition(table, column, 0, lineHeight, 0);
|
|
18517
18521
|
if (nextPosition != null && nextPosition.top - section.top + height <= section.height + LINE_LAYOUT_OVERFLOW_TOLERANCE) return true;
|
|
18518
18522
|
}
|
|
@@ -18523,9 +18527,7 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, pages, column,
|
|
|
18523
18527
|
marginTop: 0,
|
|
18524
18528
|
marginBottom: 0
|
|
18525
18529
|
} : page;
|
|
18526
|
-
const
|
|
18527
|
-
const viewModel = ctx.viewModel.getSelfOrHeaderFooterViewModel(segmentId);
|
|
18528
|
-
const tableNode = firstUnPositionedTable.tableNode;
|
|
18530
|
+
const viewModel = ctx.viewModel.getSelfOrHeaderFooterViewModel(page.segmentId);
|
|
18529
18531
|
cachePrecomputedTableSkeleton(ctx, tableNode, table);
|
|
18530
18532
|
const { fromCurrentPage, skeTables } = createTableSkeletons(ctx, tableLayoutPage, viewModel, tableNode, sectionBreakConfig, availableHeight);
|
|
18531
18533
|
skeTables.forEach((table, i) => {
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_doc_skeleton = require("./doc-skeleton-
|
|
2
|
+
const require_doc_skeleton = require("./doc-skeleton-BET2eguM.js");
|
|
3
3
|
let _univerjs_core = require("@univerjs/core");
|
|
4
4
|
let rxjs = require("rxjs");
|
|
5
5
|
let _floating_ui_dom = require("@floating-ui/dom");
|
|
6
|
-
let _floating_ui_utils = require("@floating-ui/utils");
|
|
7
|
-
let _floating_ui_utils_dom = require("@floating-ui/utils/dom");
|
|
8
6
|
let _univerjs_icons_svg = require("@univerjs/icons-svg");
|
|
9
7
|
|
|
10
8
|
// src/alignment-snap.ts
|
|
@@ -8168,6 +8166,25 @@ const RENDER_RAW_FORMULA_KEY = "RENDER_RAW_FORMULA";
|
|
|
8168
8166
|
const GENERAL_NUMBER_MAX_SIGNIFICANT_DIGITS = 15;
|
|
8169
8167
|
const GENERAL_NUMBER_RESERVE_GLYPH = "0";
|
|
8170
8168
|
const FULL_WIDTH_HORIZONTAL_ALIGNMENTS = /* @__PURE__ */ new Set([_univerjs_core.HorizontalAlign.JUSTIFIED, _univerjs_core.HorizontalAlign.DISTRIBUTED]);
|
|
8169
|
+
function isNumericCell(cell) {
|
|
8170
|
+
return cell.t === _univerjs_core.CellValueType.NUMBER || !_univerjs_core.Tools.isDefine(cell.t) && typeof cell.v === "number";
|
|
8171
|
+
}
|
|
8172
|
+
function getGeneralNumberReserveWidth(fontString) {
|
|
8173
|
+
return require_doc_skeleton.FontCache.getMeasureText(GENERAL_NUMBER_RESERVE_GLYPH, fontString).width;
|
|
8174
|
+
}
|
|
8175
|
+
function shouldUseCellDocumentLayout(cell, style, { vertexAngle, centerAngle }) {
|
|
8176
|
+
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) ?? _univerjs_core.HorizontalAlign.UNSPECIFIED);
|
|
8177
|
+
}
|
|
8178
|
+
function measureNumericCellWidth(cell, style) {
|
|
8179
|
+
var _style$n;
|
|
8180
|
+
const displayText = (0, _univerjs_core.getDisplayValueFromCell)(cell);
|
|
8181
|
+
if (!displayText) return 0;
|
|
8182
|
+
const fontString = require_doc_skeleton.getFontStyleString(style).fontCache;
|
|
8183
|
+
const roundingReserveWidth = (0, _univerjs_core.isDefaultFormat)((_style$n = style.n) === null || _style$n === void 0 ? void 0 : _style$n.pattern) && Number.isFinite(Number(cell.v)) ? getGeneralNumberReserveWidth(fontString) : 0;
|
|
8184
|
+
const padding = style.pd ?? DEFAULT_PADDING_DATA;
|
|
8185
|
+
const horizontalPadding = (padding.l ?? DEFAULT_PADDING_DATA.l) + (padding.r ?? DEFAULT_PADDING_DATA.r);
|
|
8186
|
+
return Math.ceil(require_doc_skeleton.FontCache.getMeasureText(displayText, fontString).width + roundingReserveWidth + horizontalPadding);
|
|
8187
|
+
}
|
|
8171
8188
|
function getNumberOverflowText(fontString, availableWidth) {
|
|
8172
8189
|
const hashWidth = require_doc_skeleton.FontCache.getMeasureText("#", fontString).width;
|
|
8173
8190
|
if (hashWidth <= 0) return "#";
|
|
@@ -8179,7 +8196,7 @@ function getShrinkToFitScale(contentWidth, availableWidth, fontSize) {
|
|
|
8179
8196
|
}
|
|
8180
8197
|
function getGeneralNumberDisplayText(value, displayText, fontString, availableWidth) {
|
|
8181
8198
|
if (availableWidth <= 0) return displayText;
|
|
8182
|
-
const roundingReserveWidth =
|
|
8199
|
+
const roundingReserveWidth = getGeneralNumberReserveWidth(fontString);
|
|
8183
8200
|
if (require_doc_skeleton.FontCache.getMeasureText(displayText, fontString).width + roundingReserveWidth <= availableWidth) return displayText;
|
|
8184
8201
|
let bestFit = "";
|
|
8185
8202
|
for (let decimalPlaces = 0; decimalPlaces < GENERAL_NUMBER_MAX_SIGNIFICANT_DIGITS; decimalPlaces++) {
|
|
@@ -8698,11 +8715,10 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
8698
8715
|
for (let colIndex = startColumn; colIndex <= endColumn; colIndex++) {
|
|
8699
8716
|
if (!this.worksheet.getColVisible(colIndex)) continue;
|
|
8700
8717
|
if (calculatedCols.has(colIndex)) continue;
|
|
8701
|
-
const autoWidth = this._calculateColWidth(colIndex);
|
|
8702
8718
|
calculatedCols.add(colIndex);
|
|
8703
8719
|
results.push({
|
|
8704
8720
|
col: colIndex,
|
|
8705
|
-
width:
|
|
8721
|
+
width: this._calculateColWidth(colIndex)
|
|
8706
8722
|
});
|
|
8707
8723
|
}
|
|
8708
8724
|
}
|
|
@@ -8716,9 +8732,10 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
8716
8732
|
*/
|
|
8717
8733
|
_calculateColWidth(colIndex) {
|
|
8718
8734
|
const worksheet = this.worksheet;
|
|
8735
|
+
const { defaultColumnWidth } = this._worksheetData;
|
|
8719
8736
|
let colWidth = 0;
|
|
8720
8737
|
const visibleRangeViewMain = this.visibleRangeByViewportKey("viewMain");
|
|
8721
|
-
if (!visibleRangeViewMain) return
|
|
8738
|
+
if (!visibleRangeViewMain) return defaultColumnWidth;
|
|
8722
8739
|
const { startRow: startRowOfViewMain, endRow: endRowOfViewMain } = visibleRangeViewMain;
|
|
8723
8740
|
const rowCount = this.worksheet.getRowCount();
|
|
8724
8741
|
const otherRowIndex = /* @__PURE__ */ new Set();
|
|
@@ -8738,7 +8755,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
8738
8755
|
if (colIndex === 0) currColWidth = this.columnWidthAccumulation[colIndex];
|
|
8739
8756
|
for (let i = 0; i < rowIdxArr.length; i++) {
|
|
8740
8757
|
const row = rowIdxArr[i];
|
|
8741
|
-
const { isMerged, isMergedMainCell } =
|
|
8758
|
+
const { isMerged, isMergedMainCell } = worksheet.getCellInfoInMergeData(row, colIndex);
|
|
8742
8759
|
if (isMerged && !isMergedMainCell) continue;
|
|
8743
8760
|
if (!this.worksheet.getRowVisible(row)) continue;
|
|
8744
8761
|
const cell = worksheet.getCell(row, colIndex);
|
|
@@ -8754,7 +8771,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
8754
8771
|
colWidth = Math.max(colWidth, measuredWidth);
|
|
8755
8772
|
if (colWidth >= 2e3) return require_doc_skeleton.MAXIMUM_COL_WIDTH;
|
|
8756
8773
|
}
|
|
8757
|
-
if (colWidth === 0) return currColWidth;
|
|
8774
|
+
if (colWidth === 0) return Math.max(defaultColumnWidth, currColWidth);
|
|
8758
8775
|
return Math.max(2, colWidth);
|
|
8759
8776
|
}
|
|
8760
8777
|
getColWidth(colIndex) {
|
|
@@ -8773,16 +8790,18 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
8773
8790
|
_getMeasuredWidthByCell(cell, row, column, currColWidth) {
|
|
8774
8791
|
var _cell$fontRenderExten5;
|
|
8775
8792
|
let measuredWidth = 0;
|
|
8776
|
-
if (((_cell$fontRenderExten5 = cell.fontRenderExtension) === null || _cell$fontRenderExten5 === void 0 ? void 0 : _cell$fontRenderExten5.isSkip) &&
|
|
8777
|
-
|
|
8778
|
-
const cellWidth = (_cell$interceptorAuto = cell.interceptorAutoWidth) === null || _cell$interceptorAuto === void 0 ? void 0 : _cell$interceptorAuto.call(cell);
|
|
8793
|
+
if (((_cell$fontRenderExten5 = cell.fontRenderExtension) === null || _cell$fontRenderExten5 === void 0 ? void 0 : _cell$fontRenderExten5.isSkip) && cell.interceptorAutoWidth) {
|
|
8794
|
+
const cellWidth = cell.interceptorAutoWidth();
|
|
8779
8795
|
if (cellWidth) return cellWidth;
|
|
8780
8796
|
}
|
|
8797
|
+
if (!cell.p && (cell.v == null || cell.v === "")) return 0;
|
|
8781
8798
|
const style = this.worksheet.getComposedCellStyleByCellData(row, column, cell);
|
|
8799
|
+
if (isNumericCell(cell) && style.stf !== _univerjs_core.BooleanNumber.TRUE && !shouldUseCellDocumentLayout(cell, style, convertTextRotation(style.tr ?? void 0))) return measureNumericCellWidth(cell, style);
|
|
8782
8800
|
const modelObject = this.worksheet.getCellDocumentModel(cell, style, { isDeepClone: true });
|
|
8783
8801
|
if (modelObject == null) return measuredWidth;
|
|
8784
8802
|
const { documentModel, textRotation } = modelObject;
|
|
8785
8803
|
if (documentModel == null) return measuredWidth;
|
|
8804
|
+
documentModel.updateDocumentRenderConfig({ zeroWidthParagraphBreak: _univerjs_core.BooleanNumber.TRUE });
|
|
8786
8805
|
const documentViewModel = new SheetCellDocumentViewModel(documentModel);
|
|
8787
8806
|
const { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
8788
8807
|
if ((style === null || style === void 0 ? void 0 : style.tb) === _univerjs_core.WrapStrategy.WRAP) {
|
|
@@ -9116,10 +9135,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
9116
9135
|
}).fontCache;
|
|
9117
9136
|
}
|
|
9118
9137
|
_applyNumberDisplay(row, col, fontCache, style) {
|
|
9119
|
-
var _style$
|
|
9138
|
+
var _style$n2;
|
|
9120
9139
|
const cellData = fontCache.cellData;
|
|
9121
|
-
if (!cellData || style.stf === _univerjs_core.BooleanNumber.TRUE || fontCache.documentSkeleton) return;
|
|
9122
|
-
if (cellData.t !== _univerjs_core.CellValueType.NUMBER && (_univerjs_core.Tools.isDefine(cellData.t) || typeof cellData.v !== "number")) return;
|
|
9140
|
+
if (!cellData || style.stf === _univerjs_core.BooleanNumber.TRUE || fontCache.documentSkeleton || !isNumericCell(cellData)) return;
|
|
9123
9141
|
const cellInfo = this.getCellWithCoordByIndex(row, col, false);
|
|
9124
9142
|
const startX = cellInfo.isMergedMainCell ? cellInfo.mergeInfo.startX : cellInfo.startX;
|
|
9125
9143
|
const endX = cellInfo.isMergedMainCell ? cellInfo.mergeInfo.endX : cellInfo.endX;
|
|
@@ -9127,7 +9145,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
9127
9145
|
const extension = cellData.fontRenderExtension;
|
|
9128
9146
|
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);
|
|
9129
9147
|
const displayText = fontCache.displayText ?? (0, _univerjs_core.getDisplayValueFromCell)(cellData);
|
|
9130
|
-
if ((0, _univerjs_core.isDefaultFormat)((_style$
|
|
9148
|
+
if ((0, _univerjs_core.isDefaultFormat)((_style$n2 = style.n) === null || _style$n2 === void 0 ? void 0 : _style$n2.pattern)) {
|
|
9131
9149
|
const value = Number(cellData.v);
|
|
9132
9150
|
if (Number.isFinite(value)) fontCache.displayText = getGeneralNumberDisplayText(value, displayText, fontCache.fontString, availableWidth);
|
|
9133
9151
|
} else fontCache.displayText = getCustomNumberDisplayText(displayText, fontCache.fontString, availableWidth);
|
|
@@ -9152,8 +9170,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
9152
9170
|
this._stylesCache.fontMatrix.setValue(row, col, cacheValue);
|
|
9153
9171
|
return;
|
|
9154
9172
|
}
|
|
9155
|
-
const
|
|
9156
|
-
const
|
|
9173
|
+
const rotation = convertTextRotation((style === null || style === void 0 ? void 0 : style.tr) ?? void 0);
|
|
9174
|
+
const { vertexAngle, centerAngle } = rotation;
|
|
9175
|
+
const modelObject = shouldUseCellDocumentLayout(cellData, style, rotation) ? this.worksheet.getCellDocumentModel(cellData, style, {
|
|
9157
9176
|
isDeepClone: true,
|
|
9158
9177
|
displayRawFormula: this._renderRawFormula
|
|
9159
9178
|
}) : null;
|
|
@@ -11440,6 +11459,7 @@ var Spreadsheet = class Spreadsheet extends SheetComponent {
|
|
|
11440
11459
|
if (repairNativeGridlines) this._repairGridlineStroke(ctx, startX, startY, endX, endY);
|
|
11441
11460
|
const mergeVisibleRanges = [];
|
|
11442
11461
|
let mergeVisibleRangeStartRow = startRow;
|
|
11462
|
+
let lastRowPosition = startY;
|
|
11443
11463
|
for (let r = rowStart; r <= rowEnd; r++) {
|
|
11444
11464
|
if (hasMergeData) {
|
|
11445
11465
|
if (worksheet.getRowVisible(r) === false) {
|
|
@@ -11461,20 +11481,29 @@ var Spreadsheet = class Spreadsheet extends SheetComponent {
|
|
|
11461
11481
|
}
|
|
11462
11482
|
if (r < 0 || r > rowHeightAccumulationLength - 1) continue;
|
|
11463
11483
|
const rowEndPosition = rowHeightAccumulation[r];
|
|
11484
|
+
if (rowEndPosition === lastRowPosition) continue;
|
|
11464
11485
|
ctx.beginPath();
|
|
11465
11486
|
ctx.moveToByPrecision(startX, rowEndPosition);
|
|
11466
11487
|
ctx.lineToByPrecision(endX, rowEndPosition);
|
|
11467
11488
|
ctx.closePathByEnv();
|
|
11468
11489
|
ctx.stroke();
|
|
11490
|
+
lastRowPosition = rowEndPosition;
|
|
11469
11491
|
}
|
|
11492
|
+
let lastColumnPosition = startX;
|
|
11470
11493
|
for (let c = columnStart; c <= columnEnd; c++) {
|
|
11471
11494
|
if (c < 0 || c > columnWidthAccumulationLength - 1) continue;
|
|
11472
11495
|
const columnEndPosition = columnWidthAccumulation[c];
|
|
11496
|
+
if (columnEndPosition === lastColumnPosition) {
|
|
11497
|
+
if (columnWidthAccumulation[columnEnd] === columnEndPosition) break;
|
|
11498
|
+
c = (0, _univerjs_core.binSearchFirstGreaterThanTarget)(columnWidthAccumulation, columnEndPosition) - 1;
|
|
11499
|
+
continue;
|
|
11500
|
+
}
|
|
11473
11501
|
ctx.beginPath();
|
|
11474
11502
|
ctx.moveToByPrecision(columnEndPosition, startY);
|
|
11475
11503
|
ctx.lineToByPrecision(columnEndPosition, endY);
|
|
11476
11504
|
ctx.closePathByEnv();
|
|
11477
11505
|
ctx.stroke();
|
|
11506
|
+
lastColumnPosition = columnEndPosition;
|
|
11478
11507
|
}
|
|
11479
11508
|
const mergeCellRanges = [];
|
|
11480
11509
|
if (hasMergeData) for (const mergeVisibleRange of mergeVisibleRanges) {
|
|
@@ -12236,7 +12265,7 @@ function observeClientRect(containerElement) {
|
|
|
12236
12265
|
function observeMove(element, onMove) {
|
|
12237
12266
|
let io = null;
|
|
12238
12267
|
let timeoutId;
|
|
12239
|
-
const root =
|
|
12268
|
+
const root = element.ownerDocument.documentElement;
|
|
12240
12269
|
function cleanup() {
|
|
12241
12270
|
clearTimeout(timeoutId);
|
|
12242
12271
|
io === null || io === void 0 || io.disconnect();
|
|
@@ -12247,13 +12276,13 @@ function observeMove(element, onMove) {
|
|
|
12247
12276
|
const { left, top, width, height } = element.getBoundingClientRect();
|
|
12248
12277
|
if (!skip) onMove();
|
|
12249
12278
|
if (!width || !height) return;
|
|
12250
|
-
const insetTop =
|
|
12251
|
-
const insetRight =
|
|
12252
|
-
const insetBottom =
|
|
12253
|
-
const insetLeft =
|
|
12279
|
+
const insetTop = Math.floor(top);
|
|
12280
|
+
const insetRight = Math.floor(root.clientWidth - (left + width));
|
|
12281
|
+
const insetBottom = Math.floor(root.clientHeight - (top + height));
|
|
12282
|
+
const insetLeft = Math.floor(left);
|
|
12254
12283
|
const options = {
|
|
12255
12284
|
rootMargin: `${-insetTop}px ${-insetRight}px ${-insetBottom}px ${-insetLeft}px`,
|
|
12256
|
-
threshold:
|
|
12285
|
+
threshold: Math.max(0, Math.min(1, threshold)) || 1
|
|
12257
12286
|
};
|
|
12258
12287
|
let isFirstUpdate = true;
|
|
12259
12288
|
function handleObserve(entries) {
|
|
@@ -12272,7 +12301,7 @@ function observeMove(element, onMove) {
|
|
|
12272
12301
|
...options,
|
|
12273
12302
|
root: root.ownerDocument
|
|
12274
12303
|
});
|
|
12275
|
-
} catch
|
|
12304
|
+
} catch {
|
|
12276
12305
|
io = new IntersectionObserver(handleObserve, options);
|
|
12277
12306
|
}
|
|
12278
12307
|
io.observe(element);
|
|
@@ -13040,7 +13069,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
13040
13069
|
|
|
13041
13070
|
// package.json
|
|
13042
13071
|
var name = "@univerjs/engine-render";
|
|
13043
|
-
var version = "1.6.
|
|
13072
|
+
var version = "1.6.2";
|
|
13044
13073
|
|
|
13045
13074
|
// src/config/config.ts
|
|
13046
13075
|
/**
|
|
@@ -15306,23 +15335,27 @@ const SCROLLBAR_SEEK_EXPENSIVE_RENDER_MIN_MS = 32;
|
|
|
15306
15335
|
const SCROLLBAR_SEEK_EXPENSIVE_RENDER_FRAME_INTERVALS = 2;
|
|
15307
15336
|
const SCROLLBAR_SEEK_RENDER_COST_SAMPLE_WEIGHT = .25;
|
|
15308
15337
|
const VIEWPORT_SHARED_EDGE_TOLERANCE = 1;
|
|
15309
|
-
function
|
|
15338
|
+
function createScrollRepaintBounds(viewportBounds, copyBounds, offsetX, offsetY) {
|
|
15339
|
+
const left = copyBounds.left + Math.max(0, offsetX);
|
|
15340
|
+
const right = copyBounds.right + Math.min(0, offsetX);
|
|
15341
|
+
const top = copyBounds.top + Math.max(0, offsetY);
|
|
15342
|
+
const bottom = copyBounds.bottom + Math.min(0, offsetY);
|
|
15310
15343
|
const dirtyBounds = [];
|
|
15311
|
-
if (
|
|
15312
|
-
...
|
|
15313
|
-
right:
|
|
15344
|
+
if (left > viewportBounds.left) dirtyBounds.push({
|
|
15345
|
+
...viewportBounds,
|
|
15346
|
+
right: left
|
|
15314
15347
|
});
|
|
15315
|
-
|
|
15316
|
-
...
|
|
15317
|
-
left:
|
|
15348
|
+
if (right < viewportBounds.right) dirtyBounds.push({
|
|
15349
|
+
...viewportBounds,
|
|
15350
|
+
left: right
|
|
15318
15351
|
});
|
|
15319
|
-
if (
|
|
15320
|
-
...
|
|
15321
|
-
bottom:
|
|
15352
|
+
if (top > viewportBounds.top) dirtyBounds.push({
|
|
15353
|
+
...viewportBounds,
|
|
15354
|
+
bottom: top
|
|
15322
15355
|
});
|
|
15323
|
-
|
|
15324
|
-
...
|
|
15325
|
-
top:
|
|
15356
|
+
if (bottom < viewportBounds.bottom) dirtyBounds.push({
|
|
15357
|
+
...viewportBounds,
|
|
15358
|
+
top: bottom
|
|
15326
15359
|
});
|
|
15327
15360
|
return dirtyBounds;
|
|
15328
15361
|
}
|
|
@@ -15965,7 +15998,7 @@ var Scene = class extends _univerjs_core.Disposable {
|
|
|
15965
15998
|
getViewport(key) {
|
|
15966
15999
|
for (const viewport of this._viewports) if (viewport.viewportKey === key) return viewport;
|
|
15967
16000
|
}
|
|
15968
|
-
_createScrollRenderState() {
|
|
16001
|
+
_createScrollRenderState(pixelRatio) {
|
|
15969
16002
|
const dirtyBounds = [];
|
|
15970
16003
|
const scrollRenderInfos = [];
|
|
15971
16004
|
const viewportInfos = /* @__PURE__ */ new Map();
|
|
@@ -15982,13 +16015,19 @@ var Scene = class extends _univerjs_core.Disposable {
|
|
|
15982
16015
|
dirtyBounds.push(...viewportState.dirtyBounds);
|
|
15983
16016
|
if (scrollRenderInfo) {
|
|
15984
16017
|
const followingViewportBounds = viewportStates.slice(index + 1).map((state) => state.viewportInfo.viewPortPosition).filter((bounds) => bounds != null);
|
|
15985
|
-
const bounds =
|
|
15986
|
-
const
|
|
15987
|
-
|
|
16018
|
+
const { bounds: viewportBounds, offsetX, offsetY } = scrollRenderInfo;
|
|
16019
|
+
const bounds = trimSharedViewportEdges(viewportBounds, followingViewportBounds);
|
|
16020
|
+
const pixelCoordinates = [
|
|
16021
|
+
...Object.values(viewportBounds),
|
|
16022
|
+
...Object.values(bounds),
|
|
16023
|
+
offsetX,
|
|
16024
|
+
offsetY
|
|
16025
|
+
];
|
|
16026
|
+
if (isInvalidScrollBounds(bounds, offsetX, offsetY) || pixelCoordinates.some((value) => !Number.isInteger(require_doc_skeleton.precisionTo(value * pixelRatio, 6)))) {
|
|
15988
16027
|
canPreserveEngine = false;
|
|
15989
16028
|
continue;
|
|
15990
16029
|
}
|
|
15991
|
-
dirtyBounds.push(...
|
|
16030
|
+
dirtyBounds.push(...createScrollRepaintBounds(viewportBounds, bounds, offsetX, offsetY));
|
|
15992
16031
|
scrollRenderInfos.push({
|
|
15993
16032
|
bounds,
|
|
15994
16033
|
offsetX,
|
|
@@ -16060,9 +16099,10 @@ var Scene = class extends _univerjs_core.Disposable {
|
|
|
16060
16099
|
this._preserveEngineOnRender = false;
|
|
16061
16100
|
let layerRenderOptions;
|
|
16062
16101
|
if (shouldTryPreservingEngine) {
|
|
16063
|
-
const
|
|
16102
|
+
const pixelRatio = canvasInstance.getPixelRatio();
|
|
16103
|
+
const { canPreserveEngine, dirtyBounds, scrollRenderInfos, viewportInfos } = this._createScrollRenderState(pixelRatio);
|
|
16064
16104
|
if (canPreserveEngine) {
|
|
16065
|
-
scrollAndClearCanvas(canvasInstance.getContext(),
|
|
16105
|
+
scrollAndClearCanvas(canvasInstance.getContext(), pixelRatio, scrollRenderInfos, dirtyBounds);
|
|
16066
16106
|
layerRenderOptions = {
|
|
16067
16107
|
dirtyBounds,
|
|
16068
16108
|
preserveCache: true,
|
package/lib/cjs/worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_doc_skeleton = require("./doc-skeleton-
|
|
2
|
+
const require_doc_skeleton = require("./doc-skeleton-BET2eguM.js");
|
|
3
3
|
let _univerjs_core = require("@univerjs/core");
|
|
4
4
|
|
|
5
5
|
// src/worker-layout.ts
|
|
@@ -3291,7 +3291,7 @@ function drawLineByBorderType(ctx, type, lineWidthBuffer, position) {
|
|
|
3291
3291
|
} else if (type === "b") {
|
|
3292
3292
|
drawStartX = startX - lineWidthBuffer;
|
|
3293
3293
|
drawStartY = endY;
|
|
3294
|
-
drawEndX = endX
|
|
3294
|
+
drawEndX = endX + lineWidthBuffer;
|
|
3295
3295
|
drawEndY = endY;
|
|
3296
3296
|
} else if (type === "l") {
|
|
3297
3297
|
drawStartX = startX;
|
|
@@ -18477,11 +18477,11 @@ function __avoidNonOverlappingFloatingTables(table, page) {
|
|
|
18477
18477
|
}
|
|
18478
18478
|
}
|
|
18479
18479
|
function _updateAndPositionTable(ctx, lineTop, lineHeight, page, pages, column, section, skeTablesInParagraph, paragraphIndex, sectionBreakConfig, drawingAnchorTop) {
|
|
18480
|
-
var _tableSource$position, _ctx$dataModel3;
|
|
18480
|
+
var _tableSource$position, _ctx$dataModel3, _documentStyle$compat, _ctx$viewModel$getSel, _documentStyle$compat2;
|
|
18481
18481
|
if (skeTablesInParagraph.length === 0) return false;
|
|
18482
18482
|
const firstUnPositionedTable = skeTablesInParagraph.find((table) => table.hasPositioned === false);
|
|
18483
18483
|
if (firstUnPositionedTable == null) return false;
|
|
18484
|
-
const { tableId, table } = firstUnPositionedTable;
|
|
18484
|
+
const { tableId, table, tableNode } = firstUnPositionedTable;
|
|
18485
18485
|
const { tableSource } = table;
|
|
18486
18486
|
if (firstUnPositionedTable.isSlideTable === false || tableSource.textWrap === TableTextWrapType.NONE) switch (tableSource.textWrap) {
|
|
18487
18487
|
case TableTextWrapType.NONE:
|
|
@@ -18509,10 +18509,14 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, pages, column,
|
|
|
18509
18509
|
const verticalPosition = (_tableSource$position = tableSource.position) === null || _tableSource$position === void 0 ? void 0 : _tableSource$position.positionV;
|
|
18510
18510
|
const usesPhysicalPageBounds = tableSource.textWrap === TableTextWrapType.WRAP && (verticalPosition === null || verticalPosition === void 0 ? void 0 : verticalPosition.relativeFrom) === ObjectRelativeFromV.PAGE && (verticalPosition.posOffset != null || verticalPosition.align != null || verticalPosition.percent != null) && top < 0;
|
|
18511
18511
|
const fitsPhysicalPage = usesPhysicalPageBounds && top + height <= page.pageHeight - page.marginTop + LINE_LAYOUT_OVERFLOW_TOLERANCE;
|
|
18512
|
-
const
|
|
18513
|
-
const
|
|
18514
|
-
|
|
18515
|
-
|
|
18512
|
+
const documentStyle = (_ctx$dataModel3 = ctx.dataModel) === null || _ctx$dataModel3 === void 0 ? void 0 : _ctx$dataModel3.documentStyle;
|
|
18513
|
+
const wordCompatibilityMode = Number(documentStyle === null || documentStyle === void 0 || (_documentStyle$compat = documentStyle.compatibilitySettings) === null || _documentStyle$compat === void 0 ? void 0 : _documentStyle$compat.compatibilityMode);
|
|
18514
|
+
const legacyWordLayout = wordCompatibilityMode >= 11 && wordCompatibilityMode < 15;
|
|
18515
|
+
const floating = tableSource.textWrap === TableTextWrapType.WRAP;
|
|
18516
|
+
const renderedTableBreak = floating && legacyWordLayout && ((_ctx$viewModel$getSel = ctx.viewModel.getSelfOrHeaderFooterViewModel(page.segmentId).getBody()) === null || _ctx$viewModel$getSel === void 0 || (_ctx$viewModel$getSel = _ctx$viewModel$getSel.renderedPageBreaks) === null || _ctx$viewModel$getSel === void 0 ? void 0 : _ctx$viewModel$getSel.some((index) => !tableNode.exclude(index))) === true;
|
|
18517
|
+
const keepFloatingTableTogether = floating && (documentStyle === null || documentStyle === void 0 || (_documentStyle$compat2 = documentStyle.compatibilityFlags) === null || _documentStyle$compat2 === void 0 ? void 0 : _documentStyle$compat2.doNotBreakWrappedTables) === BooleanNumber.TRUE;
|
|
18518
|
+
if ((tableSource.textWrap === TableTextWrapType.NONE || page.type === 0 && isTraditionalDocumentCompatibility(sectionBreakConfig.documentCompatibilityPolicy)) && (localTop + height > section.height && !fitsPhysicalPage && !keepFloatingTableTogether || table.hasPageBreak === true) && firstUnPositionedTable.isSlideTable === false) {
|
|
18519
|
+
if (floating && !renderedTableBreak && ((verticalPosition === null || verticalPosition === void 0 ? void 0 : verticalPosition.relativeFrom) === ObjectRelativeFromV.PARAGRAPH || (verticalPosition === null || verticalPosition === void 0 ? void 0 : verticalPosition.relativeFrom) === ObjectRelativeFromV.LINE) && table.hasPageBreak !== true && column.lines.length > 0) {
|
|
18516
18520
|
const nextPosition = __getWrapTablePosition(table, column, 0, lineHeight, 0);
|
|
18517
18521
|
if (nextPosition != null && nextPosition.top - section.top + height <= section.height + LINE_LAYOUT_OVERFLOW_TOLERANCE) return true;
|
|
18518
18522
|
}
|
|
@@ -18523,9 +18527,7 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, pages, column,
|
|
|
18523
18527
|
marginTop: 0,
|
|
18524
18528
|
marginBottom: 0
|
|
18525
18529
|
} : page;
|
|
18526
|
-
const
|
|
18527
|
-
const viewModel = ctx.viewModel.getSelfOrHeaderFooterViewModel(segmentId);
|
|
18528
|
-
const tableNode = firstUnPositionedTable.tableNode;
|
|
18530
|
+
const viewModel = ctx.viewModel.getSelfOrHeaderFooterViewModel(page.segmentId);
|
|
18529
18531
|
cachePrecomputedTableSkeleton(ctx, tableNode, table);
|
|
18530
18532
|
const { fromCurrentPage, skeTables } = createTableSkeletons(ctx, tableLayoutPage, viewModel, tableNode, sectionBreakConfig, availableHeight);
|
|
18531
18533
|
skeTables.forEach((table, i) => {
|
|
@@ -3291,7 +3291,7 @@ function drawLineByBorderType(ctx, type, lineWidthBuffer, position) {
|
|
|
3291
3291
|
} else if (type === "b") {
|
|
3292
3292
|
drawStartX = startX - lineWidthBuffer;
|
|
3293
3293
|
drawStartY = endY;
|
|
3294
|
-
drawEndX = endX
|
|
3294
|
+
drawEndX = endX + lineWidthBuffer;
|
|
3295
3295
|
drawEndY = endY;
|
|
3296
3296
|
} else if (type === "l") {
|
|
3297
3297
|
drawStartX = startX;
|
|
@@ -18477,11 +18477,11 @@ function __avoidNonOverlappingFloatingTables(table, page) {
|
|
|
18477
18477
|
}
|
|
18478
18478
|
}
|
|
18479
18479
|
function _updateAndPositionTable(ctx, lineTop, lineHeight, page, pages, column, section, skeTablesInParagraph, paragraphIndex, sectionBreakConfig, drawingAnchorTop) {
|
|
18480
|
-
var _tableSource$position, _ctx$dataModel3;
|
|
18480
|
+
var _tableSource$position, _ctx$dataModel3, _documentStyle$compat, _ctx$viewModel$getSel, _documentStyle$compat2;
|
|
18481
18481
|
if (skeTablesInParagraph.length === 0) return false;
|
|
18482
18482
|
const firstUnPositionedTable = skeTablesInParagraph.find((table) => table.hasPositioned === false);
|
|
18483
18483
|
if (firstUnPositionedTable == null) return false;
|
|
18484
|
-
const { tableId, table } = firstUnPositionedTable;
|
|
18484
|
+
const { tableId, table, tableNode } = firstUnPositionedTable;
|
|
18485
18485
|
const { tableSource } = table;
|
|
18486
18486
|
if (firstUnPositionedTable.isSlideTable === false || tableSource.textWrap === TableTextWrapType.NONE) switch (tableSource.textWrap) {
|
|
18487
18487
|
case TableTextWrapType.NONE:
|
|
@@ -18509,10 +18509,14 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, pages, column,
|
|
|
18509
18509
|
const verticalPosition = (_tableSource$position = tableSource.position) === null || _tableSource$position === void 0 ? void 0 : _tableSource$position.positionV;
|
|
18510
18510
|
const usesPhysicalPageBounds = tableSource.textWrap === TableTextWrapType.WRAP && (verticalPosition === null || verticalPosition === void 0 ? void 0 : verticalPosition.relativeFrom) === ObjectRelativeFromV.PAGE && (verticalPosition.posOffset != null || verticalPosition.align != null || verticalPosition.percent != null) && top < 0;
|
|
18511
18511
|
const fitsPhysicalPage = usesPhysicalPageBounds && top + height <= page.pageHeight - page.marginTop + LINE_LAYOUT_OVERFLOW_TOLERANCE;
|
|
18512
|
-
const
|
|
18513
|
-
const
|
|
18514
|
-
|
|
18515
|
-
|
|
18512
|
+
const documentStyle = (_ctx$dataModel3 = ctx.dataModel) === null || _ctx$dataModel3 === void 0 ? void 0 : _ctx$dataModel3.documentStyle;
|
|
18513
|
+
const wordCompatibilityMode = Number(documentStyle === null || documentStyle === void 0 || (_documentStyle$compat = documentStyle.compatibilitySettings) === null || _documentStyle$compat === void 0 ? void 0 : _documentStyle$compat.compatibilityMode);
|
|
18514
|
+
const legacyWordLayout = wordCompatibilityMode >= 11 && wordCompatibilityMode < 15;
|
|
18515
|
+
const floating = tableSource.textWrap === TableTextWrapType.WRAP;
|
|
18516
|
+
const renderedTableBreak = floating && legacyWordLayout && ((_ctx$viewModel$getSel = ctx.viewModel.getSelfOrHeaderFooterViewModel(page.segmentId).getBody()) === null || _ctx$viewModel$getSel === void 0 || (_ctx$viewModel$getSel = _ctx$viewModel$getSel.renderedPageBreaks) === null || _ctx$viewModel$getSel === void 0 ? void 0 : _ctx$viewModel$getSel.some((index) => !tableNode.exclude(index))) === true;
|
|
18517
|
+
const keepFloatingTableTogether = floating && (documentStyle === null || documentStyle === void 0 || (_documentStyle$compat2 = documentStyle.compatibilityFlags) === null || _documentStyle$compat2 === void 0 ? void 0 : _documentStyle$compat2.doNotBreakWrappedTables) === BooleanNumber.TRUE;
|
|
18518
|
+
if ((tableSource.textWrap === TableTextWrapType.NONE || page.type === 0 && isTraditionalDocumentCompatibility(sectionBreakConfig.documentCompatibilityPolicy)) && (localTop + height > section.height && !fitsPhysicalPage && !keepFloatingTableTogether || table.hasPageBreak === true) && firstUnPositionedTable.isSlideTable === false) {
|
|
18519
|
+
if (floating && !renderedTableBreak && ((verticalPosition === null || verticalPosition === void 0 ? void 0 : verticalPosition.relativeFrom) === ObjectRelativeFromV.PARAGRAPH || (verticalPosition === null || verticalPosition === void 0 ? void 0 : verticalPosition.relativeFrom) === ObjectRelativeFromV.LINE) && table.hasPageBreak !== true && column.lines.length > 0) {
|
|
18516
18520
|
const nextPosition = __getWrapTablePosition(table, column, 0, lineHeight, 0);
|
|
18517
18521
|
if (nextPosition != null && nextPosition.top - section.top + height <= section.height + LINE_LAYOUT_OVERFLOW_TOLERANCE) return true;
|
|
18518
18522
|
}
|
|
@@ -18523,9 +18527,7 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, pages, column,
|
|
|
18523
18527
|
marginTop: 0,
|
|
18524
18528
|
marginBottom: 0
|
|
18525
18529
|
} : page;
|
|
18526
|
-
const
|
|
18527
|
-
const viewModel = ctx.viewModel.getSelfOrHeaderFooterViewModel(segmentId);
|
|
18528
|
-
const tableNode = firstUnPositionedTable.tableNode;
|
|
18530
|
+
const viewModel = ctx.viewModel.getSelfOrHeaderFooterViewModel(page.segmentId);
|
|
18529
18531
|
cachePrecomputedTableSkeleton(ctx, tableNode, table);
|
|
18530
18532
|
const { fromCurrentPage, skeTables } = createTableSkeletons(ctx, tableLayoutPage, viewModel, tableNode, sectionBreakConfig, availableHeight);
|
|
18531
18533
|
skeTables.forEach((table, i) => {
|