@univerjs/engine-render 0.23.0 → 0.24.0-insiders.20260528-29f582d
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/index.js +540 -146
- package/lib/es/index.js +536 -146
- package/lib/types/basics/index.d.ts +1 -0
- package/lib/types/basics/tools.d.ts +1 -0
- package/lib/types/basics/zoom.d.ts +17 -0
- package/lib/types/components/docs/doc-background.d.ts +6 -0
- package/lib/types/components/docs/doc-component.d.ts +4 -0
- package/lib/types/components/docs/document.d.ts +6 -0
- package/lib/types/components/docs/layout/block/paragraph/language-ruler.d.ts +4 -0
- package/lib/types/components/docs/layout/model/page.d.ts +1 -0
- package/lib/types/components/docs/table-render-viewport.d.ts +23 -0
- package/lib/types/components/sheets/interfaces.d.ts +2 -2
- package/lib/types/index.d.ts +2 -0
- package/lib/umd/index.js +2 -2
- package/package.json +3 -3
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as EnUs } from "./en-us-ClVoWMyT.js";
|
|
2
|
-
import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentDataModel, DocumentFlavor, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, ListGlyphType, LocaleService, MOVE_BUFFER_VALUE, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SectionType, SheetSkeleton, Skeleton, SpacingRule, TableAlignmentType, TableRowHeightRule, TableTextWrapType, TextDecoration, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, addLinkToDocumentModel, checkParagraphHasIndentByStyle, createIdentifier, deleteContent, extractPureTextFromCell, getCellInfoInMergeData, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isClassDependencyItem, isNullCell, isWhiteColor, merge, mergeWith, numberToABC, numberToListABC, registerDependencies, remove, requestImmediateMacroTask, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
|
|
2
|
+
import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentDataModel, DocumentFlavor, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, ListGlyphType, LocaleService, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SectionType, SheetSkeleton, Skeleton, SpacingRule, TableAlignmentType, TableRowHeightRule, TableTextWrapType, TextDecoration, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, addLinkToDocumentModel, checkParagraphHasIndentByStyle, createIdentifier, deleteContent, extractPureTextFromCell, getCellInfoInMergeData, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isClassDependencyItem, isNullCell, isWhiteColor, merge, mergeWith, noop, numberToABC, numberToListABC, registerDependencies, remove, requestImmediateMacroTask, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
|
|
3
3
|
import * as cjk from "cjk-regex";
|
|
4
4
|
import { BehaviorSubject, Observable, Subject, Subscription, debounceTime, distinctUntilChanged, shareReplay, startWith } from "rxjs";
|
|
5
5
|
import { parse } from "opentype.js";
|
|
@@ -280,14 +280,7 @@ function getFontStyleString(textStyle) {
|
|
|
280
280
|
let originFontSize = defaultFontSize;
|
|
281
281
|
if (textStyle.fs) originFontSize = Math.ceil(textStyle.fs);
|
|
282
282
|
let fontSize = originFontSize;
|
|
283
|
-
|
|
284
|
-
if (textStyle.ff) {
|
|
285
|
-
let fontFamily = textStyle.ff;
|
|
286
|
-
fontFamily = fontFamily.replace(/"/g, "").replace(/'/g, "");
|
|
287
|
-
if (fontFamily.indexOf(" ") > -1) fontFamily = `"${fontFamily}"`;
|
|
288
|
-
if (fontFamily == null) fontFamily = defaultFont;
|
|
289
|
-
fontFamilyResult = fontFamily;
|
|
290
|
-
}
|
|
283
|
+
const fontFamilyResult = normalizeFontFamily(textStyle.ff, defaultFont);
|
|
291
284
|
const { va: baselineOffset } = textStyle;
|
|
292
285
|
if (baselineOffset === BaselineOffset.SUBSCRIPT || baselineOffset === BaselineOffset.SUPERSCRIPT) {
|
|
293
286
|
const { sbr, spr } = FontCache.getBaselineOffsetInfo(fontFamilyResult, fontSize);
|
|
@@ -302,6 +295,13 @@ function getFontStyleString(textStyle) {
|
|
|
302
295
|
fontFamily: fontFamilyResult
|
|
303
296
|
};
|
|
304
297
|
}
|
|
298
|
+
function normalizeFontFamily(fontFamily, defaultFont) {
|
|
299
|
+
if (!(fontFamily === null || fontFamily === void 0 ? void 0 : fontFamily.trim())) return defaultFont;
|
|
300
|
+
return fontFamily.split(",").map((item) => {
|
|
301
|
+
const family = item.trim().replace(/^['"]|['"]$/g, "");
|
|
302
|
+
return family.includes(" ") ? `"${family}"` : family;
|
|
303
|
+
}).filter(Boolean).join(", ");
|
|
304
|
+
}
|
|
305
305
|
const CJK_LETTER_REG = cjk.letters().toRegExp();
|
|
306
306
|
function hasCJKText(text) {
|
|
307
307
|
return CJK_LETTER_REG.test(text);
|
|
@@ -355,6 +355,9 @@ function hasArabic(text) {
|
|
|
355
355
|
function hasTibetan(text) {
|
|
356
356
|
return /[\u0180-\u024F]/gi.test(text);
|
|
357
357
|
}
|
|
358
|
+
function hasThai(text) {
|
|
359
|
+
return /[\u0E00-\u0E7F]/.test(text);
|
|
360
|
+
}
|
|
358
361
|
function hasSpace(text) {
|
|
359
362
|
return /\s+/g.test(text);
|
|
360
363
|
}
|
|
@@ -2923,6 +2926,37 @@ var Transform = class Transform {
|
|
|
2923
2926
|
}
|
|
2924
2927
|
};
|
|
2925
2928
|
|
|
2929
|
+
//#endregion
|
|
2930
|
+
//#region src/basics/zoom.ts
|
|
2931
|
+
const MIN_ZOOM_RATIO = .1;
|
|
2932
|
+
const MAX_ZOOM_RATIO = 4;
|
|
2933
|
+
const PIXEL_DELTA_TO_ZOOM_RATIO = .008;
|
|
2934
|
+
const MAX_WHEEL_ZOOM_STEP = .14;
|
|
2935
|
+
const MAX_WHEEL_ZOOM_STEP_BELOW_ONE = .07;
|
|
2936
|
+
const LINE_DELTA_PIXEL_SIZE = 16;
|
|
2937
|
+
const PAGE_DELTA_PIXEL_SIZE = 800;
|
|
2938
|
+
const ZOOM_RATIO_PRECISION = 100;
|
|
2939
|
+
function clamp(value, min, max) {
|
|
2940
|
+
return Math.min(max, Math.max(min, value));
|
|
2941
|
+
}
|
|
2942
|
+
function normalizeWheelDelta(event) {
|
|
2943
|
+
const deltaY = Number.isFinite(event.deltaY) ? event.deltaY : 0;
|
|
2944
|
+
const deltaX = Number.isFinite(event.deltaX) ? event.deltaX : 0;
|
|
2945
|
+
let delta = Math.abs(deltaY) >= Math.abs(deltaX) ? deltaY : deltaX;
|
|
2946
|
+
if (delta === 0 && typeof event.wheelDelta === "number") delta = -event.wheelDelta / 3;
|
|
2947
|
+
if (event.deltaMode === EventConstants.DOM_DELTA_LINE) delta *= LINE_DELTA_PIXEL_SIZE;
|
|
2948
|
+
else if (event.deltaMode === EventConstants.DOM_DELTA_PAGE) delta *= PAGE_DELTA_PIXEL_SIZE;
|
|
2949
|
+
return delta;
|
|
2950
|
+
}
|
|
2951
|
+
function getNextWheelZoomRatio(currentRatio, event) {
|
|
2952
|
+
const validCurrentRatio = Number.isFinite(currentRatio) ? currentRatio : 1;
|
|
2953
|
+
const normalizedDelta = normalizeWheelDelta(event);
|
|
2954
|
+
if (normalizedDelta === 0) return clamp(validCurrentRatio, MIN_ZOOM_RATIO, MAX_ZOOM_RATIO);
|
|
2955
|
+
const maxStep = validCurrentRatio < 1 ? MAX_WHEEL_ZOOM_STEP_BELOW_ONE : MAX_WHEEL_ZOOM_STEP;
|
|
2956
|
+
const ratioDelta = clamp(-normalizedDelta * PIXEL_DELTA_TO_ZOOM_RATIO, -maxStep, maxStep);
|
|
2957
|
+
return clamp(Math.round((validCurrentRatio + ratioDelta) * ZOOM_RATIO_PRECISION) / ZOOM_RATIO_PRECISION, MIN_ZOOM_RATIO, MAX_ZOOM_RATIO);
|
|
2958
|
+
}
|
|
2959
|
+
|
|
2926
2960
|
//#endregion
|
|
2927
2961
|
//#region src/base-object.ts
|
|
2928
2962
|
const BASE_OBJECT_ARRAY = [
|
|
@@ -4686,8 +4720,9 @@ var SpreadsheetColumnHeader = class extends SpreadsheetHeader {
|
|
|
4686
4720
|
const segment = spreadsheetSkeleton.rowColumnSegment;
|
|
4687
4721
|
if (!segment) return;
|
|
4688
4722
|
if (segment.startColumn === -1 && segment.endColumn === -1) return;
|
|
4689
|
-
const {
|
|
4690
|
-
|
|
4723
|
+
const { columnHeaderHeight, columnHeaderHeightAndMarginTop, rowHeaderWidthAndMarginLeft } = spreadsheetSkeleton;
|
|
4724
|
+
const marginTop = columnHeaderHeightAndMarginTop - columnHeaderHeight;
|
|
4725
|
+
ctx.translateWithPrecision(rowHeaderWidthAndMarginLeft, marginTop);
|
|
4691
4726
|
const extensions = this.getExtensionsByOrder();
|
|
4692
4727
|
for (const extension of extensions) extension.draw(ctx, parentScale, spreadsheetSkeleton);
|
|
4693
4728
|
}
|
|
@@ -4695,8 +4730,9 @@ var SpreadsheetColumnHeader = class extends SpreadsheetHeader {
|
|
|
4695
4730
|
const oCoord = this.getInverseCoord(coord);
|
|
4696
4731
|
const skeleton = this.getSkeleton();
|
|
4697
4732
|
if (!skeleton) return false;
|
|
4698
|
-
const {
|
|
4699
|
-
|
|
4733
|
+
const { rowHeaderWidthAndMarginLeft, columnHeaderHeight, columnHeaderHeightAndMarginTop } = skeleton;
|
|
4734
|
+
const marginTop = columnHeaderHeightAndMarginTop - columnHeaderHeight;
|
|
4735
|
+
if (oCoord.x > rowHeaderWidthAndMarginLeft && oCoord.y >= marginTop && oCoord.y <= columnHeaderHeightAndMarginTop) return true;
|
|
4700
4736
|
return false;
|
|
4701
4737
|
}
|
|
4702
4738
|
_initialDefaultExtension() {
|
|
@@ -12022,6 +12058,17 @@ var Liquid = class {
|
|
|
12022
12058
|
}
|
|
12023
12059
|
};
|
|
12024
12060
|
|
|
12061
|
+
//#endregion
|
|
12062
|
+
//#region src/components/docs/table-render-viewport.ts
|
|
12063
|
+
let docsTableRenderViewportProvider = null;
|
|
12064
|
+
function setDocsTableRenderViewportProvider(provider) {
|
|
12065
|
+
docsTableRenderViewportProvider = provider;
|
|
12066
|
+
}
|
|
12067
|
+
function getDocsTableRenderViewport(unitId, tableId) {
|
|
12068
|
+
var _docsTableRenderViewp;
|
|
12069
|
+
return (_docsTableRenderViewp = docsTableRenderViewportProvider === null || docsTableRenderViewportProvider === void 0 ? void 0 : docsTableRenderViewportProvider(unitId, tableId)) !== null && _docsTableRenderViewp !== void 0 ? _docsTableRenderViewp : null;
|
|
12070
|
+
}
|
|
12071
|
+
|
|
12025
12072
|
//#endregion
|
|
12026
12073
|
//#region src/components/docs/view-model/data-stream-tree-node.ts
|
|
12027
12074
|
var DataStreamTreeNode = class DataStreamTreeNode {
|
|
@@ -12190,6 +12237,17 @@ function parseDataStreamToTree(dataStream, tables) {
|
|
|
12190
12237
|
const tableRowList = [];
|
|
12191
12238
|
const tableCellList = [];
|
|
12192
12239
|
const currentBlocks = [];
|
|
12240
|
+
const getParagraphList = () => tableCellList.length > 0 ? cellParagraphList : paragraphList;
|
|
12241
|
+
const appendToPreviousParagraph = (char) => {
|
|
12242
|
+
const tempParagraphList = getParagraphList();
|
|
12243
|
+
const lastParagraph = tempParagraphList[tempParagraphList.length - 1];
|
|
12244
|
+
if (lastParagraph) {
|
|
12245
|
+
var _lastParagraph$conten;
|
|
12246
|
+
lastParagraph.content = `${(_lastParagraph$conten = lastParagraph.content) !== null && _lastParagraph$conten !== void 0 ? _lastParagraph$conten : ""}${char}`;
|
|
12247
|
+
return true;
|
|
12248
|
+
}
|
|
12249
|
+
return false;
|
|
12250
|
+
};
|
|
12193
12251
|
for (let i = 0; i < dataStreamLen; i++) {
|
|
12194
12252
|
const char = dataStream[i];
|
|
12195
12253
|
if (char === DataStreamTreeTokenType.PARAGRAPH) {
|
|
@@ -12250,6 +12308,9 @@ function parseDataStreamToTree(dataStream, tables) {
|
|
|
12250
12308
|
const cellNode = tableCellList.pop();
|
|
12251
12309
|
const lastRow = tableRowList[tableRowList.length - 1];
|
|
12252
12310
|
batchParent(lastRow, [cellNode], DataStreamTreeNodeType.TABLE_ROW);
|
|
12311
|
+
} else if (char === DataStreamTreeTokenType.BLOCK_START) content += char;
|
|
12312
|
+
else if (char === DataStreamTreeTokenType.BLOCK_END) {
|
|
12313
|
+
if (content.length > 0 || !appendToPreviousParagraph(char)) content += char;
|
|
12253
12314
|
} else if (char === DataStreamTreeTokenType.CUSTOM_BLOCK) {
|
|
12254
12315
|
currentBlocks.push(i);
|
|
12255
12316
|
content += char;
|
|
@@ -12566,6 +12627,8 @@ function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, gly
|
|
|
12566
12627
|
DataStreamTreeTokenType.TABLE_ROW_END,
|
|
12567
12628
|
DataStreamTreeTokenType.TABLE_CELL_START,
|
|
12568
12629
|
DataStreamTreeTokenType.TABLE_CELL_END,
|
|
12630
|
+
DataStreamTreeTokenType.BLOCK_START,
|
|
12631
|
+
DataStreamTreeTokenType.BLOCK_END,
|
|
12569
12632
|
DataStreamTreeTokenType.CUSTOM_RANGE_START,
|
|
12570
12633
|
DataStreamTreeTokenType.CUSTOM_RANGE_END,
|
|
12571
12634
|
DataStreamTreeTokenType.COLUMN_BREAK,
|
|
@@ -13075,7 +13138,16 @@ function createTableSkeleton(ctx, curPage, viewModel, tableNode, sectionBreakCon
|
|
|
13075
13138
|
let left = 0;
|
|
13076
13139
|
let rowHeight = 0;
|
|
13077
13140
|
for (const cellNode of cellNodes) {
|
|
13078
|
-
const
|
|
13141
|
+
const col = cellNodes.indexOf(cellNode);
|
|
13142
|
+
const cellConfig = rowSource.tableCells[col];
|
|
13143
|
+
if (isCoveredTableCell(cellConfig)) {
|
|
13144
|
+
const cellPageSkeleton = createMergedCoveredCellPage(ctx, sectionBreakConfig, table, row, col, rowSkeleton);
|
|
13145
|
+
cellPageSkeleton.left = left;
|
|
13146
|
+
if (shouldAdvanceTableCellLeft(table, row, col)) left += cellPageSkeleton.pageWidth;
|
|
13147
|
+
rowSkeleton.cells.push(cellPageSkeleton);
|
|
13148
|
+
continue;
|
|
13149
|
+
}
|
|
13150
|
+
const cellPageSkeleton = createSkeletonCellPages(ctx, viewModel, cellNode, sectionBreakConfig, table, row, col)[0];
|
|
13079
13151
|
const { marginTop = 0, marginBottom = 0 } = cellPageSkeleton;
|
|
13080
13152
|
const pageHeight = cellPageSkeleton.height + marginTop + marginBottom;
|
|
13081
13153
|
cellPageSkeleton.left = left;
|
|
@@ -13085,7 +13157,7 @@ function createTableSkeleton(ctx, curPage, viewModel, tableNode, sectionBreakCon
|
|
|
13085
13157
|
rowHeight = Math.max(rowHeight, pageHeight);
|
|
13086
13158
|
}
|
|
13087
13159
|
if (hRule === TableRowHeightRule.AT_LEAST) rowHeight = Math.max(rowHeight, val.v);
|
|
13088
|
-
else if (hRule === TableRowHeightRule.EXACT) rowHeight = val.v;
|
|
13160
|
+
else if (hRule === TableRowHeightRule.EXACT) rowHeight = Math.max(rowHeight, val.v);
|
|
13089
13161
|
for (const cellPageSkeleton of rowSkeleton.cells) cellPageSkeleton.pageHeight = rowHeight;
|
|
13090
13162
|
const rowConfig = table.tableRows[row];
|
|
13091
13163
|
for (let i = 0; i < rowConfig.tableCells.length; i++) {
|
|
@@ -13116,6 +13188,7 @@ function createTableSkeleton(ctx, curPage, viewModel, tableNode, sectionBreakCon
|
|
|
13116
13188
|
}
|
|
13117
13189
|
tableSkeleton.width = tableWidth;
|
|
13118
13190
|
tableSkeleton.height = rowTop;
|
|
13191
|
+
applyMergedCellSpanHeights(tableSkeleton);
|
|
13119
13192
|
const { pageWidth, marginLeft = 0, marginRight = 0 } = curPage;
|
|
13120
13193
|
tableSkeleton.left = _getTableLeft(pageWidth - marginLeft - marginRight, tableWidth, table.align, table.indent);
|
|
13121
13194
|
return tableSkeleton;
|
|
@@ -13139,14 +13212,14 @@ function createTableSkeletons(ctx, curPage, viewModel, tableNode, sectionBreakCo
|
|
|
13139
13212
|
fromCurrentPage: false
|
|
13140
13213
|
};
|
|
13141
13214
|
}
|
|
13142
|
-
const
|
|
13215
|
+
const repeatRows = getLeadingRepeatHeaderRows(table, rowNodes);
|
|
13143
13216
|
const curTableSkeleton = getNullTableSkeleton(startIndex, endIndex, table);
|
|
13144
13217
|
const createCache = {
|
|
13145
13218
|
rowTop: 0,
|
|
13146
13219
|
tableWidth: 0,
|
|
13147
13220
|
remainHeight: availableHeight,
|
|
13148
|
-
|
|
13149
|
-
|
|
13221
|
+
repeatRows,
|
|
13222
|
+
repeatRowsHeight: 0
|
|
13150
13223
|
};
|
|
13151
13224
|
skeTables.push(curTableSkeleton);
|
|
13152
13225
|
for (const rowNode of rowNodes) dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig, rowNode, rowNodes.indexOf(rowNode), table, createCache);
|
|
@@ -13162,6 +13235,7 @@ function updateTableSkeletonsPosition(cache, curPage, skeTables, table) {
|
|
|
13162
13235
|
const tableLeft = _getTableLeft(pageWidth - marginLeft - marginRight, tableWidth, table.align, table.indent);
|
|
13163
13236
|
let tableIndex = 0;
|
|
13164
13237
|
for (const tableSkeleton of skeTables) {
|
|
13238
|
+
applyMergedCellSpanHeights(tableSkeleton);
|
|
13165
13239
|
tableSkeleton.width = tableWidth;
|
|
13166
13240
|
tableSkeleton.left = tableLeft;
|
|
13167
13241
|
tableSkeleton.st = tableSkeleton.rows[0].st - 1;
|
|
@@ -13178,7 +13252,7 @@ function getCurTableSkeleton(skeTables) {
|
|
|
13178
13252
|
function getAvailableHeight(curPage, cache, hasRepeatHeader) {
|
|
13179
13253
|
const { marginTop, marginBottom, pageHeight } = curPage;
|
|
13180
13254
|
let pageContentHeight = pageHeight - marginTop - marginBottom;
|
|
13181
|
-
if (hasRepeatHeader) pageContentHeight -= cache.
|
|
13255
|
+
if (hasRepeatHeader) pageContentHeight -= cache.repeatRowsHeight;
|
|
13182
13256
|
return pageContentHeight;
|
|
13183
13257
|
}
|
|
13184
13258
|
function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig, rowNode, row, table, cache, isRepeatRow = false) {
|
|
@@ -13196,17 +13270,13 @@ function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig
|
|
|
13196
13270
|
const rowHeights = [0];
|
|
13197
13271
|
for (const cellNode of cellNodes) {
|
|
13198
13272
|
const col = cellNodes.indexOf(cellNode);
|
|
13199
|
-
const
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
rowSkeleton.cells = [...new Array(colCount)].map((_, i) => {
|
|
13204
|
-
const cellSkeleton = createNullCellPage(ctx, sectionBreakConfig, table, row, i).page;
|
|
13205
|
-
cellSkeleton.parent = rowSkeleton;
|
|
13206
|
-
return cellSkeleton;
|
|
13207
|
-
});
|
|
13208
|
-
rowSkeletons.push(rowSkeleton);
|
|
13273
|
+
const cellConfig = rowSource.tableCells[col];
|
|
13274
|
+
if (isCoveredTableCell(cellConfig)) {
|
|
13275
|
+
if (rowSkeletons.length === 0) rowSkeletons.push(createNullRowSkeletonWithCells(ctx, sectionBreakConfig, table, row, startIndex, endIndex, rowSource, isRepeatRow));
|
|
13276
|
+
continue;
|
|
13209
13277
|
}
|
|
13278
|
+
const cellPageSkeletons = createSkeletonCellPages(ctx, viewModel, cellNode, sectionBreakConfig, table, row, col, canRowSplit && !needOpenNewTable ? cache.remainHeight : availableHeight, pageContentHeight);
|
|
13279
|
+
while (rowSkeletons.length < cellPageSkeletons.length) rowSkeletons.push(createNullRowSkeletonWithCells(ctx, sectionBreakConfig, table, row, startIndex, endIndex, rowSource, isRepeatRow));
|
|
13210
13280
|
while (rowHeights.length < cellPageSkeletons.length) rowHeights.push(0);
|
|
13211
13281
|
for (const cellPageSkeleton of cellPageSkeletons) {
|
|
13212
13282
|
const { marginTop: cellMarginTop = 0, marginBottom: cellMarginBottom = 0 } = cellPageSkeleton;
|
|
@@ -13221,18 +13291,20 @@ function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig
|
|
|
13221
13291
|
for (const rowSke of rowSkeletons) {
|
|
13222
13292
|
const rowIndex = rowSkeletons.indexOf(rowSke);
|
|
13223
13293
|
if (hRule === TableRowHeightRule.AT_LEAST) rowHeights[rowIndex] = Math.max(rowHeights[rowIndex], val.v);
|
|
13224
|
-
else if (hRule === TableRowHeightRule.EXACT) rowHeights[rowIndex] = val.v;
|
|
13294
|
+
else if (hRule === TableRowHeightRule.EXACT) rowHeights[rowIndex] = Math.max(rowHeights[rowIndex], val.v);
|
|
13225
13295
|
rowHeights[rowIndex] = Math.min(rowHeights[rowIndex], pageContentHeight);
|
|
13226
13296
|
let left = 0;
|
|
13227
|
-
for (
|
|
13297
|
+
for (let col = 0; col < rowSke.cells.length; col++) {
|
|
13298
|
+
const cellPageSkeleton = rowSke.cells[col];
|
|
13299
|
+
if (cellPageSkeleton == null) continue;
|
|
13228
13300
|
cellPageSkeleton.left = left;
|
|
13229
13301
|
cellPageSkeleton.pageHeight = rowHeights[rowIndex];
|
|
13230
|
-
left += cellPageSkeleton.pageWidth;
|
|
13302
|
+
if (shouldAdvanceTableCellLeft(table, rowSke.index, col)) left += cellPageSkeleton.pageWidth;
|
|
13231
13303
|
cache.tableWidth = Math.max(cache.tableWidth, left);
|
|
13232
13304
|
}
|
|
13233
13305
|
rowSke.height = rowHeights[rowIndex];
|
|
13234
13306
|
}
|
|
13235
|
-
if (
|
|
13307
|
+
if (!isRepeatRow && row < cache.repeatRows.length) cache.repeatRowsHeight += rowHeights.reduce((total, height) => total + height, 0);
|
|
13236
13308
|
for (const rowSkeleton of rowSkeletons) _verticalAlignInCell(rowSkeleton, rowSource);
|
|
13237
13309
|
while (rowSkeletons.length > 0) {
|
|
13238
13310
|
const rowSkeleton = rowSkeletons.shift();
|
|
@@ -13243,10 +13315,11 @@ function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig
|
|
|
13243
13315
|
if (curTableSkeleton.rows.length > 0) {
|
|
13244
13316
|
curTableSkeleton = getNullTableSkeleton(startIndex, endIndex, table);
|
|
13245
13317
|
skeTables.push(curTableSkeleton);
|
|
13246
|
-
if (cache.
|
|
13247
|
-
const FIRST_ROW_INDEX = 0;
|
|
13318
|
+
if (cache.repeatRows.length > 0 && isRepeatRow === false && row >= cache.repeatRows.length && rowSkeleton.index !== lastRow.index) {
|
|
13248
13319
|
cache.remainHeight = getAvailableHeight(curPage, cache, false);
|
|
13249
|
-
|
|
13320
|
+
cache.repeatRows.forEach((repeatRow, repeatRowIndex) => {
|
|
13321
|
+
dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig, repeatRow, repeatRowIndex, table, cache, true);
|
|
13322
|
+
});
|
|
13250
13323
|
}
|
|
13251
13324
|
}
|
|
13252
13325
|
}
|
|
@@ -13259,6 +13332,15 @@ function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig
|
|
|
13259
13332
|
cache.rowTop += rowSkeleton.height;
|
|
13260
13333
|
}
|
|
13261
13334
|
}
|
|
13335
|
+
function getLeadingRepeatHeaderRows(table, rowNodes) {
|
|
13336
|
+
const repeatRows = [];
|
|
13337
|
+
for (let index = 0; index < rowNodes.length; index++) {
|
|
13338
|
+
var _table$tableRows$inde;
|
|
13339
|
+
if (((_table$tableRows$inde = table.tableRows[index]) === null || _table$tableRows$inde === void 0 ? void 0 : _table$tableRows$inde.repeatHeaderRow) !== BooleanNumber.TRUE) break;
|
|
13340
|
+
repeatRows.push(rowNodes[index]);
|
|
13341
|
+
}
|
|
13342
|
+
return repeatRows;
|
|
13343
|
+
}
|
|
13262
13344
|
function _verticalAlignInCell(rowSkeleton, rowSource) {
|
|
13263
13345
|
for (let i = 0; i < rowSource.tableCells.length; i++) {
|
|
13264
13346
|
const cellConfig = rowSource.tableCells[i];
|
|
@@ -13283,6 +13365,75 @@ function _verticalAlignInCell(rowSkeleton, rowSource) {
|
|
|
13283
13365
|
cellPageSkeleton.marginTop = marginTop;
|
|
13284
13366
|
}
|
|
13285
13367
|
}
|
|
13368
|
+
function createNullRowSkeletonWithCells(ctx, sectionBreakConfig, table, row, startIndex, endIndex, rowSource, isRepeatRow = false) {
|
|
13369
|
+
const rowSkeleton = _getNullTableRowSkeleton(startIndex, endIndex, row, rowSource, isRepeatRow);
|
|
13370
|
+
const colCount = rowSource.tableCells.length;
|
|
13371
|
+
rowSkeleton.cells = Array.from({ length: colCount }, (_, col) => createMergedAwareNullCellPage(ctx, sectionBreakConfig, table, row, col, rowSkeleton));
|
|
13372
|
+
return rowSkeleton;
|
|
13373
|
+
}
|
|
13374
|
+
function createMergedCoveredCellPage(ctx, sectionBreakConfig, table, row, col, rowSkeleton) {
|
|
13375
|
+
return createMergedAwareNullCellPage(ctx, sectionBreakConfig, table, row, col, rowSkeleton);
|
|
13376
|
+
}
|
|
13377
|
+
function applyMergedCellSpanHeights(tableSkeleton) {
|
|
13378
|
+
var _tableSkeleton$tableS, _tableSkeleton$tableS2;
|
|
13379
|
+
const tableRows = (_tableSkeleton$tableS = (_tableSkeleton$tableS2 = tableSkeleton.tableSource) === null || _tableSkeleton$tableS2 === void 0 ? void 0 : _tableSkeleton$tableS2.tableRows) !== null && _tableSkeleton$tableS !== void 0 ? _tableSkeleton$tableS : [];
|
|
13380
|
+
if (tableRows.length === 0) return;
|
|
13381
|
+
const skeletonRowsByIndex = new Map(tableSkeleton.rows.map((row) => [row.index, row]));
|
|
13382
|
+
tableRows.forEach((rowSource, rowIndex) => {
|
|
13383
|
+
rowSource.tableCells.forEach((cellConfig, columnIndex) => {
|
|
13384
|
+
var _cellConfig$rowSpan, _cellConfig$columnSpa;
|
|
13385
|
+
const rowSpan = (_cellConfig$rowSpan = cellConfig.rowSpan) !== null && _cellConfig$rowSpan !== void 0 ? _cellConfig$rowSpan : 1;
|
|
13386
|
+
const columnSpan = (_cellConfig$columnSpa = cellConfig.columnSpan) !== null && _cellConfig$columnSpa !== void 0 ? _cellConfig$columnSpa : 1;
|
|
13387
|
+
if (rowSpan <= 1 && columnSpan <= 1) return;
|
|
13388
|
+
const masterRow = skeletonRowsByIndex.get(rowIndex);
|
|
13389
|
+
const masterCell = masterRow === null || masterRow === void 0 ? void 0 : masterRow.cells[columnIndex];
|
|
13390
|
+
if (!masterCell || masterCell.isMergedCellCovered) return;
|
|
13391
|
+
let pageHeight = 0;
|
|
13392
|
+
for (let row = rowIndex; row < rowIndex + rowSpan; row++) {
|
|
13393
|
+
var _skeletonRowsByIndex$, _skeletonRowsByIndex$2;
|
|
13394
|
+
pageHeight += (_skeletonRowsByIndex$ = (_skeletonRowsByIndex$2 = skeletonRowsByIndex.get(row)) === null || _skeletonRowsByIndex$2 === void 0 ? void 0 : _skeletonRowsByIndex$2.height) !== null && _skeletonRowsByIndex$ !== void 0 ? _skeletonRowsByIndex$ : 0;
|
|
13395
|
+
}
|
|
13396
|
+
if (pageHeight > 0) masterCell.pageHeight = pageHeight;
|
|
13397
|
+
});
|
|
13398
|
+
});
|
|
13399
|
+
}
|
|
13400
|
+
function createMergedAwareNullCellPage(ctx, sectionBreakConfig, table, row, col, rowSkeleton) {
|
|
13401
|
+
const cellSkeleton = createNullCellPage(ctx, sectionBreakConfig, table, row, col).page;
|
|
13402
|
+
cellSkeleton.parent = rowSkeleton;
|
|
13403
|
+
if (isCoveredTableCell(table.tableRows[row].tableCells[col])) Object.assign(cellSkeleton, { isMergedCellCovered: true });
|
|
13404
|
+
return cellSkeleton;
|
|
13405
|
+
}
|
|
13406
|
+
function shouldAdvanceTableCellLeft(table, row, col) {
|
|
13407
|
+
var _table$tableRows$row;
|
|
13408
|
+
if (!isCoveredTableCell((_table$tableRows$row = table.tableRows[row]) === null || _table$tableRows$row === void 0 ? void 0 : _table$tableRows$row.tableCells[col])) return true;
|
|
13409
|
+
const masterCell = findMergedMasterCell(table, row, col);
|
|
13410
|
+
if (masterCell == null) return true;
|
|
13411
|
+
return masterCell.row !== row;
|
|
13412
|
+
}
|
|
13413
|
+
function findMergedMasterCell(table, row, col) {
|
|
13414
|
+
for (let rowIndex = 0; rowIndex <= row; rowIndex++) {
|
|
13415
|
+
const rowSource = table.tableRows[rowIndex];
|
|
13416
|
+
if (rowSource == null) continue;
|
|
13417
|
+
for (let columnIndex = 0; columnIndex < rowSource.tableCells.length; columnIndex++) {
|
|
13418
|
+
var _cellConfig$rowSpan2, _cellConfig$columnSpa2;
|
|
13419
|
+
const cellConfig = rowSource.tableCells[columnIndex];
|
|
13420
|
+
if (isCoveredTableCell(cellConfig)) continue;
|
|
13421
|
+
const rowSpan = Math.max(1, (_cellConfig$rowSpan2 = cellConfig.rowSpan) !== null && _cellConfig$rowSpan2 !== void 0 ? _cellConfig$rowSpan2 : 1);
|
|
13422
|
+
const columnSpan = Math.max(1, (_cellConfig$columnSpa2 = cellConfig.columnSpan) !== null && _cellConfig$columnSpa2 !== void 0 ? _cellConfig$columnSpa2 : 1);
|
|
13423
|
+
if (rowSpan <= 1 && columnSpan <= 1) continue;
|
|
13424
|
+
const containsRow = row >= rowIndex && row < rowIndex + rowSpan;
|
|
13425
|
+
const containsColumn = col >= columnIndex && col < columnIndex + columnSpan;
|
|
13426
|
+
if (containsRow && containsColumn) return {
|
|
13427
|
+
row: rowIndex,
|
|
13428
|
+
col: columnIndex
|
|
13429
|
+
};
|
|
13430
|
+
}
|
|
13431
|
+
}
|
|
13432
|
+
return null;
|
|
13433
|
+
}
|
|
13434
|
+
function isCoveredTableCell(cellConfig) {
|
|
13435
|
+
return (cellConfig === null || cellConfig === void 0 ? void 0 : cellConfig.rowSpan) === 0 || (cellConfig === null || cellConfig === void 0 ? void 0 : cellConfig.columnSpan) === 0;
|
|
13436
|
+
}
|
|
13286
13437
|
function _getTableLeft(pageWidth, tableWidth, align, indent = { v: 0 }) {
|
|
13287
13438
|
switch (align) {
|
|
13288
13439
|
case TableAlignmentType.START: return indent.v;
|
|
@@ -14388,13 +14539,13 @@ const DEFAULT_PAGE_SIZE = {
|
|
|
14388
14539
|
const DEFAULT_MODERN_DOCUMENT_STYLE = {
|
|
14389
14540
|
pageNumberStart: 1,
|
|
14390
14541
|
pageSize: {
|
|
14391
|
-
width:
|
|
14542
|
+
width: MODERN_DOCUMENT_WIDTH[ModernDocumentWidthMode.MEDIUM],
|
|
14392
14543
|
height: Number.POSITIVE_INFINITY
|
|
14393
14544
|
},
|
|
14394
|
-
marginTop:
|
|
14395
|
-
marginBottom:
|
|
14396
|
-
marginRight:
|
|
14397
|
-
marginLeft:
|
|
14545
|
+
marginTop: MODERN_DOCUMENT_DEFAULT_MARGIN,
|
|
14546
|
+
marginBottom: MODERN_DOCUMENT_DEFAULT_MARGIN,
|
|
14547
|
+
marginRight: MODERN_DOCUMENT_DEFAULT_MARGIN,
|
|
14548
|
+
marginLeft: MODERN_DOCUMENT_DEFAULT_MARGIN,
|
|
14398
14549
|
renderConfig: {
|
|
14399
14550
|
vertexAngle: 0,
|
|
14400
14551
|
centerAngle: 0,
|
|
@@ -14424,8 +14575,13 @@ function prepareSectionBreakConfig(ctx, nodeIndex) {
|
|
|
14424
14575
|
const { documentFlavor } = documentStyle;
|
|
14425
14576
|
let sectionBreak = viewModel.getSectionBreak(sectionNode.endIndex) || DEFAULT_SECTION_BREAK;
|
|
14426
14577
|
if (documentFlavor === DocumentFlavor.MODERN) {
|
|
14578
|
+
var _documentStyle$pageSi, _documentStyle$pageSi2;
|
|
14579
|
+
const modernPageWidth = (_documentStyle$pageSi = (_documentStyle$pageSi2 = documentStyle.pageSize) === null || _documentStyle$pageSi2 === void 0 ? void 0 : _documentStyle$pageSi2.width) !== null && _documentStyle$pageSi !== void 0 ? _documentStyle$pageSi : DEFAULT_MODERN_DOCUMENT_STYLE.pageSize.width;
|
|
14427
14580
|
sectionBreak = Object.assign({}, sectionBreak, DEFAULT_MODERN_SECTION_BREAK);
|
|
14428
|
-
documentStyle = Object.assign({}, documentStyle, DEFAULT_MODERN_DOCUMENT_STYLE
|
|
14581
|
+
documentStyle = Object.assign({}, documentStyle, DEFAULT_MODERN_DOCUMENT_STYLE, { pageSize: {
|
|
14582
|
+
...DEFAULT_MODERN_DOCUMENT_STYLE.pageSize,
|
|
14583
|
+
width: modernPageWidth
|
|
14584
|
+
} });
|
|
14429
14585
|
}
|
|
14430
14586
|
const { pageNumberStart: global_pageNumberStart = 1, pageSize: global_pageSize = DEFAULT_PAGE_SIZE, pageOrient: global_pageOrient = PageOrientType.PORTRAIT, defaultHeaderId: global_defaultHeaderId, defaultFooterId: global_defaultFooterId, evenPageHeaderId: global_evenPageHeaderId, evenPageFooterId: global_evenPageFooterId, firstPageHeaderId: global_firstPageHeaderId, firstPageFooterId: global_firstPageFooterId, useFirstPageHeaderFooter: global_useFirstPageHeaderFooter, evenAndOddHeaders: global_evenAndOddHeaders, marginTop: global_marginTop = 0, marginBottom: global_marginBottom = 0, marginRight: global_marginRight = 0, marginLeft: global_marginLeft = 0, marginHeader: global_marginHeader = 0, marginFooter: global_marginFooter = 0, autoHyphenation = BooleanNumber.FALSE, doNotHyphenateCaps = BooleanNumber.FALSE, consecutiveHyphenLimit = Number.POSITIVE_INFINITY, hyphenationZone, renderConfig: global_renderConfig = {
|
|
14431
14587
|
horizontalAlign: HorizontalAlign.LEFT,
|
|
@@ -14662,12 +14818,14 @@ function _createSkeletonHeaderFooter(ctx, headerOrFooterViewModel, sectionBreakC
|
|
|
14662
14818
|
return page;
|
|
14663
14819
|
}
|
|
14664
14820
|
function createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY) {
|
|
14665
|
-
var _ref, _cellConfig$margin;
|
|
14821
|
+
var _ref, _cellConfig$margin, _cellConfig$columnSpa;
|
|
14666
14822
|
const { lists, footerTreeMap, headerTreeMap, localeService, drawings } = sectionBreakConfig;
|
|
14667
14823
|
const { skeletonResourceReference } = ctx;
|
|
14668
14824
|
const { cellMargin, tableRows, tableColumns, tableId } = tableConfig;
|
|
14669
|
-
const
|
|
14670
|
-
const
|
|
14825
|
+
const cellConfig = tableRows[row].tableCells[col];
|
|
14826
|
+
const { start = { v: 10 }, end = { v: 10 }, top = { v: 5 }, bottom = { v: 5 } } = (_ref = (_cellConfig$margin = cellConfig.margin) !== null && _cellConfig$margin !== void 0 ? _cellConfig$margin : cellMargin) !== null && _ref !== void 0 ? _ref : {};
|
|
14827
|
+
const columnSpan = Math.max(1, (_cellConfig$columnSpa = cellConfig.columnSpan) !== null && _cellConfig$columnSpa !== void 0 ? _cellConfig$columnSpa : 1);
|
|
14828
|
+
const pageWidth = tableColumns.slice(col, col + columnSpan).reduce((sum, column) => sum + column.size.width.v, 0);
|
|
14671
14829
|
const pageHeight = maxCellPageHeight;
|
|
14672
14830
|
const cellSectionBreakConfig = {
|
|
14673
14831
|
lists,
|
|
@@ -14696,6 +14854,7 @@ function createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, avai
|
|
|
14696
14854
|
};
|
|
14697
14855
|
}
|
|
14698
14856
|
function createSkeletonCellPages(ctx, viewModel, cellNode, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY) {
|
|
14857
|
+
var _ctx$dataModel, _ctx$dataModel$getBod;
|
|
14699
14858
|
const sectionNode = cellNode.children[0];
|
|
14700
14859
|
const { page: areaPage, sectionBreakConfig: cellSectionBreakConfig } = createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, availableHeight, maxCellPageHeight);
|
|
14701
14860
|
const { pages } = dealWithSection(ctx, viewModel, sectionNode, areaPage, cellSectionBreakConfig);
|
|
@@ -14704,9 +14863,36 @@ function createSkeletonCellPages(ctx, viewModel, cellNode, sectionBreakConfig, t
|
|
|
14704
14863
|
p.segmentId = tableConfig.tableId;
|
|
14705
14864
|
}
|
|
14706
14865
|
updateBlockIndex(pages, cellNode.startIndex);
|
|
14866
|
+
applyTrailingCellBlockRangeSpaceBelow(pages, (_ctx$dataModel = ctx.dataModel) === null || _ctx$dataModel === void 0 || (_ctx$dataModel$getBod = _ctx$dataModel.getBody) === null || _ctx$dataModel$getBod === void 0 ? void 0 : _ctx$dataModel$getBod.call(_ctx$dataModel), cellNode.endIndex);
|
|
14707
14867
|
updateInlineDrawingCoordsAndBorder(ctx, pages);
|
|
14868
|
+
expandCellPageHeightForInlineDrawings(pages);
|
|
14708
14869
|
return pages;
|
|
14709
14870
|
}
|
|
14871
|
+
function expandCellPageHeightForInlineDrawings(pages) {
|
|
14872
|
+
for (const page of pages) {
|
|
14873
|
+
var _page$skeDrawings;
|
|
14874
|
+
(_page$skeDrawings = page.skeDrawings) === null || _page$skeDrawings === void 0 || _page$skeDrawings.forEach((drawing) => {
|
|
14875
|
+
var _drawing$drawingOrigi, _drawing$aTop, _drawing$height;
|
|
14876
|
+
if (((_drawing$drawingOrigi = drawing.drawingOrigin) === null || _drawing$drawingOrigi === void 0 ? void 0 : _drawing$drawingOrigi.layoutType) !== PositionedObjectLayoutType.INLINE) return;
|
|
14877
|
+
const drawingBottom = ((_drawing$aTop = drawing.aTop) !== null && _drawing$aTop !== void 0 ? _drawing$aTop : 0) + ((_drawing$height = drawing.height) !== null && _drawing$height !== void 0 ? _drawing$height : 0);
|
|
14878
|
+
if (drawingBottom > page.height) page.height = drawingBottom;
|
|
14879
|
+
});
|
|
14880
|
+
}
|
|
14881
|
+
}
|
|
14882
|
+
function applyTrailingCellBlockRangeSpaceBelow(pages, body, cellEndIndex) {
|
|
14883
|
+
const blockRanges = body === null || body === void 0 ? void 0 : body.blockRanges;
|
|
14884
|
+
const trailingBlockRangeSpace = 28;
|
|
14885
|
+
if (!(blockRanges === null || blockRanges === void 0 ? void 0 : blockRanges.length)) return;
|
|
14886
|
+
for (const page of pages) {
|
|
14887
|
+
var _page$sections$at, _body$paragraphs;
|
|
14888
|
+
const lastLine = (_page$sections$at = page.sections.at(-1)) === null || _page$sections$at === void 0 || (_page$sections$at = _page$sections$at.columns.at(-1)) === null || _page$sections$at === void 0 ? void 0 : _page$sections$at.lines.at(-1);
|
|
14889
|
+
if (!lastLine) continue;
|
|
14890
|
+
const paragraphIndex = lastLine.paragraphIndex;
|
|
14891
|
+
if (!blockRanges.some((range) => range.startIndex < paragraphIndex && paragraphIndex < range.endIndex)) continue;
|
|
14892
|
+
if (body === null || body === void 0 || (_body$paragraphs = body.paragraphs) === null || _body$paragraphs === void 0 ? void 0 : _body$paragraphs.some((paragraph) => paragraph.startIndex > paragraphIndex && paragraph.startIndex < cellEndIndex)) continue;
|
|
14893
|
+
page.height += lastLine.spaceBelowApply || trailingBlockRangeSpace;
|
|
14894
|
+
}
|
|
14895
|
+
}
|
|
14710
14896
|
function _getVerticalMargin(marginTB, headerOrFooter, pageHeight) {
|
|
14711
14897
|
if (!headerOrFooter || headerOrFooter.sections[0].columns[0].lines.length === 0) return marginTB;
|
|
14712
14898
|
const HeaderFooterPageHeight = headerOrFooter.height + headerOrFooter.marginTop + headerOrFooter.marginBottom;
|
|
@@ -15113,6 +15299,11 @@ function ___getLevelAndSuffix(levelAndSuffixPre) {
|
|
|
15113
15299
|
|
|
15114
15300
|
//#endregion
|
|
15115
15301
|
//#region src/components/docs/layout/block/paragraph/linebreaking.ts
|
|
15302
|
+
const BLOCK_LAYOUT_OUTER_SPACING_MAP = new Map([
|
|
15303
|
+
["callout", 34],
|
|
15304
|
+
["code", 32],
|
|
15305
|
+
["quote", 24]
|
|
15306
|
+
]);
|
|
15116
15307
|
function _getListLevelAncestors(bullet, listLevel) {
|
|
15117
15308
|
if (!bullet || !listLevel) return;
|
|
15118
15309
|
const { listId, nestingLevel } = bullet;
|
|
@@ -15139,6 +15330,57 @@ function _updateListLevelAncestors(paragraph, bullet, bulletSkeleton, listLevel)
|
|
|
15139
15330
|
cacheItem.splice(nestingLevel + 1);
|
|
15140
15331
|
listLevel === null || listLevel === void 0 || listLevel.set(listId, cacheItem);
|
|
15141
15332
|
}
|
|
15333
|
+
function _withMinSpacing(style, key, value) {
|
|
15334
|
+
var _current$v;
|
|
15335
|
+
const current = style[key];
|
|
15336
|
+
const nextValue = Math.max((_current$v = current === null || current === void 0 ? void 0 : current.v) !== null && _current$v !== void 0 ? _current$v : 0, value);
|
|
15337
|
+
style[key] = {
|
|
15338
|
+
...current,
|
|
15339
|
+
v: nextValue
|
|
15340
|
+
};
|
|
15341
|
+
}
|
|
15342
|
+
function _getNextAdjacentBlockRange(blockRanges, blockRange) {
|
|
15343
|
+
return blockRanges === null || blockRanges === void 0 ? void 0 : blockRanges.filter((range) => range.startIndex > blockRange.endIndex).sort((left, right) => left.startIndex - right.startIndex)[0];
|
|
15344
|
+
}
|
|
15345
|
+
function _hasNextAdjacentLayoutBlockRange(blockRanges, blockRange) {
|
|
15346
|
+
const nextBlockRange = _getNextAdjacentBlockRange(blockRanges, blockRange);
|
|
15347
|
+
return nextBlockRange != null && BLOCK_LAYOUT_OUTER_SPACING_MAP.has(nextBlockRange.blockType) && nextBlockRange.startIndex === blockRange.endIndex + 1;
|
|
15348
|
+
}
|
|
15349
|
+
function _applyDefaultLayoutParagraphStyle(style, hasBlockRange) {
|
|
15350
|
+
if (style.lineSpacing == null) style.lineSpacing = DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING;
|
|
15351
|
+
if (hasBlockRange) return;
|
|
15352
|
+
if (style.spaceAbove == null) style.spaceAbove = { v: DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE };
|
|
15353
|
+
if (style.spaceBelow == null) style.spaceBelow = { v: DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW };
|
|
15354
|
+
}
|
|
15355
|
+
function _applyBlockRangeLayoutParagraphStyle(body, paragraph, paragraphStyle, shouldApplyDocumentDefaults) {
|
|
15356
|
+
var _body$paragraphs, _BLOCK_LAYOUT_OUTER_S;
|
|
15357
|
+
const style = Tools.deepClone(paragraphStyle);
|
|
15358
|
+
const blockRanges = body === null || body === void 0 ? void 0 : body.blockRanges;
|
|
15359
|
+
if (!(blockRanges === null || blockRanges === void 0 ? void 0 : blockRanges.length)) {
|
|
15360
|
+
if (shouldApplyDocumentDefaults) _applyDefaultLayoutParagraphStyle(style, false);
|
|
15361
|
+
return style;
|
|
15362
|
+
}
|
|
15363
|
+
const blockRange = blockRanges.find((range) => BLOCK_LAYOUT_OUTER_SPACING_MAP.has(range.blockType) && paragraph.startIndex > range.startIndex && paragraph.startIndex < range.endIndex);
|
|
15364
|
+
if (!blockRange) {
|
|
15365
|
+
if (shouldApplyDocumentDefaults) _applyDefaultLayoutParagraphStyle(style, false);
|
|
15366
|
+
return style;
|
|
15367
|
+
}
|
|
15368
|
+
_applyDefaultLayoutParagraphStyle(style, true);
|
|
15369
|
+
const blockParagraphs = ((_body$paragraphs = body === null || body === void 0 ? void 0 : body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).filter((item) => item.startIndex > blockRange.startIndex && item.startIndex < blockRange.endIndex).sort((left, right) => left.startIndex - right.startIndex);
|
|
15370
|
+
const firstParagraph = blockParagraphs[0];
|
|
15371
|
+
const lastParagraph = blockParagraphs[blockParagraphs.length - 1];
|
|
15372
|
+
const outerSpacing = (_BLOCK_LAYOUT_OUTER_S = BLOCK_LAYOUT_OUTER_SPACING_MAP.get(blockRange.blockType)) !== null && _BLOCK_LAYOUT_OUTER_S !== void 0 ? _BLOCK_LAYOUT_OUTER_S : 0;
|
|
15373
|
+
if ((firstParagraph === null || firstParagraph === void 0 ? void 0 : firstParagraph.startIndex) === paragraph.startIndex) _withMinSpacing(style, "spaceAbove", outerSpacing);
|
|
15374
|
+
if ((lastParagraph === null || lastParagraph === void 0 ? void 0 : lastParagraph.startIndex) === paragraph.startIndex && !_hasNextAdjacentLayoutBlockRange(blockRanges, blockRange)) _withMinSpacing(style, "spaceBelow", outerSpacing);
|
|
15375
|
+
return style;
|
|
15376
|
+
}
|
|
15377
|
+
function _shouldApplyDocumentDefaultParagraphStyle(viewModel) {
|
|
15378
|
+
var _viewModel$getSnapsho;
|
|
15379
|
+
const snapshot = (_viewModel$getSnapsho = viewModel.getSnapshot) === null || _viewModel$getSnapsho === void 0 ? void 0 : _viewModel$getSnapsho.call(viewModel);
|
|
15380
|
+
const documentFlavor = snapshot === null || snapshot === void 0 ? void 0 : snapshot.documentStyle.documentFlavor;
|
|
15381
|
+
if (snapshot == null) return true;
|
|
15382
|
+
return documentFlavor != null && documentFlavor !== DocumentFlavor.UNSPECIFIED;
|
|
15383
|
+
}
|
|
15142
15384
|
function _getDrawingSkeletonFormat(drawingOrigin) {
|
|
15143
15385
|
const { drawingId } = drawingOrigin;
|
|
15144
15386
|
return {
|
|
@@ -15161,6 +15403,7 @@ function _getNextPageNumber(lastPage) {
|
|
|
15161
15403
|
return lastPage.pageNumber + 1;
|
|
15162
15404
|
}
|
|
15163
15405
|
function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, sectionBreakConfig, tableSkeleton) {
|
|
15406
|
+
var _viewModel$getBody, _viewModel$getBody2;
|
|
15164
15407
|
const { skeletonResourceReference } = ctx;
|
|
15165
15408
|
const { lists, drawings = {}, localeService } = sectionBreakConfig;
|
|
15166
15409
|
const { endIndex, blocks = [], children } = paragraphNode;
|
|
@@ -15177,7 +15420,7 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
|
|
|
15177
15420
|
}
|
|
15178
15421
|
const paragraphConfig = {
|
|
15179
15422
|
paragraphIndex: endIndex,
|
|
15180
|
-
paragraphStyle:
|
|
15423
|
+
paragraphStyle: _applyBlockRangeLayoutParagraphStyle((_viewModel$getBody = (_viewModel$getBody2 = viewModel.getBody) === null || _viewModel$getBody2 === void 0 ? void 0 : _viewModel$getBody2.call(viewModel)) !== null && _viewModel$getBody !== void 0 ? _viewModel$getBody : null, paragraph, paragraphStyle, _shouldApplyDocumentDefaultParagraphStyle(viewModel)),
|
|
15181
15424
|
paragraphNonInlineSkeDrawings,
|
|
15182
15425
|
paragraphInlineSkeDrawings,
|
|
15183
15426
|
skeTablesInParagraph: tableSkeleton ? [{
|
|
@@ -15737,6 +15980,22 @@ function TibetanHandler(index, charArray, viewModel, paragraphNode, sectionBreak
|
|
|
15737
15980
|
glyphGroup: [createSkeletonWordGlyph(glyph.join(""), config)]
|
|
15738
15981
|
};
|
|
15739
15982
|
}
|
|
15983
|
+
function ThaiHandler(index, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
|
|
15984
|
+
const config = getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
15985
|
+
const glyph = [];
|
|
15986
|
+
let step = 0;
|
|
15987
|
+
for (let i = 0; i < charArray.length; i++) {
|
|
15988
|
+
const newChar = charArray[i];
|
|
15989
|
+
if (hasThai(newChar)) {
|
|
15990
|
+
glyph.push(newChar);
|
|
15991
|
+
step++;
|
|
15992
|
+
} else break;
|
|
15993
|
+
}
|
|
15994
|
+
return {
|
|
15995
|
+
step,
|
|
15996
|
+
glyphGroup: [createSkeletonWordGlyph(glyph.join(""), config)]
|
|
15997
|
+
};
|
|
15998
|
+
}
|
|
15740
15999
|
|
|
15741
16000
|
//#endregion
|
|
15742
16001
|
//#region src/components/docs/layout/block/paragraph/shaping.ts
|
|
@@ -15882,6 +16141,11 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
|
|
|
15882
16141
|
shapedGlyphs.push(...glyphGroup);
|
|
15883
16142
|
i += step;
|
|
15884
16143
|
src = src.substring(step);
|
|
16144
|
+
} else if (hasThai(char)) {
|
|
16145
|
+
const { step, glyphGroup } = ThaiHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
16146
|
+
shapedGlyphs.push(...glyphGroup);
|
|
16147
|
+
i += step;
|
|
16148
|
+
src = src.substring(step);
|
|
15885
16149
|
} else {
|
|
15886
16150
|
const { step, glyphGroup } = otherHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
15887
16151
|
shapedGlyphs.push(...glyphGroup);
|
|
@@ -16737,28 +17001,45 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
16737
17001
|
}
|
|
16738
17002
|
}
|
|
16739
17003
|
let exactMatch = null;
|
|
16740
|
-
if (skeTables.size > 0)
|
|
16741
|
-
var _this$
|
|
16742
|
-
const
|
|
16743
|
-
(
|
|
16744
|
-
|
|
16745
|
-
|
|
16746
|
-
|
|
16747
|
-
const
|
|
16748
|
-
|
|
16749
|
-
(_this$
|
|
16750
|
-
(
|
|
16751
|
-
|
|
16752
|
-
|
|
16753
|
-
const
|
|
17004
|
+
if (skeTables.size > 0) {
|
|
17005
|
+
var _this$_docViewModel$g, _this$_docViewModel$g2, _this$_docViewModel$g3;
|
|
17006
|
+
const unitId = (_this$_docViewModel$g = (_this$_docViewModel$g2 = (_this$_docViewModel$g3 = this._docViewModel.getDataModel()).getUnitId) === null || _this$_docViewModel$g2 === void 0 ? void 0 : _this$_docViewModel$g2.call(_this$_docViewModel$g3)) !== null && _this$_docViewModel$g !== void 0 ? _this$_docViewModel$g : "";
|
|
17007
|
+
for (const table of skeTables.values()) {
|
|
17008
|
+
var _this$_findLiquid, _this$_findLiquid2, _this$_findLiquid11;
|
|
17009
|
+
const { top: tableTop, left: tableLeft, rows } = table;
|
|
17010
|
+
const sourceTableId = getTableIdAndSliceIndex(table.tableId).tableId;
|
|
17011
|
+
const viewport = getDocsTableRenderViewport(unitId, sourceTableId);
|
|
17012
|
+
(_this$_findLiquid = this._findLiquid) === null || _this$_findLiquid === void 0 || _this$_findLiquid.translateSave();
|
|
17013
|
+
(_this$_findLiquid2 = this._findLiquid) === null || _this$_findLiquid2 === void 0 || _this$_findLiquid2.translate(tableLeft, tableTop);
|
|
17014
|
+
if (viewport && viewport.contentWidth > viewport.viewportWidth) {
|
|
17015
|
+
var _this$_findLiquid4;
|
|
17016
|
+
const visibleLeft = this._findLiquid.x;
|
|
17017
|
+
const visibleRight = visibleLeft + viewport.viewportWidth;
|
|
17018
|
+
if (x < visibleLeft || x > visibleRight) {
|
|
17019
|
+
var _this$_findLiquid3;
|
|
17020
|
+
(_this$_findLiquid3 = this._findLiquid) === null || _this$_findLiquid3 === void 0 || _this$_findLiquid3.translateRestore();
|
|
17021
|
+
continue;
|
|
17022
|
+
}
|
|
17023
|
+
(_this$_findLiquid4 = this._findLiquid) === null || _this$_findLiquid4 === void 0 || _this$_findLiquid4.translate(-viewport.scrollLeft, 0);
|
|
17024
|
+
}
|
|
17025
|
+
for (const row of rows) {
|
|
17026
|
+
var _this$_findLiquid5, _this$_findLiquid6, _this$_findLiquid10;
|
|
17027
|
+
const { top: rowTop, cells, isRepeatRow } = row;
|
|
17028
|
+
if (isRepeatRow) continue;
|
|
16754
17029
|
(_this$_findLiquid5 = this._findLiquid) === null || _this$_findLiquid5 === void 0 || _this$_findLiquid5.translateSave();
|
|
16755
|
-
(_this$_findLiquid6 = this._findLiquid) === null || _this$_findLiquid6 === void 0 || _this$_findLiquid6.translate(
|
|
16756
|
-
|
|
16757
|
-
|
|
17030
|
+
(_this$_findLiquid6 = this._findLiquid) === null || _this$_findLiquid6 === void 0 || _this$_findLiquid6.translate(0, rowTop);
|
|
17031
|
+
for (const cell of cells) {
|
|
17032
|
+
var _this$_findLiquid7, _this$_findLiquid8, _exactMatch3, _this$_findLiquid9;
|
|
17033
|
+
const { left: cellLeft } = cell;
|
|
17034
|
+
(_this$_findLiquid7 = this._findLiquid) === null || _this$_findLiquid7 === void 0 || _this$_findLiquid7.translateSave();
|
|
17035
|
+
(_this$_findLiquid8 = this._findLiquid) === null || _this$_findLiquid8 === void 0 || _this$_findLiquid8.translate(cellLeft, 0);
|
|
17036
|
+
exactMatch = (_exactMatch3 = exactMatch) !== null && _exactMatch3 !== void 0 ? _exactMatch3 : this._collectNearestNode(cell, 3, cell, segmentId, pi, cache, x, y, pageLength, nestLevel + 1);
|
|
17037
|
+
(_this$_findLiquid9 = this._findLiquid) === null || _this$_findLiquid9 === void 0 || _this$_findLiquid9.translateRestore();
|
|
17038
|
+
}
|
|
17039
|
+
(_this$_findLiquid10 = this._findLiquid) === null || _this$_findLiquid10 === void 0 || _this$_findLiquid10.translateRestore();
|
|
16758
17040
|
}
|
|
16759
|
-
(_this$
|
|
17041
|
+
(_this$_findLiquid11 = this._findLiquid) === null || _this$_findLiquid11 === void 0 || _this$_findLiquid11.translateRestore();
|
|
16760
17042
|
}
|
|
16761
|
-
(_this$_findLiquid9 = this._findLiquid) === null || _this$_findLiquid9 === void 0 || _this$_findLiquid9.translateRestore();
|
|
16762
17043
|
}
|
|
16763
17044
|
if (exactMatch) {
|
|
16764
17045
|
this._findLiquid.translateRestore();
|
|
@@ -17043,10 +17324,12 @@ function createDocumentModelWithStyle(content, textStyle, config = {}) {
|
|
|
17043
17324
|
width: Number.POSITIVE_INFINITY,
|
|
17044
17325
|
height: Number.POSITIVE_INFINITY
|
|
17045
17326
|
},
|
|
17327
|
+
documentFlavor: DocumentFlavor.UNSPECIFIED,
|
|
17046
17328
|
marginTop,
|
|
17047
17329
|
marginBottom,
|
|
17048
17330
|
marginRight,
|
|
17049
17331
|
marginLeft,
|
|
17332
|
+
paragraphLineGapDefault: 0,
|
|
17050
17333
|
renderConfig: {
|
|
17051
17334
|
horizontalAlign,
|
|
17052
17335
|
verticalAlign,
|
|
@@ -18945,8 +19228,9 @@ var SpreadsheetRowHeader = class extends SpreadsheetHeader {
|
|
|
18945
19228
|
const segment = spreadsheetSkeleton.rowColumnSegment;
|
|
18946
19229
|
if (!segment) return;
|
|
18947
19230
|
if (segment.startRow === -1 && segment.endRow === -1) return;
|
|
18948
|
-
const {
|
|
18949
|
-
|
|
19231
|
+
const { columnHeaderHeightAndMarginTop, rowHeaderWidth, rowHeaderWidthAndMarginLeft } = spreadsheetSkeleton;
|
|
19232
|
+
const marginLeft = rowHeaderWidthAndMarginLeft - rowHeaderWidth;
|
|
19233
|
+
ctx.translateWithPrecision(marginLeft, columnHeaderHeightAndMarginTop);
|
|
18950
19234
|
const extensions = this.getExtensionsByOrder();
|
|
18951
19235
|
for (const extension of extensions) extension.draw(ctx, parentScale, spreadsheetSkeleton);
|
|
18952
19236
|
}
|
|
@@ -18954,8 +19238,9 @@ var SpreadsheetRowHeader = class extends SpreadsheetHeader {
|
|
|
18954
19238
|
const oCoord = this.getInverseCoord(coord);
|
|
18955
19239
|
const skeleton = this.getSkeleton();
|
|
18956
19240
|
if (!skeleton) return false;
|
|
18957
|
-
const { rowHeaderWidth,
|
|
18958
|
-
|
|
19241
|
+
const { rowHeaderWidth, rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = skeleton;
|
|
19242
|
+
const marginLeft = rowHeaderWidthAndMarginLeft - rowHeaderWidth;
|
|
19243
|
+
if (oCoord.x >= marginLeft && oCoord.x <= rowHeaderWidthAndMarginLeft && oCoord.y > columnHeaderHeightAndMarginTop) return true;
|
|
18959
19244
|
return false;
|
|
18960
19245
|
}
|
|
18961
19246
|
_initialDefaultExtension() {
|
|
@@ -21510,7 +21795,8 @@ DocumentsSpanAndLineExtensionRegistry.add(new Line());
|
|
|
21510
21795
|
|
|
21511
21796
|
//#endregion
|
|
21512
21797
|
//#region src/components/docs/document.ts
|
|
21513
|
-
const DEFAULT_BORDER_COLOR = { color: { rgb: "#
|
|
21798
|
+
const DEFAULT_BORDER_COLOR = { color: { rgb: "#c7c9cc" } };
|
|
21799
|
+
const TABLE_VIEWPORT_BORDER_CLIP_PADDING = 2;
|
|
21514
21800
|
var Documents = class Documents extends DocComponent {
|
|
21515
21801
|
constructor(oKey, documentSkeleton, config) {
|
|
21516
21802
|
super(oKey, documentSkeleton, config);
|
|
@@ -21693,29 +21979,62 @@ var Documents = class Documents extends DocComponent {
|
|
|
21693
21979
|
}
|
|
21694
21980
|
}
|
|
21695
21981
|
_drawTable(ctx, page, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale) {
|
|
21696
|
-
|
|
21697
|
-
|
|
21982
|
+
const drawLiquid = this._drawLiquid;
|
|
21983
|
+
if (drawLiquid == null) return;
|
|
21984
|
+
const renderUnitId = this._getRenderUnitId();
|
|
21985
|
+
for (const [tableId, tableSkeleton] of skeTables) {
|
|
21698
21986
|
const { top: tableTop, left: tableLeft, rows } = tableSkeleton;
|
|
21699
|
-
|
|
21700
|
-
|
|
21987
|
+
const sourceTableId = getTableIdAndSliceIndex(tableId).tableId;
|
|
21988
|
+
const viewport = this._getTableViewport(page, tableSkeleton, renderUnitId, sourceTableId);
|
|
21989
|
+
drawLiquid.translateSave();
|
|
21990
|
+
drawLiquid.translate(tableLeft, tableTop);
|
|
21991
|
+
if (viewport && viewport.contentWidth > viewport.viewportWidth) {
|
|
21992
|
+
const { x, y } = drawLiquid;
|
|
21993
|
+
ctx.save();
|
|
21994
|
+
ctx.beginPath();
|
|
21995
|
+
ctx.rectByPrecision(x + page.marginLeft - TABLE_VIEWPORT_BORDER_CLIP_PADDING, y + page.marginTop - TABLE_VIEWPORT_BORDER_CLIP_PADDING, viewport.viewportWidth + TABLE_VIEWPORT_BORDER_CLIP_PADDING * 2, tableSkeleton.height + TABLE_VIEWPORT_BORDER_CLIP_PADDING * 2);
|
|
21996
|
+
ctx.closePath();
|
|
21997
|
+
ctx.clip();
|
|
21998
|
+
drawLiquid.translate(-viewport.scrollLeft, 0);
|
|
21999
|
+
}
|
|
21701
22000
|
for (const row of rows) {
|
|
21702
|
-
var _this$_drawLiquid3, _this$_drawLiquid4, _this$_drawLiquid8;
|
|
21703
22001
|
const { top: rowTop, cells } = row;
|
|
21704
|
-
|
|
21705
|
-
|
|
22002
|
+
drawLiquid.translateSave();
|
|
22003
|
+
drawLiquid.translate(0, rowTop);
|
|
21706
22004
|
for (const cell of cells) {
|
|
21707
|
-
|
|
22005
|
+
if (cell.isMergedCellCovered) continue;
|
|
21708
22006
|
const { left: cellLeft } = cell;
|
|
21709
|
-
|
|
21710
|
-
|
|
22007
|
+
drawLiquid.translateSave();
|
|
22008
|
+
drawLiquid.translate(cellLeft, 0);
|
|
21711
22009
|
this._drawTableCell(ctx, page, cell, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
|
|
21712
|
-
|
|
22010
|
+
drawLiquid.translateRestore();
|
|
21713
22011
|
}
|
|
21714
|
-
|
|
22012
|
+
drawLiquid.translateRestore();
|
|
21715
22013
|
}
|
|
21716
|
-
(
|
|
22014
|
+
if (viewport && viewport.contentWidth > viewport.viewportWidth) ctx.restore();
|
|
22015
|
+
drawLiquid.translateRestore();
|
|
21717
22016
|
}
|
|
21718
22017
|
}
|
|
22018
|
+
_getTableViewport(page, tableSkeleton, unitId, tableId) {
|
|
22019
|
+
const viewport = getDocsTableRenderViewport(unitId, tableId);
|
|
22020
|
+
if (viewport) return viewport;
|
|
22021
|
+
const { pageWidth, marginLeft = 0, marginRight = 0 } = page;
|
|
22022
|
+
if (!Number.isFinite(pageWidth)) return null;
|
|
22023
|
+
const viewportWidth = Math.max(0, pageWidth - marginLeft - marginRight - tableSkeleton.left);
|
|
22024
|
+
if (viewportWidth <= 0 || tableSkeleton.width <= viewportWidth) return null;
|
|
22025
|
+
return {
|
|
22026
|
+
contentWidth: tableSkeleton.width,
|
|
22027
|
+
scrollLeft: 0,
|
|
22028
|
+
viewportWidth
|
|
22029
|
+
};
|
|
22030
|
+
}
|
|
22031
|
+
_getRenderUnitId() {
|
|
22032
|
+
var _skeleton$getViewMode, _viewModel$getDataMod, _dataModel$getUnitId, _dataModel$getUnitId2;
|
|
22033
|
+
const skeleton = this.getSkeleton();
|
|
22034
|
+
const viewModel = skeleton === null || skeleton === void 0 || (_skeleton$getViewMode = skeleton.getViewModel) === null || _skeleton$getViewMode === void 0 ? void 0 : _skeleton$getViewMode.call(skeleton);
|
|
22035
|
+
const dataModel = viewModel === null || viewModel === void 0 || (_viewModel$getDataMod = viewModel.getDataModel) === null || _viewModel$getDataMod === void 0 ? void 0 : _viewModel$getDataMod.call(viewModel);
|
|
22036
|
+
return (_dataModel$getUnitId = dataModel === null || dataModel === void 0 || (_dataModel$getUnitId2 = dataModel.getUnitId) === null || _dataModel$getUnitId2 === void 0 ? void 0 : _dataModel$getUnitId2.call(dataModel)) !== null && _dataModel$getUnitId !== void 0 ? _dataModel$getUnitId : this.oKey;
|
|
22037
|
+
}
|
|
21719
22038
|
_drawBorderBottom(ctx, page, line, left = 0, top = 0) {
|
|
21720
22039
|
var _line$borderBottom$pa, _line$borderBottom, _line$borderBottom$co, _line$borderBottom2;
|
|
21721
22040
|
if (this._drawLiquid == null) return;
|
|
@@ -21825,60 +22144,68 @@ var Documents = class Documents extends DocComponent {
|
|
|
21825
22144
|
ctx.restore();
|
|
21826
22145
|
}
|
|
21827
22146
|
_drawTableCellBordersAndBg(ctx, page, cell) {
|
|
21828
|
-
var
|
|
22147
|
+
var _rowSke$index, _cellSource$backgroun;
|
|
21829
22148
|
const { marginLeft, marginTop } = page;
|
|
21830
22149
|
const { pageWidth, pageHeight } = cell;
|
|
21831
22150
|
const rowSke = cell.parent;
|
|
21832
22151
|
const index = rowSke.cells.indexOf(cell);
|
|
21833
|
-
|
|
22152
|
+
if (index < 0) return;
|
|
22153
|
+
const cellSource = rowSke.rowSource.tableCells[index];
|
|
22154
|
+
const tableSke = rowSke.parent;
|
|
22155
|
+
const rowIndexInTable = tableSke === null || tableSke === void 0 ? void 0 : tableSke.rows.indexOf(rowSke);
|
|
22156
|
+
const rowIndex = rowIndexInTable == null || rowIndexInTable < 0 ? (_rowSke$index = rowSke.index) !== null && _rowSke$index !== void 0 ? _rowSke$index : 0 : rowIndexInTable;
|
|
22157
|
+
if (!cellSource || cellSource.rowSpan === 0 || cellSource.columnSpan === 0) return;
|
|
21834
22158
|
if (this._drawLiquid == null) return;
|
|
21835
22159
|
let { x, y } = this._drawLiquid;
|
|
21836
22160
|
x += marginLeft;
|
|
21837
22161
|
y += marginTop;
|
|
21838
|
-
if (backgroundColor
|
|
22162
|
+
if ((_cellSource$backgroun = cellSource.backgroundColor) === null || _cellSource$backgroun === void 0 ? void 0 : _cellSource$backgroun.rgb) {
|
|
21839
22163
|
ctx.save();
|
|
21840
|
-
ctx.fillStyle = backgroundColor.rgb;
|
|
22164
|
+
ctx.fillStyle = cellSource.backgroundColor.rgb;
|
|
21841
22165
|
ctx.fillRectByPrecision(x, y, pageWidth, pageHeight);
|
|
21842
22166
|
ctx.restore();
|
|
21843
22167
|
}
|
|
21844
|
-
|
|
21845
|
-
ctx.setLineWidthByPrecision(1);
|
|
21846
|
-
ctx.save();
|
|
21847
|
-
ctx.strokeStyle = (_borderLeft$color$rgb = borderLeft.color.rgb) !== null && _borderLeft$color$rgb !== void 0 ? _borderLeft$color$rgb : DEFAULT_BORDER_COLOR.color.rgb;
|
|
21848
|
-
drawLineByBorderType(ctx, "l", 0, {
|
|
21849
|
-
startX: x,
|
|
21850
|
-
startY: y,
|
|
21851
|
-
endX: x + pageWidth,
|
|
21852
|
-
endY: y + pageHeight
|
|
21853
|
-
});
|
|
21854
|
-
ctx.restore();
|
|
21855
|
-
ctx.save();
|
|
21856
|
-
ctx.strokeStyle = (_borderTop$color$rgb = borderTop.color.rgb) !== null && _borderTop$color$rgb !== void 0 ? _borderTop$color$rgb : DEFAULT_BORDER_COLOR.color.rgb;
|
|
21857
|
-
drawLineByBorderType(ctx, "t", 0, {
|
|
21858
|
-
startX: x,
|
|
21859
|
-
startY: y,
|
|
21860
|
-
endX: x + pageWidth,
|
|
21861
|
-
endY: y + pageHeight
|
|
21862
|
-
});
|
|
21863
|
-
ctx.restore();
|
|
21864
|
-
ctx.save();
|
|
21865
|
-
ctx.strokeStyle = (_borderRight$color$rg = borderRight.color.rgb) !== null && _borderRight$color$rg !== void 0 ? _borderRight$color$rg : DEFAULT_BORDER_COLOR.color.rgb;
|
|
21866
|
-
drawLineByBorderType(ctx, "r", 0, {
|
|
22168
|
+
const position = {
|
|
21867
22169
|
startX: x,
|
|
21868
22170
|
startY: y,
|
|
21869
22171
|
endX: x + pageWidth,
|
|
21870
22172
|
endY: y + pageHeight
|
|
21871
|
-
}
|
|
21872
|
-
|
|
22173
|
+
};
|
|
22174
|
+
const rightCellSource = this._getTableCellSource(rowSke, index + 1);
|
|
22175
|
+
const bottomCellSource = tableSke ? this._getTableCellSource(tableSke.rows[rowIndex + 1], index) : void 0;
|
|
22176
|
+
this._drawTableCellBorder(ctx, this._resolveTableCellBorder(cellSource.borderRight, rightCellSource === null || rightCellSource === void 0 ? void 0 : rightCellSource.borderLeft), "r", position);
|
|
22177
|
+
this._drawTableCellBorder(ctx, this._resolveTableCellBorder(cellSource.borderBottom, bottomCellSource === null || bottomCellSource === void 0 ? void 0 : bottomCellSource.borderTop), "b", position);
|
|
22178
|
+
if (rowIndex <= 0) this._drawTableCellBorder(ctx, this._resolveTableCellBorder(cellSource.borderTop), "t", position);
|
|
22179
|
+
if (index <= 0) this._drawTableCellBorder(ctx, this._resolveTableCellBorder(cellSource.borderLeft), "l", position);
|
|
22180
|
+
}
|
|
22181
|
+
_getTableCellSource(row, column) {
|
|
22182
|
+
var _row$rowSource$tableC;
|
|
22183
|
+
return (_row$rowSource$tableC = row === null || row === void 0 ? void 0 : row.rowSource.tableCells[column]) !== null && _row$rowSource$tableC !== void 0 ? _row$rowSource$tableC : null;
|
|
22184
|
+
}
|
|
22185
|
+
_resolveTableCellBorder(primary, secondary) {
|
|
22186
|
+
if (this._isDrawableTableCellBorder(primary)) return primary;
|
|
22187
|
+
if (this._isDrawableTableCellBorder(secondary)) return secondary;
|
|
22188
|
+
if (primary || secondary) return null;
|
|
22189
|
+
return DEFAULT_BORDER_COLOR;
|
|
22190
|
+
}
|
|
22191
|
+
_isDrawableTableCellBorder(border) {
|
|
22192
|
+
var _border$width$v, _border$width, _border$color$rgb, _border$color;
|
|
22193
|
+
if (!border) return false;
|
|
22194
|
+
const lineWidth = (_border$width$v = (_border$width = border.width) === null || _border$width === void 0 ? void 0 : _border$width.v) !== null && _border$width$v !== void 0 ? _border$width$v : 1;
|
|
22195
|
+
const color = (_border$color$rgb = (_border$color = border.color) === null || _border$color === void 0 ? void 0 : _border$color.rgb) !== null && _border$color$rgb !== void 0 ? _border$color$rgb : DEFAULT_BORDER_COLOR.color.rgb;
|
|
22196
|
+
return lineWidth > 0 && color !== "transparent";
|
|
22197
|
+
}
|
|
22198
|
+
_drawTableCellBorder(ctx, border, type, position) {
|
|
22199
|
+
var _border$width$v2, _border$width2, _border$color$rgb2, _border$color2;
|
|
22200
|
+
if (!border) return;
|
|
22201
|
+
const lineWidth = (_border$width$v2 = (_border$width2 = border.width) === null || _border$width2 === void 0 ? void 0 : _border$width2.v) !== null && _border$width$v2 !== void 0 ? _border$width$v2 : 1;
|
|
22202
|
+
const color = (_border$color$rgb2 = (_border$color2 = border.color) === null || _border$color2 === void 0 ? void 0 : _border$color2.rgb) !== null && _border$color$rgb2 !== void 0 ? _border$color$rgb2 : DEFAULT_BORDER_COLOR.color.rgb;
|
|
22203
|
+
if (lineWidth <= 0 || color === "transparent") return;
|
|
21873
22204
|
ctx.save();
|
|
21874
|
-
ctx.
|
|
21875
|
-
|
|
21876
|
-
|
|
21877
|
-
|
|
21878
|
-
endX: x + pageWidth,
|
|
21879
|
-
endY: y + pageHeight
|
|
21880
|
-
});
|
|
21881
|
-
ctx.restore();
|
|
22205
|
+
ctx.setLineWidthByPrecision(lineWidth);
|
|
22206
|
+
setTableCellBorderDash(ctx, border.dashStyle);
|
|
22207
|
+
ctx.strokeStyle = color;
|
|
22208
|
+
drawLineByBorderType(ctx, type, 0, position);
|
|
21882
22209
|
ctx.restore();
|
|
21883
22210
|
}
|
|
21884
22211
|
_drawHeaderFooter(page, ctx, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale, parentPage, isHeader = true) {
|
|
@@ -22009,6 +22336,17 @@ var Documents = class Documents extends DocComponent {
|
|
|
22009
22336
|
});
|
|
22010
22337
|
}
|
|
22011
22338
|
};
|
|
22339
|
+
function setTableCellBorderDash(ctx, dashStyle) {
|
|
22340
|
+
if (dashStyle === DashStyleType.DOT) {
|
|
22341
|
+
ctx.setLineDash([2]);
|
|
22342
|
+
return;
|
|
22343
|
+
}
|
|
22344
|
+
if (dashStyle === DashStyleType.DASH) {
|
|
22345
|
+
ctx.setLineDash([6]);
|
|
22346
|
+
return;
|
|
22347
|
+
}
|
|
22348
|
+
ctx.setLineDash([0]);
|
|
22349
|
+
}
|
|
22012
22350
|
|
|
22013
22351
|
//#endregion
|
|
22014
22352
|
//#region src/components/sheets/spreadsheet.ts
|
|
@@ -22115,8 +22453,8 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
22115
22453
|
const oCoord = this.getInverseCoord(coord);
|
|
22116
22454
|
const skeleton = this.getSkeleton();
|
|
22117
22455
|
if (!skeleton) return false;
|
|
22118
|
-
const {
|
|
22119
|
-
if (oCoord.x >
|
|
22456
|
+
const { rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = skeleton;
|
|
22457
|
+
if (oCoord.x > rowHeaderWidthAndMarginLeft && oCoord.y > columnHeaderHeightAndMarginTop) return true;
|
|
22120
22458
|
return false;
|
|
22121
22459
|
}
|
|
22122
22460
|
getNoMergeCellPositionByIndex(rowIndex, columnIndex) {
|
|
@@ -22184,7 +22522,7 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
22184
22522
|
}
|
|
22185
22523
|
renderByViewports(mainCtx, viewportInfo, spreadsheetSkeleton) {
|
|
22186
22524
|
const { diffBounds, diffX, diffY, viewPortPosition, cacheCanvas, leftOrigin, topOrigin, bufferEdgeX, bufferEdgeY, isDirty: isViewportDirty, isForceDirty: isViewportForceDirty } = viewportInfo;
|
|
22187
|
-
const {
|
|
22525
|
+
const { rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = spreadsheetSkeleton;
|
|
22188
22526
|
const { a: scaleX = 1, d: scaleY = 1 } = mainCtx.getTransform();
|
|
22189
22527
|
const bufferEdgeSizeX = bufferEdgeX * scaleX / window.devicePixelRatio;
|
|
22190
22528
|
const bufferEdgeSizeY = bufferEdgeY * scaleY / window.devicePixelRatio;
|
|
@@ -22192,8 +22530,10 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
22192
22530
|
cacheCtx.save();
|
|
22193
22531
|
const isForceDirty = isViewportForceDirty || this.isForceDirty();
|
|
22194
22532
|
const isDirty = isViewportDirty || this.isDirty();
|
|
22195
|
-
|
|
22196
|
-
|
|
22533
|
+
const isScrollJumpOutsideCache = Math.abs(diffX) * scaleX >= cacheCanvas.getWidth() || Math.abs(diffY) * scaleY >= cacheCanvas.getHeight();
|
|
22534
|
+
const shouldRefreshCache = isDirty || isForceDirty || isScrollJumpOutsideCache;
|
|
22535
|
+
if (diffBounds.length === 0 || diffX === 0 && diffY === 0 || shouldRefreshCache) {
|
|
22536
|
+
if (shouldRefreshCache) {
|
|
22197
22537
|
this.addRenderTagToScene("scrolling", false);
|
|
22198
22538
|
this.refreshCacheCanvas(viewportInfo, {
|
|
22199
22539
|
cacheCanvas,
|
|
@@ -22217,20 +22557,20 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
22217
22557
|
bufferEdgeY,
|
|
22218
22558
|
scaleX,
|
|
22219
22559
|
scaleY,
|
|
22220
|
-
|
|
22221
|
-
|
|
22560
|
+
columnHeaderHeightAndMarginTop,
|
|
22561
|
+
rowHeaderWidthAndMarginLeft
|
|
22222
22562
|
});
|
|
22223
22563
|
}
|
|
22224
22564
|
const sourceLeft = bufferEdgeSizeX * Math.min(1, window.devicePixelRatio);
|
|
22225
22565
|
const sourceTop = bufferEdgeSizeY * Math.min(1, window.devicePixelRatio);
|
|
22226
22566
|
const { left, top, right, bottom } = viewPortPosition;
|
|
22227
|
-
const dw = right - left +
|
|
22228
|
-
const dh = bottom - top +
|
|
22567
|
+
const dw = right - left + rowHeaderWidthAndMarginLeft;
|
|
22568
|
+
const dh = bottom - top + columnHeaderHeightAndMarginTop;
|
|
22229
22569
|
this._applyCache(cacheCanvas, mainCtx, sourceLeft, sourceTop, dw, dh, left, top, dw, dh);
|
|
22230
22570
|
cacheCtx.restore();
|
|
22231
22571
|
}
|
|
22232
22572
|
paintNewAreaForScrolling(viewportInfo, param) {
|
|
22233
|
-
const { cacheCanvas, cacheCtx, mainCtx, topOrigin, leftOrigin, bufferEdgeX, bufferEdgeY, scaleX, scaleY,
|
|
22573
|
+
const { cacheCanvas, cacheCtx, mainCtx, topOrigin, leftOrigin, bufferEdgeX, bufferEdgeY, scaleX, scaleY, columnHeaderHeightAndMarginTop, rowHeaderWidthAndMarginLeft } = param;
|
|
22234
22574
|
const { shouldCacheUpdate, diffCacheBounds, diffX, diffY } = viewportInfo;
|
|
22235
22575
|
cacheCtx.save();
|
|
22236
22576
|
cacheCtx.setTransform(1, 0, 0, 1, 0, 0);
|
|
@@ -22243,8 +22583,8 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
22243
22583
|
cacheCtx.translateWithPrecision(m.e / m.a - leftOrigin + bufferEdgeX, m.f / m.d - topOrigin + bufferEdgeY);
|
|
22244
22584
|
if (shouldCacheUpdate) for (const diffBound of diffCacheBounds) {
|
|
22245
22585
|
const { left: diffLeft, right: diffRight, bottom: diffBottom, top: diffTop } = diffBound;
|
|
22246
|
-
const x = diffLeft -
|
|
22247
|
-
const y = diffTop -
|
|
22586
|
+
const x = diffLeft - rowHeaderWidthAndMarginLeft;
|
|
22587
|
+
const y = diffTop - columnHeaderHeightAndMarginTop;
|
|
22248
22588
|
const w = diffRight - diffLeft;
|
|
22249
22589
|
const h = diffBottom - diffTop;
|
|
22250
22590
|
cacheCtx.clearRectByPrecision(x, y, w, h);
|
|
@@ -22290,9 +22630,9 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
22290
22630
|
if (!segment) return;
|
|
22291
22631
|
if (segment.startRow === -1 && segment.endRow === -1 || segment.startColumn === -1 && segment.endColumn === -1) return;
|
|
22292
22632
|
mainCtx.save();
|
|
22293
|
-
const {
|
|
22294
|
-
mainCtx.translateWithPrecision(
|
|
22295
|
-
(_this$getScene = this.getScene()) === null || _this$getScene === void 0 || _this$getScene.updateTransformerZero(
|
|
22633
|
+
const { rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = spreadsheetSkeleton;
|
|
22634
|
+
mainCtx.translateWithPrecision(rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop);
|
|
22635
|
+
(_this$getScene = this.getScene()) === null || _this$getScene === void 0 || _this$getScene.updateTransformerZero(rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop);
|
|
22296
22636
|
const { viewportKey } = viewportInfo;
|
|
22297
22637
|
if (sheetContentViewportKeys.includes(viewportKey)) if (viewportInfo && viewportInfo.cacheCanvas) this.renderByViewports(mainCtx, viewportInfo, spreadsheetSkeleton);
|
|
22298
22638
|
else this._draw(mainCtx, viewportInfo);
|
|
@@ -23209,29 +23549,49 @@ var Slide = class extends SceneViewer {
|
|
|
23209
23549
|
//#region src/components/docs/doc-background.ts
|
|
23210
23550
|
const PAGE_STROKE_COLOR = "rgba(198, 198, 198, 1)";
|
|
23211
23551
|
const PAGE_FILL_COLOR = "rgba(255, 255, 255, 1)";
|
|
23552
|
+
const DOCS_WORKSPACE_FILL_COLOR = "#fafafa";
|
|
23212
23553
|
const MARGIN_STROKE_COLOR = "rgba(158, 158, 158, 1)";
|
|
23213
23554
|
var DocBackground = class DocBackground extends DocComponent {
|
|
23214
23555
|
constructor(oKey, documentSkeleton, config) {
|
|
23215
23556
|
super(oKey, documentSkeleton, config);
|
|
23216
23557
|
_defineProperty(this, "_drawLiquid", void 0);
|
|
23558
|
+
_defineProperty(this, "_backgroundFillColor", void 0);
|
|
23559
|
+
_defineProperty(this, "_pageFillColor", void 0);
|
|
23560
|
+
_defineProperty(this, "_pageStrokeColor", void 0);
|
|
23561
|
+
_defineProperty(this, "_marginStrokeColor", void 0);
|
|
23217
23562
|
this._drawLiquid = new Liquid();
|
|
23563
|
+
this._backgroundFillColor = config === null || config === void 0 ? void 0 : config.backgroundFillColor;
|
|
23564
|
+
this._pageFillColor = config === null || config === void 0 ? void 0 : config.pageFillColor;
|
|
23565
|
+
this._pageStrokeColor = config === null || config === void 0 ? void 0 : config.pageStrokeColor;
|
|
23566
|
+
this._marginStrokeColor = config === null || config === void 0 ? void 0 : config.marginStrokeColor;
|
|
23218
23567
|
this.makeDirty(true);
|
|
23219
23568
|
}
|
|
23220
23569
|
static create(oKey, documentSkeleton, config) {
|
|
23221
23570
|
return new DocBackground(oKey, documentSkeleton, config);
|
|
23222
23571
|
}
|
|
23572
|
+
setFillColors(backgroundFillColor, pageFillColor, pageStrokeColor, marginStrokeColor) {
|
|
23573
|
+
if (this._backgroundFillColor === backgroundFillColor && this._pageFillColor === pageFillColor && this._pageStrokeColor === pageStrokeColor && this._marginStrokeColor === marginStrokeColor) return;
|
|
23574
|
+
this._backgroundFillColor = backgroundFillColor;
|
|
23575
|
+
this._pageFillColor = pageFillColor;
|
|
23576
|
+
this._pageStrokeColor = pageStrokeColor;
|
|
23577
|
+
this._marginStrokeColor = marginStrokeColor;
|
|
23578
|
+
this.makeDirty(true);
|
|
23579
|
+
}
|
|
23223
23580
|
draw(ctx, bounds) {
|
|
23224
|
-
var _this$getSkeleton, _this$getSkeleton2;
|
|
23581
|
+
var _this$getSkeleton, _this$getSkeleton2, _this$_backgroundFill;
|
|
23225
23582
|
const skeletonData = (_this$getSkeleton = this.getSkeleton()) === null || _this$getSkeleton === void 0 ? void 0 : _this$getSkeleton.getSkeletonData();
|
|
23226
23583
|
const docDataModel = (_this$getSkeleton2 = this.getSkeleton()) === null || _this$getSkeleton2 === void 0 ? void 0 : _this$getSkeleton2.getViewModel().getDataModel();
|
|
23227
23584
|
if (skeletonData == null || docDataModel == null) return;
|
|
23228
23585
|
const { documentFlavor } = docDataModel.getSnapshot().documentStyle;
|
|
23229
|
-
|
|
23586
|
+
const workspaceFill = (_this$_backgroundFill = this._backgroundFillColor) !== null && _this$_backgroundFill !== void 0 ? _this$_backgroundFill : documentFlavor === DocumentFlavor.MODERN ? PAGE_FILL_COLOR : DOCS_WORKSPACE_FILL_COLOR;
|
|
23587
|
+
this._drawWorkspaceBackground(ctx, workspaceFill, bounds);
|
|
23588
|
+
if (documentFlavor === DocumentFlavor.MODERN) return;
|
|
23230
23589
|
this._drawLiquid.reset();
|
|
23231
23590
|
const { pages } = skeletonData;
|
|
23232
23591
|
let pageTop = 0;
|
|
23233
23592
|
let pageLeft = 0;
|
|
23234
23593
|
for (let i = 0, len = pages.length; i < len; i++) {
|
|
23594
|
+
var _this$_pageStrokeColo, _this$_pageFillColor, _this$_marginStrokeCo;
|
|
23235
23595
|
const page = pages[i];
|
|
23236
23596
|
if (this.isSkipByDiffBounds(page, pageTop, pageLeft, bounds)) {
|
|
23237
23597
|
const { x, y } = this._drawLiquid.translatePage(page, this.pageLayoutType, this.pageMarginLeft, this.pageMarginTop);
|
|
@@ -23246,8 +23606,8 @@ var DocBackground = class DocBackground extends DocComponent {
|
|
|
23246
23606
|
width: pageWidth !== null && pageWidth !== void 0 ? pageWidth : width,
|
|
23247
23607
|
height: pageHeight !== null && pageHeight !== void 0 ? pageHeight : height,
|
|
23248
23608
|
strokeWidth: 1,
|
|
23249
|
-
stroke: PAGE_STROKE_COLOR,
|
|
23250
|
-
fill: PAGE_FILL_COLOR,
|
|
23609
|
+
stroke: (_this$_pageStrokeColo = this._pageStrokeColor) !== null && _this$_pageStrokeColo !== void 0 ? _this$_pageStrokeColo : PAGE_STROKE_COLOR,
|
|
23610
|
+
fill: (_this$_pageFillColor = this._pageFillColor) !== null && _this$_pageFillColor !== void 0 ? _this$_pageFillColor : PAGE_FILL_COLOR,
|
|
23251
23611
|
zIndex: 3
|
|
23252
23612
|
};
|
|
23253
23613
|
Rect.drawWith(ctx, backgroundOptions);
|
|
@@ -23304,7 +23664,7 @@ var DocBackground = class DocBackground extends DocComponent {
|
|
|
23304
23664
|
}
|
|
23305
23665
|
],
|
|
23306
23666
|
strokeWidth: 1.5,
|
|
23307
|
-
stroke: MARGIN_STROKE_COLOR
|
|
23667
|
+
stroke: (_this$_marginStrokeCo = this._marginStrokeColor) !== null && _this$_marginStrokeCo !== void 0 ? _this$_marginStrokeCo : MARGIN_STROKE_COLOR
|
|
23308
23668
|
};
|
|
23309
23669
|
Path.drawWith(ctx, marginIdentification);
|
|
23310
23670
|
ctx.restore();
|
|
@@ -23313,6 +23673,24 @@ var DocBackground = class DocBackground extends DocComponent {
|
|
|
23313
23673
|
pageTop += y;
|
|
23314
23674
|
}
|
|
23315
23675
|
}
|
|
23676
|
+
_drawWorkspaceBackground(ctx, fill, bounds) {
|
|
23677
|
+
var _bounds$cacheBound, _visibleBound$left, _visibleBound$top;
|
|
23678
|
+
const visibleBound = (_bounds$cacheBound = bounds === null || bounds === void 0 ? void 0 : bounds.cacheBound) !== null && _bounds$cacheBound !== void 0 ? _bounds$cacheBound : bounds === null || bounds === void 0 ? void 0 : bounds.viewBound;
|
|
23679
|
+
const left = (_visibleBound$left = visibleBound === null || visibleBound === void 0 ? void 0 : visibleBound.left) !== null && _visibleBound$left !== void 0 ? _visibleBound$left : 0;
|
|
23680
|
+
const top = (_visibleBound$top = visibleBound === null || visibleBound === void 0 ? void 0 : visibleBound.top) !== null && _visibleBound$top !== void 0 ? _visibleBound$top : 0;
|
|
23681
|
+
const width = visibleBound == null ? this.width : visibleBound.right - visibleBound.left;
|
|
23682
|
+
const height = visibleBound == null ? this.height : visibleBound.bottom - visibleBound.top;
|
|
23683
|
+
if (width <= 0 || height <= 0) return;
|
|
23684
|
+
ctx.save();
|
|
23685
|
+
ctx.translate(left, top);
|
|
23686
|
+
Rect.drawWith(ctx, {
|
|
23687
|
+
width,
|
|
23688
|
+
height,
|
|
23689
|
+
fill,
|
|
23690
|
+
zIndex: 0
|
|
23691
|
+
});
|
|
23692
|
+
ctx.restore();
|
|
23693
|
+
}
|
|
23316
23694
|
changeSkeleton(newSkeleton) {
|
|
23317
23695
|
this.setSkeleton(newSkeleton);
|
|
23318
23696
|
return this;
|
|
@@ -24429,7 +24807,6 @@ let Engine = class Engine extends Disposable {
|
|
|
24429
24807
|
}
|
|
24430
24808
|
_getPassive() {
|
|
24431
24809
|
let passiveSupported = false;
|
|
24432
|
-
const noop = () => {};
|
|
24433
24810
|
try {
|
|
24434
24811
|
const options = { passive: { get() {
|
|
24435
24812
|
passiveSupported = true;
|
|
@@ -24463,7 +24840,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
24463
24840
|
//#endregion
|
|
24464
24841
|
//#region package.json
|
|
24465
24842
|
var name = "@univerjs/engine-render";
|
|
24466
|
-
var version = "0.
|
|
24843
|
+
var version = "0.24.0-insiders.20260528-29f582d";
|
|
24467
24844
|
|
|
24468
24845
|
//#endregion
|
|
24469
24846
|
//#region src/config/config.ts
|
|
@@ -27547,6 +27924,7 @@ function subtractViewportRange(range1, range2) {
|
|
|
27547
27924
|
//#endregion
|
|
27548
27925
|
//#region src/viewport.ts
|
|
27549
27926
|
const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3;
|
|
27927
|
+
const WHEEL_CROSS_AXIS_LOCK_RATIO = 2;
|
|
27550
27928
|
var Viewport = class {
|
|
27551
27929
|
constructor(viewportKey, scene, props) {
|
|
27552
27930
|
var _this$scene$getEngine;
|
|
@@ -28190,11 +28568,22 @@ var Viewport = class {
|
|
|
28190
28568
|
let offsetX = 0;
|
|
28191
28569
|
let offsetY = 0;
|
|
28192
28570
|
const allWidth = this._scene.width;
|
|
28193
|
-
|
|
28571
|
+
const viewWidth = this.width || 1;
|
|
28572
|
+
const scaleX = Math.abs(this._scene.scaleX) || 1;
|
|
28573
|
+
const scaleY = Math.abs(this._scene.scaleY) || 1;
|
|
28574
|
+
const rawOffsetX = evt.deltaX / scaleX;
|
|
28575
|
+
const rawOffsetY = evt.deltaY / scaleY;
|
|
28576
|
+
offsetX = viewWidth / allWidth * rawOffsetX;
|
|
28194
28577
|
const allHeight = this._scene.height;
|
|
28195
28578
|
const viewHeight = this.height || 1;
|
|
28196
|
-
if (evt.shiftKey) offsetX = viewHeight / allHeight * evt.deltaY * MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR;
|
|
28197
|
-
else
|
|
28579
|
+
if (evt.shiftKey) offsetX = viewHeight / allHeight * evt.deltaY * MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR / scaleX;
|
|
28580
|
+
else {
|
|
28581
|
+
offsetY = viewHeight / allHeight * rawOffsetY;
|
|
28582
|
+
const absOffsetX = Math.abs(rawOffsetX);
|
|
28583
|
+
const absOffsetY = Math.abs(rawOffsetY);
|
|
28584
|
+
if (absOffsetY >= absOffsetX * WHEEL_CROSS_AXIS_LOCK_RATIO) offsetX = 0;
|
|
28585
|
+
else if (absOffsetX >= absOffsetY * WHEEL_CROSS_AXIS_LOCK_RATIO) offsetY = 0;
|
|
28586
|
+
}
|
|
28198
28587
|
const isLimitedStore = this.scrollByBarDeltaValue({
|
|
28199
28588
|
x: offsetX,
|
|
28200
28589
|
y: offsetY
|
|
@@ -28521,6 +28910,7 @@ var Viewport = class {
|
|
|
28521
28910
|
}
|
|
28522
28911
|
_calcDiffCacheBound(prevBound, currBound) {
|
|
28523
28912
|
if (!prevBound) return [currBound];
|
|
28913
|
+
if (prevBound.right <= currBound.left || currBound.right <= prevBound.left || prevBound.bottom <= currBound.top || currBound.bottom <= prevBound.top) return [currBound];
|
|
28524
28914
|
const additionalAreas = [];
|
|
28525
28915
|
if (currBound.left < prevBound.left) additionalAreas.push({
|
|
28526
28916
|
top: currBound.top,
|
|
@@ -28579,4 +28969,4 @@ var Viewport = class {
|
|
|
28579
28969
|
};
|
|
28580
28970
|
|
|
28581
28971
|
//#endregion
|
|
28582
|
-
export { BASE_OBJECT_ARRAY, BG_Z_INDEX, BORDER_TYPE, BORDER_Z_INDEX, Background, BaseObject, Border, BreakType, CHECK_OBJECT_ARRAY, CIRCLE_OBJECT_ARRAY, COLOR_BLACK_RGB, CURSOR_TYPE, Canvas, CanvasColorService, CanvasRenderMode, CheckboxShape, Circle, ColumnHeaderLayout, ComponentExtension, Control, Custom, CustomObject, DEFAULT_DOCUMENT_FONTSIZE, DEFAULT_FONTFACE_PLANE, DEFAULT_FRAME_LIST_SIZE, DEFAULT_FRAME_SAMPLE_SIZE, DEFAULT_MEASURE_TEXT, DEFAULT_OFFSET_SPACING, DEFAULT_PADDING_DATA, DEFAULT_SKELETON_FOOTER, DEFAULT_SKELETON_HEADER, DOCUMENT_CONTEXT_CLIP_TYPE, DRAWING_OBJECT_LAYER_INDEX, DRAWING_OBJECT_LOWER_LAYER_INDEX, DRAWING_OBJECT_UPPER_LAYER_INDEX, DashedRect, DataStreamTreeNode, DeviceInputEventType, DeviceType, DocBackground, DocSimpleSkeleton, DocumentEditArea, DocumentSkeleton, DocumentSkeletonPageType, DocumentViewModel, Documents, DocumentsSpanAndLineExtensionRegistry, Drawing, DrawingGroupObject, DumbCanvasColorService, EXPAND_SIZE_FOR_RENDER_OVERFLOW, Engine, EventConstants, FIX_ONE_PIXEL_BLUR_OFFSET, FONT_EXTENSION_Z_INDEX, Font, FontCache, GlyphType, Group, HitCanvas, ICanvasColorService, INITIAL_MATRIX, INITIAL_Path2, IRenderManagerService, IRenderingEngine, IWatermarkTypeEnum, Image$1 as Image, IsSafari, LINK_VIEW_PORT_TYPE, Layer, LineType, Liquid, MAIN_VIEW_PORT_KEY, MAXIMUM_COL_WIDTH, MAXIMUM_ROW_HEIGHT, MEASURE_EXTENT, MEASURE_EXTENT_FOR_PARAGRAPH, MIDDLE_CELL_POS_MAGIC_NUMBER, MIN_COL_WIDTH, Marker, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, ORIENTATION_TYPE, ObjectType, PATH_OBJECT_ARRAY, PRINTING_BG_Z_INDEX, PageLayoutType, Path, Path2, PerformanceMonitor, PointerInput, RECT_OBJECT_ARRAY, REGULAR_POLYGON_OBJECT_ARRAY, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, RICHTEXT_OBJECT_ARRAY, Rect, RegularPolygon, RenderComponent, RenderManagerService, RenderUnit, RichText, RollingAverage, RowHeaderLayout, SHAPE_OBJECT_ARRAY, SHAPE_TYPE, SHEET_EXTENSION_PREFIX, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, SLIDE_NAVIGATION_KEY, Scene, SceneCanvas, SceneViewer, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetColumnHeaderExtensionRegistry, SheetComponent, SheetExtension, SheetRowHeaderExtensionRegistry, ShowGridlinesState, SkeletonType, Slide, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetExtensionRegistry, SpreadsheetHeader, SpreadsheetRowHeader, SpreadsheetSkeleton, TEXT_OBJECT_ARRAY, TRANSFORM_CHANGE_OBSERVABLE_TYPE, Text, Transform, UNIVER_WATERMARK_LAYER_INDEX, UNIVER_WATERMARK_STORAGE_KEY, UniverPrintingContext, UniverRenderEnginePlugin, UniverRenderingContext, UniverRenderingContext2D, VERTICAL_ROTATE_ANGLE, Vector2, Viewport, WatermarkLayer, calculateRectRotate, cancelRequestFrame, checkStyle, clampRange, clearLineByBorderType, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, createCanvasElement, createImageElement, degToRad, drawDiagonalLineByBorderType, drawLineByBorderType, expandRangeIfIntersects, fixLineWidthByScale, generateRandomKey, getCellByIndexWithMergeInfo, getCellPositionByIndex, getCharSpaceApply, getColor, getCurrentScrollXY, getCurrentTypeOfRenderer, getDPI, getDevicePixelRatio, getDocsSkeletonPageSize, getDrawingGroupState, getFirstGrapheme, getFontStyleString, getGroupState, getLastColumn, getLastLine, getLineOffset, getLineWidth, getLineWith, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getPointerPrefix, getRenderTransformBaseOnParentBound, getRotateOffsetAndFarthestHypotenuse, getRotateOrientation, getRotatedBoundInGroup, getScale, getSizeForDom, getSystemHighlightColor, getTableIdAndSliceIndex, getTranslateInSpreadContextWithPixelRatio, getValueType, glyphIterator, hasAllLatin, hasArabic, hasBasicLatin, hasCJK, hasCJKPunctuation, hasCJKText, hasLatinExtendedA, hasLatinExtendedB, hasLatinOneSupplement, hasListGlyph, hasSpace, hasTibetan, hasUnMergedCellInRow, inViewRanges, injectStyle, isArray, isCjkCenterAlignedPunctuation, isCjkLeftAlignedPunctuation, isCjkRightAlignedPunctuation, isDate, isEmojiGrapheme, isFirstGlyph, isFunction, isIndentByGlyph, isLastGlyph, isNumber, isObject, isPlaceholderOrSpace, isRectIntersect, isRegExp, isSameLine, isString, lineIterator, mergeInfoOffset, parseDataStreamToTree, pixelToPt, precisionTo, ptToMM, ptToPixel, ptToPx, pxToInch, pxToNum, pxToPt, radToDeg, renderImageWatermark, renderTextWatermark, renderUserInfoWatermark, renderWatermark, requestNewFrame, setLineType, sheetContentViewportKeys, sheetHeaderViewportKeys, startWithEmoji, toPx, transformObjectOutOfGroup, withCurrentTypeOfRenderer };
|
|
28972
|
+
export { BASE_OBJECT_ARRAY, BG_Z_INDEX, BORDER_TYPE, BORDER_Z_INDEX, Background, BaseObject, Border, BreakType, CHECK_OBJECT_ARRAY, CIRCLE_OBJECT_ARRAY, COLOR_BLACK_RGB, CURSOR_TYPE, Canvas, CanvasColorService, CanvasRenderMode, CheckboxShape, Circle, ColumnHeaderLayout, ComponentExtension, Control, Custom, CustomObject, DEFAULT_DOCUMENT_FONTSIZE, DEFAULT_FONTFACE_PLANE, DEFAULT_FRAME_LIST_SIZE, DEFAULT_FRAME_SAMPLE_SIZE, DEFAULT_MEASURE_TEXT, DEFAULT_OFFSET_SPACING, DEFAULT_PADDING_DATA, DEFAULT_SKELETON_FOOTER, DEFAULT_SKELETON_HEADER, DOCUMENT_CONTEXT_CLIP_TYPE, DRAWING_OBJECT_LAYER_INDEX, DRAWING_OBJECT_LOWER_LAYER_INDEX, DRAWING_OBJECT_UPPER_LAYER_INDEX, DashedRect, DataStreamTreeNode, DeviceInputEventType, DeviceType, DocBackground, DocSimpleSkeleton, DocumentEditArea, DocumentSkeleton, DocumentSkeletonPageType, DocumentViewModel, Documents, DocumentsSpanAndLineExtensionRegistry, Drawing, DrawingGroupObject, DumbCanvasColorService, EXPAND_SIZE_FOR_RENDER_OVERFLOW, Engine, EventConstants, FIX_ONE_PIXEL_BLUR_OFFSET, FONT_EXTENSION_Z_INDEX, Font, FontCache, GlyphType, Group, HitCanvas, ICanvasColorService, INITIAL_MATRIX, INITIAL_Path2, IRenderManagerService, IRenderingEngine, IWatermarkTypeEnum, Image$1 as Image, IsSafari, LINK_VIEW_PORT_TYPE, Layer, LineType, Liquid, MAIN_VIEW_PORT_KEY, MAXIMUM_COL_WIDTH, MAXIMUM_ROW_HEIGHT, MEASURE_EXTENT, MEASURE_EXTENT_FOR_PARAGRAPH, MIDDLE_CELL_POS_MAGIC_NUMBER, MIN_COL_WIDTH, Marker, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, ORIENTATION_TYPE, ObjectType, PATH_OBJECT_ARRAY, PRINTING_BG_Z_INDEX, PageLayoutType, Path, Path2, PerformanceMonitor, PointerInput, RECT_OBJECT_ARRAY, REGULAR_POLYGON_OBJECT_ARRAY, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, RICHTEXT_OBJECT_ARRAY, Rect, RegularPolygon, RenderComponent, RenderManagerService, RenderUnit, RichText, RollingAverage, RowHeaderLayout, SHAPE_OBJECT_ARRAY, SHAPE_TYPE, SHEET_EXTENSION_PREFIX, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, SLIDE_NAVIGATION_KEY, Scene, SceneCanvas, SceneViewer, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetColumnHeaderExtensionRegistry, SheetComponent, SheetExtension, SheetRowHeaderExtensionRegistry, ShowGridlinesState, SkeletonType, Slide, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetExtensionRegistry, SpreadsheetHeader, SpreadsheetRowHeader, SpreadsheetSkeleton, TEXT_OBJECT_ARRAY, TRANSFORM_CHANGE_OBSERVABLE_TYPE, Text, Transform, UNIVER_WATERMARK_LAYER_INDEX, UNIVER_WATERMARK_STORAGE_KEY, UniverPrintingContext, UniverRenderEnginePlugin, UniverRenderingContext, UniverRenderingContext2D, VERTICAL_ROTATE_ANGLE, Vector2, Viewport, WatermarkLayer, calculateRectRotate, cancelRequestFrame, checkStyle, clampRange, clearLineByBorderType, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, createCanvasElement, createImageElement, degToRad, drawDiagonalLineByBorderType, drawLineByBorderType, expandRangeIfIntersects, fixLineWidthByScale, generateRandomKey, getCellByIndexWithMergeInfo, getCellPositionByIndex, getCharSpaceApply, getColor, getCurrentScrollXY, getCurrentTypeOfRenderer, getDPI, getDevicePixelRatio, getDocsSkeletonPageSize, getDocsTableRenderViewport, getDrawingGroupState, getFirstGrapheme, getFontStyleString, getGroupState, getLastColumn, getLastLine, getLineOffset, getLineWidth, getLineWith, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getPointerPrefix, getRenderTransformBaseOnParentBound, getRotateOffsetAndFarthestHypotenuse, getRotateOrientation, getRotatedBoundInGroup, getScale, getSizeForDom, getSystemHighlightColor, getTableIdAndSliceIndex, getTranslateInSpreadContextWithPixelRatio, getValueType, glyphIterator, hasAllLatin, hasArabic, hasBasicLatin, hasCJK, hasCJKPunctuation, hasCJKText, hasLatinExtendedA, hasLatinExtendedB, hasLatinOneSupplement, hasListGlyph, hasSpace, hasThai, hasTibetan, hasUnMergedCellInRow, inViewRanges, injectStyle, isArray, isCjkCenterAlignedPunctuation, isCjkLeftAlignedPunctuation, isCjkRightAlignedPunctuation, isDate, isEmojiGrapheme, isFirstGlyph, isFunction, isIndentByGlyph, isLastGlyph, isNumber, isObject, isPlaceholderOrSpace, isRectIntersect, isRegExp, isSameLine, isString, lineIterator, mergeInfoOffset, parseDataStreamToTree, pixelToPt, precisionTo, ptToMM, ptToPixel, ptToPx, pxToInch, pxToNum, pxToPt, radToDeg, renderImageWatermark, renderTextWatermark, renderUserInfoWatermark, renderWatermark, requestNewFrame, setDocsTableRenderViewportProvider, setLineType, sheetContentViewportKeys, sheetHeaderViewportKeys, startWithEmoji, toPx, transformObjectOutOfGroup, withCurrentTypeOfRenderer };
|