@univerjs/engine-render 1.0.0-alpha.0 → 1.0.0-alpha.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/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 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, DocumentBlockRangeType, 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, createParagraphId, deleteContent, extractPureTextFromCell, getCellInfoInMergeData, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isClassDependencyItem, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, registerDependencies, remove, requestImmediateMacroTask, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
1
+ import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnResponsiveType, 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, DocumentBlockRangeType, 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, createParagraphId, deleteContent, extractPureTextFromCell, getCellInfoInMergeData, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isClassDependencyItem, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, registerDependencies, remove, requestImmediateMacroTask, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
2
2
  import * as cjk from "cjk-regex";
3
3
  import { BehaviorSubject, Observable, Subject, Subscription, debounceTime, distinctUntilChanged, shareReplay, startWith } from "rxjs";
4
4
  import { parse } from "opentype.js";
@@ -89,6 +89,10 @@ let CURSOR_TYPE = /* @__PURE__ */ function(CURSOR_TYPE) {
89
89
  CURSOR_TYPE["SOUTH_WEST_RESIZE"] = "sw-resize";
90
90
  CURSOR_TYPE["SOUTH_RESIZE"] = "s-resize";
91
91
  CURSOR_TYPE["WEST_RESIZE"] = "w-resize";
92
+ CURSOR_TYPE["EAST_WEST_RESIZE"] = "ew-resize";
93
+ CURSOR_TYPE["NORTH_SOUTH_RESIZE"] = "ns-resize";
94
+ CURSOR_TYPE["NORTH_EAST_SOUTH_WEST_RESIZE"] = "nesw-resize";
95
+ CURSOR_TYPE["NORTH_WEST_SOUTH_EAST_RESIZE"] = "nwse-resize";
92
96
  CURSOR_TYPE["TEXT"] = "text";
93
97
  CURSOR_TYPE["WAIT"] = "wait";
94
98
  CURSOR_TYPE["HELP"] = "help";
@@ -203,6 +207,7 @@ const cancelRequestFrame = (requestID, requester) => {
203
207
  };
204
208
  const createCanvasElement = () => {
205
209
  const canvas = document.createElement("canvas");
210
+ canvas.dir = "ltr";
206
211
  try {
207
212
  canvas.style = canvas.style || {};
208
213
  } catch (e) {
@@ -3435,11 +3440,12 @@ var BaseObject = class extends Disposable {
3435
3440
  if (this.isInGroup && ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.classType) === "Group" && ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.getBaseBound)) baseBound = this.parent.getBaseBound();
3436
3441
  if (baseBound) {
3437
3442
  const parentState = this.getParent();
3443
+ const parentRealBound = typeof parentState.getRealBound === "function" ? parentState.getRealBound() : parentState;
3438
3444
  const parentBound = {
3439
- top: parentState.top || 0,
3440
- left: parentState.left,
3441
- width: parentState.width || 0,
3442
- height: parentState.height || 0
3445
+ top: parentRealBound.top || 0,
3446
+ left: parentRealBound.left,
3447
+ width: parentRealBound.width || 0,
3448
+ height: parentRealBound.height || 0
3443
3449
  };
3444
3450
  const realBound = getRenderTransformBaseOnParentBound(baseBound, parentBound, {
3445
3451
  width: realWidth,
@@ -11969,6 +11975,68 @@ var Text = class Text extends Shape {
11969
11975
  }
11970
11976
  };
11971
11977
 
11978
+ //#endregion
11979
+ //#region src/components/docs/document-compatibility.ts
11980
+ const MODERN_DOCUMENT_COMPATIBILITY_POLICY = {
11981
+ mode: "modern",
11982
+ applyDocumentDefaultParagraphStyle: true,
11983
+ useWordStyleLineHeight: true,
11984
+ font: { metricScaleRules: [] },
11985
+ table: {
11986
+ currentPageOverflowTolerance: 0,
11987
+ rowOverflowTolerance: 0,
11988
+ allowImportedTableMarginOverflow: false
11989
+ }
11990
+ };
11991
+ const TRADITIONAL_DOCUMENT_COMPATIBILITY_POLICY = {
11992
+ mode: "traditional",
11993
+ applyDocumentDefaultParagraphStyle: false,
11994
+ useWordStyleLineHeight: true,
11995
+ font: { metricScaleRules: [{
11996
+ fontFamily: /^calibri$/i,
11997
+ minFontSize: 20,
11998
+ fontString: /\bbold\b/i,
11999
+ content: /^[\d/]+$/u,
12000
+ widthScale: .92
12001
+ }] },
12002
+ table: {
12003
+ currentPageOverflowTolerance: 12,
12004
+ rowOverflowTolerance: 4,
12005
+ allowImportedTableMarginOverflow: true
12006
+ }
12007
+ };
12008
+ const UNSPECIFIED_DOCUMENT_COMPATIBILITY_POLICY = {
12009
+ mode: "unspecified",
12010
+ applyDocumentDefaultParagraphStyle: false,
12011
+ useWordStyleLineHeight: false,
12012
+ font: { metricScaleRules: [] },
12013
+ table: {
12014
+ currentPageOverflowTolerance: 0,
12015
+ rowOverflowTolerance: 0,
12016
+ allowImportedTableMarginOverflow: false
12017
+ }
12018
+ };
12019
+ function getDocumentCompatibilityPolicy(documentFlavor) {
12020
+ if (documentFlavor === DocumentFlavor.MODERN) return MODERN_DOCUMENT_COMPATIBILITY_POLICY;
12021
+ if (documentFlavor === DocumentFlavor.TRADITIONAL) return TRADITIONAL_DOCUMENT_COMPATIBILITY_POLICY;
12022
+ return UNSPECIFIED_DOCUMENT_COMPATIBILITY_POLICY;
12023
+ }
12024
+ function applyFontMetricCompatibility(content, fontStyle, bBox, policy) {
12025
+ const fontFamilies = fontStyle.fontFamily.split(",").map((item) => item.trim().replace(/^['"]|['"]$/g, ""));
12026
+ const rule = policy.font.metricScaleRules.find((rule) => (rule.minFontSize == null || fontStyle.originFontSize >= rule.minFontSize) && (rule.fontString == null || rule.fontString.test(fontStyle.fontString)) && (rule.content == null || rule.content.test(content)) && fontFamilies.some((family) => rule.fontFamily.test(family)));
12027
+ if ((rule === null || rule === void 0 ? void 0 : rule.widthScale) == null) return bBox;
12028
+ return {
12029
+ ...bBox,
12030
+ width: bBox.width * rule.widthScale
12031
+ };
12032
+ }
12033
+ function isTraditionalDocumentCompatibility(policy) {
12034
+ return policy.mode === "traditional";
12035
+ }
12036
+ function shouldAllowImportedTableMarginOverflow(policy, tableSource) {
12037
+ return policy.table.allowImportedTableMarginOverflow && tableSource != null && typeof tableSource === "object" && "docxWidth" in tableSource;
12038
+ }
12039
+
11972
12040
  //#endregion
11973
12041
  //#region src/components/docs/liquid.ts
11974
12042
  var Liquid = class {
@@ -12261,8 +12329,16 @@ function parseDataStreamToTree(dataStream, tables) {
12261
12329
  const tableList = [];
12262
12330
  const tableRowList = [];
12263
12331
  const tableCellList = [];
12332
+ const columnGroupList = [];
12333
+ const columnList = [];
12334
+ const columnParagraphList = [];
12335
+ const columnSectionList = [];
12264
12336
  const currentBlocks = [];
12265
- const getParagraphList = () => tableCellList.length > 0 ? cellParagraphList : paragraphList;
12337
+ const getParagraphList = () => {
12338
+ if (tableCellList.length > 0) return cellParagraphList;
12339
+ if (columnGroupList.length > 0) return columnParagraphList;
12340
+ return paragraphList;
12341
+ };
12266
12342
  const appendToPreviousParagraph = (char) => {
12267
12343
  const tempParagraphList = getParagraphList();
12268
12344
  const lastParagraph = tempParagraphList[tempParagraphList.length - 1];
@@ -12292,10 +12368,11 @@ function parseDataStreamToTree(dataStream, tables) {
12292
12368
  currentBlocks.length = 0;
12293
12369
  content = "";
12294
12370
  if (tableCellList.length > 0) cellParagraphList.push(paragraphNode);
12371
+ else if (columnGroupList.length > 0) columnParagraphList.push(paragraphNode);
12295
12372
  else paragraphList.push(paragraphNode);
12296
12373
  } else if (char === DataStreamTreeTokenType.SECTION_BREAK) {
12297
12374
  const sectionNode = DataStreamTreeNode.create(DataStreamTreeNodeType.SECTION_BREAK);
12298
- const tempParagraphList = tableCellList.length > 0 ? cellParagraphList : paragraphList;
12375
+ const tempParagraphList = tableCellList.length > 0 ? cellParagraphList : columnGroupList.length > 0 ? columnParagraphList : paragraphList;
12299
12376
  if (tempParagraphList.length === 0) {
12300
12377
  const emptyParagraph = DataStreamTreeNode.create(DataStreamTreeNodeType.PARAGRAPH, "");
12301
12378
  emptyParagraph.setIndexRange(i, i - 1);
@@ -12307,7 +12384,8 @@ function parseDataStreamToTree(dataStream, tables) {
12307
12384
  if (tableCellList.length > 0) {
12308
12385
  const lastCell = tableCellList[tableCellList.length - 1];
12309
12386
  batchParent(lastCell, [sectionNode], DataStreamTreeNodeType.TABLE_CELL);
12310
- } else sectionList.push(sectionNode);
12387
+ } else if (columnGroupList.length > 0) columnSectionList.push(sectionNode);
12388
+ else sectionList.push(sectionNode);
12311
12389
  tempParagraphList.length = 0;
12312
12390
  } else if (char === DataStreamTreeTokenType.TABLE_START) {
12313
12391
  const tableNode = DataStreamTreeNode.create(DataStreamTreeNodeType.TABLE);
@@ -12333,6 +12411,32 @@ function parseDataStreamToTree(dataStream, tables) {
12333
12411
  const cellNode = tableCellList.pop();
12334
12412
  const lastRow = tableRowList[tableRowList.length - 1];
12335
12413
  batchParent(lastRow, [cellNode], DataStreamTreeNodeType.TABLE_ROW);
12414
+ } else if (char === DataStreamTreeTokenType.COLUMN_GROUP_START) {
12415
+ const columnGroupNode = DataStreamTreeNode.create(DataStreamTreeNodeType.COLUMN_GROUP);
12416
+ columnGroupNode.setIndexRange(i, i);
12417
+ columnGroupList.push(columnGroupNode);
12418
+ } else if (char === DataStreamTreeTokenType.COLUMN_START) {
12419
+ const columnNode = DataStreamTreeNode.create(DataStreamTreeNodeType.COLUMN);
12420
+ columnNode.setIndexRange(i, i);
12421
+ columnList.push(columnNode);
12422
+ } else if (char === DataStreamTreeTokenType.COLUMN_END) {
12423
+ const columnNode = columnList[columnList.length - 1];
12424
+ const columnChildren = columnSectionList.length > 0 ? columnSectionList : columnParagraphList;
12425
+ const columnStartIndex = columnNode.startIndex;
12426
+ batchParent(columnNode, columnChildren, DataStreamTreeNodeType.COLUMN);
12427
+ columnNode.setIndexRange(columnStartIndex, i);
12428
+ columnParagraphList.length = 0;
12429
+ columnSectionList.length = 0;
12430
+ } else if (char === DataStreamTreeTokenType.COLUMN_GROUP_END) {
12431
+ const columnGroupNode = columnGroupList.pop();
12432
+ const columnGroupStartIndex = columnGroupNode.startIndex;
12433
+ batchParent(columnGroupNode, columnList, DataStreamTreeNodeType.COLUMN_GROUP);
12434
+ columnGroupNode.setIndexRange(columnGroupStartIndex, i);
12435
+ paragraphList.push(columnGroupNode);
12436
+ columnList.length = 0;
12437
+ columnParagraphList.length = 0;
12438
+ columnSectionList.length = 0;
12439
+ content = "";
12336
12440
  } else if (char === DataStreamTreeTokenType.BLOCK_START) content += char;
12337
12441
  else if (char === DataStreamTreeTokenType.BLOCK_END) {
12338
12442
  if (content.length > 0 || !appendToPreviousParagraph(char)) content += char;
@@ -12347,8 +12451,9 @@ function parseDataStreamToTree(dataStream, tables) {
12347
12451
  };
12348
12452
  }
12349
12453
  var DocumentViewModel = class DocumentViewModel {
12350
- constructor(_documentDataModel) {
12454
+ constructor(_documentDataModel, _tableSource) {
12351
12455
  this._documentDataModel = _documentDataModel;
12456
+ this._tableSource = _tableSource;
12352
12457
  _defineProperty(this, "_interceptor", null);
12353
12458
  _defineProperty(this, "_cacheSize", 1e3);
12354
12459
  _defineProperty(this, "_textRunsCache", /* @__PURE__ */ new Map());
@@ -12356,6 +12461,7 @@ var DocumentViewModel = class DocumentViewModel {
12356
12461
  _defineProperty(this, "_sectionBreakCache", /* @__PURE__ */ new Map());
12357
12462
  _defineProperty(this, "_customBlockCache", /* @__PURE__ */ new Map());
12358
12463
  _defineProperty(this, "_tableCache", /* @__PURE__ */ new Map());
12464
+ _defineProperty(this, "_columnGroupCache", /* @__PURE__ */ new Map());
12359
12465
  _defineProperty(this, "_tableNodeCache", /* @__PURE__ */ new Map());
12360
12466
  _defineProperty(this, "_children", []);
12361
12467
  _defineProperty(this, "_editArea", "BODY");
@@ -12386,6 +12492,7 @@ var DocumentViewModel = class DocumentViewModel {
12386
12492
  this._sectionBreakCache.clear();
12387
12493
  this._customBlockCache.clear();
12388
12494
  this._tableCache.clear();
12495
+ this._columnGroupCache.clear();
12389
12496
  this._tableNodeCache.clear();
12390
12497
  this._segmentViewModels$.complete();
12391
12498
  this._editAreaChange$.complete();
@@ -12457,6 +12564,9 @@ var DocumentViewModel = class DocumentViewModel {
12457
12564
  getTableByStartIndex(index) {
12458
12565
  return this._tableCache.get(index);
12459
12566
  }
12567
+ getColumnGroupByStartIndex(index) {
12568
+ return this._columnGroupCache.get(index);
12569
+ }
12460
12570
  findTableNodeById(id) {
12461
12571
  var _this$_tableNodeCache;
12462
12572
  return (_this$_tableNodeCache = this._tableNodeCache.get(id)) === null || _this$_tableNodeCache === void 0 ? void 0 : _this$_tableNodeCache.table;
@@ -12491,6 +12601,7 @@ var DocumentViewModel = class DocumentViewModel {
12491
12601
  this._buildSectionBreakCache();
12492
12602
  this._buildCustomBlockCache();
12493
12603
  this._buildTableCache();
12604
+ this._buildColumnGroupCache();
12494
12605
  }
12495
12606
  _buildParagraphCache() {
12496
12607
  var _this$getBody$paragra, _this$getBody;
@@ -12520,10 +12631,10 @@ var DocumentViewModel = class DocumentViewModel {
12520
12631
  }
12521
12632
  }
12522
12633
  _buildTableCache() {
12523
- var _this$getBody4;
12634
+ var _this$getBody4, _this$_tableSource;
12524
12635
  this._tableCache.clear();
12525
12636
  const tables = (_this$getBody4 = this.getBody()) === null || _this$getBody4 === void 0 ? void 0 : _this$getBody4.tables;
12526
- const tableConfig = this.getSnapshot().tableSource;
12637
+ const tableConfig = (_this$_tableSource = this._tableSource) !== null && _this$_tableSource !== void 0 ? _this$_tableSource : this.getSnapshot().tableSource;
12527
12638
  if (tables == null || tableConfig == null) return;
12528
12639
  for (const table of tables) {
12529
12640
  const { startIndex, tableId } = table;
@@ -12535,9 +12646,23 @@ var DocumentViewModel = class DocumentViewModel {
12535
12646
  });
12536
12647
  }
12537
12648
  }
12649
+ _buildColumnGroupCache() {
12650
+ var _this$getBody5;
12651
+ this._columnGroupCache.clear();
12652
+ const columnGroups = (_this$getBody5 = this.getBody()) === null || _this$getBody5 === void 0 ? void 0 : _this$getBody5.columnGroups;
12653
+ if (columnGroups == null) return;
12654
+ for (const columnGroup of columnGroups) {
12655
+ const { startIndex } = columnGroup;
12656
+ if (!columnGroup.columns) continue;
12657
+ this._columnGroupCache.set(startIndex, {
12658
+ columnGroup,
12659
+ columnGroupSource: columnGroup
12660
+ });
12661
+ }
12662
+ }
12538
12663
  _buildTextRunsCache() {
12539
- var _this$getBody$textRun, _this$getBody5;
12540
- const textRuns = (_this$getBody$textRun = (_this$getBody5 = this.getBody()) === null || _this$getBody5 === void 0 ? void 0 : _this$getBody5.textRuns) !== null && _this$getBody$textRun !== void 0 ? _this$getBody$textRun : [];
12664
+ var _this$getBody$textRun, _this$getBody6;
12665
+ const textRuns = (_this$getBody$textRun = (_this$getBody6 = this.getBody()) === null || _this$getBody6 === void 0 ? void 0 : _this$getBody6.textRuns) !== null && _this$getBody$textRun !== void 0 ? _this$getBody$textRun : [];
12541
12666
  this._textRunsCache.clear();
12542
12667
  for (const textRun of textRuns) {
12543
12668
  const { st, ed } = textRun;
@@ -12551,80 +12676,19 @@ var DocumentViewModel = class DocumentViewModel {
12551
12676
  _buildHeaderFooterViewModel() {
12552
12677
  const { headerModelMap, footerModelMap } = this._documentDataModel;
12553
12678
  const viewModels = [];
12679
+ const tableSource = this.getSnapshot().tableSource;
12554
12680
  for (const [headerId, headerModel] of headerModelMap) {
12555
- this._headerTreeMap.set(headerId, new DocumentViewModel(headerModel));
12681
+ this._headerTreeMap.set(headerId, new DocumentViewModel(headerModel, tableSource));
12556
12682
  viewModels.push(this._headerTreeMap.get(headerId));
12557
12683
  }
12558
12684
  for (const [footerId, footerModel] of footerModelMap) {
12559
- this._footerTreeMap.set(footerId, new DocumentViewModel(footerModel));
12685
+ this._footerTreeMap.set(footerId, new DocumentViewModel(footerModel, tableSource));
12560
12686
  viewModels.push(this._footerTreeMap.get(footerId));
12561
12687
  }
12562
12688
  this._segmentViewModels$.next(viewModels);
12563
12689
  }
12564
12690
  };
12565
12691
 
12566
- //#endregion
12567
- //#region src/components/docs/document-compatibility.ts
12568
- const MODERN_DOCUMENT_COMPATIBILITY_POLICY = {
12569
- mode: "modern",
12570
- applyDocumentDefaultParagraphStyle: true,
12571
- useWordStyleLineHeight: true,
12572
- font: { metricScaleRules: [] },
12573
- table: {
12574
- currentPageOverflowTolerance: 0,
12575
- rowOverflowTolerance: 0,
12576
- allowImportedTableMarginOverflow: false
12577
- }
12578
- };
12579
- const TRADITIONAL_DOCUMENT_COMPATIBILITY_POLICY = {
12580
- mode: "traditional",
12581
- applyDocumentDefaultParagraphStyle: false,
12582
- useWordStyleLineHeight: true,
12583
- font: { metricScaleRules: [{
12584
- fontFamily: /^calibri$/i,
12585
- minFontSize: 20,
12586
- fontString: /\bbold\b/i,
12587
- content: /^[\d/]+$/u,
12588
- widthScale: .92
12589
- }] },
12590
- table: {
12591
- currentPageOverflowTolerance: 12,
12592
- rowOverflowTolerance: 4,
12593
- allowImportedTableMarginOverflow: true
12594
- }
12595
- };
12596
- const UNSPECIFIED_DOCUMENT_COMPATIBILITY_POLICY = {
12597
- mode: "unspecified",
12598
- applyDocumentDefaultParagraphStyle: false,
12599
- useWordStyleLineHeight: false,
12600
- font: { metricScaleRules: [] },
12601
- table: {
12602
- currentPageOverflowTolerance: 0,
12603
- rowOverflowTolerance: 0,
12604
- allowImportedTableMarginOverflow: false
12605
- }
12606
- };
12607
- function getDocumentCompatibilityPolicy(documentFlavor) {
12608
- if (documentFlavor === DocumentFlavor.MODERN) return MODERN_DOCUMENT_COMPATIBILITY_POLICY;
12609
- if (documentFlavor === DocumentFlavor.TRADITIONAL) return TRADITIONAL_DOCUMENT_COMPATIBILITY_POLICY;
12610
- return UNSPECIFIED_DOCUMENT_COMPATIBILITY_POLICY;
12611
- }
12612
- function applyFontMetricCompatibility(content, fontStyle, bBox, policy) {
12613
- const fontFamilies = fontStyle.fontFamily.split(",").map((item) => item.trim().replace(/^['"]|['"]$/g, ""));
12614
- const rule = policy.font.metricScaleRules.find((rule) => (rule.minFontSize == null || fontStyle.originFontSize >= rule.minFontSize) && (rule.fontString == null || rule.fontString.test(fontStyle.fontString)) && (rule.content == null || rule.content.test(content)) && fontFamilies.some((family) => rule.fontFamily.test(family)));
12615
- if ((rule === null || rule === void 0 ? void 0 : rule.widthScale) == null) return bBox;
12616
- return {
12617
- ...bBox,
12618
- width: bBox.width * rule.widthScale
12619
- };
12620
- }
12621
- function isTraditionalDocumentCompatibility(policy) {
12622
- return policy.mode === "traditional";
12623
- }
12624
- function shouldAllowImportedTableMarginOverflow(policy, tableSource) {
12625
- return policy.table.allowImportedTableMarginOverflow && tableSource != null && typeof tableSource === "object" && "docxWidth" in tableSource;
12626
- }
12627
-
12628
12692
  //#endregion
12629
12693
  //#region src/components/docs/layout/model/glyph.ts
12630
12694
  function isSpace(char) {
@@ -12715,6 +12779,10 @@ function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, gly
12715
12779
  DataStreamTreeTokenType.TABLE_ROW_END,
12716
12780
  DataStreamTreeTokenType.TABLE_CELL_START,
12717
12781
  DataStreamTreeTokenType.TABLE_CELL_END,
12782
+ DataStreamTreeTokenType.COLUMN_GROUP_START,
12783
+ DataStreamTreeTokenType.COLUMN_START,
12784
+ DataStreamTreeTokenType.COLUMN_END,
12785
+ DataStreamTreeTokenType.COLUMN_GROUP_END,
12718
12786
  DataStreamTreeTokenType.BLOCK_START,
12719
12787
  DataStreamTreeTokenType.BLOCK_END,
12720
12788
  DataStreamTreeTokenType.CUSTOM_RANGE_START,
@@ -12877,7 +12945,9 @@ function createSkeletonLine(paragraphIndex, lineType, lineBoundingBox, columnWid
12877
12945
  lineSke.isBehindTable = true;
12878
12946
  lineSke.tableId = tableId;
12879
12947
  }
12880
- lineSke.divides = _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, new Map(Array.from(pageSkeDrawings).filter(([_, drawing]) => drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.INLINE && drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.WRAP_NONE)), headersDrawings, footersDrawings, new Map(Array.from(pageSkeTables).filter(([_, table]) => table.tableSource.textWrap === TableTextWrapType.WRAP)));
12948
+ const affectSkeDrawings = new Map(Array.from(pageSkeDrawings).filter(([_, drawing]) => drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.INLINE && drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.WRAP_NONE));
12949
+ const wrapTypeTables = new Map(Array.from(pageSkeTables).filter(([_, table]) => table.tableSource.textWrap === TableTextWrapType.WRAP));
12950
+ lineSke.divides = lineHeight <= .01 ? [__getDivideSKe(0, columnWidth)] : _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, affectSkeDrawings, headersDrawings, footersDrawings, wrapTypeTables);
12881
12951
  for (const divide of lineSke.divides) divide.parent = lineSke;
12882
12952
  return lineSke;
12883
12953
  }
@@ -13116,6 +13186,8 @@ function ___getWrapTextRuler(wrapText, resultLeft, resultWidth, columnWidth) {
13116
13186
  return ruler;
13117
13187
  }
13118
13188
  function _calculateDivideByDrawings(columnWidth, drawingSplit) {
13189
+ if (!Number.isFinite(columnWidth) || columnWidth <= 0) return [__getDivideSKe(0, Math.max(1, columnWidth || 1))];
13190
+ drawingSplit = drawingSplit.filter(({ left, width }) => Number.isFinite(left) && Number.isFinite(width) && width > 0 && left < columnWidth && left + width > 0);
13119
13191
  drawingSplit.sort((pre, next) => {
13120
13192
  if (pre.left > next.left) return 1;
13121
13193
  return -1;
@@ -13645,6 +13717,13 @@ function getTableIdAndSliceIndex(tableSliceId) {
13645
13717
  //#region src/components/docs/layout/block/paragraph/layout-ruler.ts
13646
13718
  const LINE_LAYOUT_OVERFLOW_TOLERANCE = 2;
13647
13719
  const FLOAT_OBJECT_RELAYOUT_LIMIT = 5;
13720
+ const MIN_LINE_WIDTH_TOLERANCE = 1;
13721
+ const MAX_LINE_WIDTH_TOLERANCE = 3;
13722
+ const RELATIVE_LINE_WIDTH_TOLERANCE = .01;
13723
+ function isBeyondDivideWidth(width, divideWidth) {
13724
+ const tolerance = Math.min(MAX_LINE_WIDTH_TOLERANCE, Math.max(MIN_LINE_WIDTH_TOLERANCE, divideWidth * RELATIVE_LINE_WIDTH_TOLERANCE));
13725
+ return width - divideWidth > tolerance;
13726
+ }
13648
13727
  function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal") {
13649
13728
  if (isParagraphFirstShapedText) if (paragraphConfig.bulletSkeleton) {
13650
13729
  var _paragraphProperties$;
@@ -13726,7 +13805,12 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13726
13805
  const lastGlyph = divide === null || divide === void 0 || (_divide$glyphGroup = divide.glyphGroup) === null || _divide$glyphGroup === void 0 ? void 0 : _divide$glyphGroup[divide.glyphGroup.length - 1];
13727
13806
  const preOffsetLeft = ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.width) || 0) + ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.left) || 0);
13728
13807
  const { hyphenationZone } = sectionBreakConfig;
13729
- if (preOffsetLeft + width > divide.width) {
13808
+ if (isBeyondDivideWidth(preOffsetLeft + width, divide.width)) {
13809
+ if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0 && glyphGroup.length > 0 && glyphGroup[0].streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) {
13810
+ addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13811
+ updateDivideInfo(divide, { breakType: breakPointType });
13812
+ return;
13813
+ }
13730
13814
  if (shouldKeepOverflowingTextOnLine(sectionBreakConfig)) {
13731
13815
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13732
13816
  updateDivideInfo(divide, { breakType: breakPointType });
@@ -13738,13 +13822,13 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13738
13822
  if (divideInfo.isLast && glyphGroup.length === 1 && (glyphGroup[0].content === DataStreamTreeTokenType.SPACE || glyphGroup[0].content === DataStreamTreeTokenType.PARAGRAPH)) addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13739
13823
  else if (divideInfo.isLast && !isGlyphGroupBeyondContentBox(glyphGroup, preOffsetLeft, divide.width) && isGlyphGroupEndWithWhiteSpaces(glyphGroup)) addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13740
13824
  else if (!isLast && (divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0 && glyphGroup.length === 1 && glyphGroup[0].streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyphGroup[0].width > divide.width) {
13741
- updateDivideInfo(divide, { isFull: true });
13742
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
13825
+ addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13826
+ updateDivideInfo(divide, { breakType: breakPointType });
13743
13827
  } else if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0) {
13744
13828
  const sliceGlyphGroup = [];
13745
13829
  while (glyphGroup.length) {
13746
13830
  sliceGlyphGroup.push(glyphGroup.shift());
13747
- if (__getGlyphGroupWidth(sliceGlyphGroup) > divide.width) {
13831
+ if (isBeyondDivideWidth(__getGlyphGroupWidth(sliceGlyphGroup), divide.width)) {
13748
13832
  if (sliceGlyphGroup.length > 1) glyphGroup.unshift(sliceGlyphGroup.pop());
13749
13833
  break;
13750
13834
  }
@@ -13797,6 +13881,10 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13797
13881
  const paragraphAnchorLeft = __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, (_paragraphConfig$para = paragraphConfig.paragraphStyle) === null || _paragraphConfig$para === void 0 ? void 0 : _paragraphConfig$para.indentStart);
13798
13882
  const drawings = __getDrawingPosition(currentLine.top, currentLine.lineHeight, currentLine.parent, true, (_paragraphConfig$pDra = paragraphConfig.pDrawingAnchor) === null || _paragraphConfig$pDra === void 0 || (_paragraphConfig$pDra = _paragraphConfig$pDra.get(paragraphConfig.paragraphIndex)) === null || _paragraphConfig$pDra === void 0 ? void 0 : _paragraphConfig$pDra.top, anchorDrawings, paragraphAnchorLeft);
13799
13883
  __updateDrawingPosition(currentLine.parent, drawings);
13884
+ addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13885
+ updateDivideInfo(divide, { breakType: breakPointType });
13886
+ glyphGroup.length = 0;
13887
+ return;
13800
13888
  }
13801
13889
  }
13802
13890
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
@@ -13808,6 +13896,19 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13808
13896
  var _originParagraphStyle, _originParagraphStyle2, _skeHeaders$get, _skeFooters$get;
13809
13897
  let lastPage = getLastPage(pages);
13810
13898
  let columnInfo = getLastNotFullColumnInfo(lastPage);
13899
+ if (!columnInfo || !columnInfo.column) {
13900
+ const lastSection = getLastSection(lastPage);
13901
+ const lastColumnIndex = lastSection.columns.length - 1;
13902
+ const lastColumn = lastSection.columns[lastColumnIndex];
13903
+ if (lastColumn && isBlankColumn(lastColumn)) {
13904
+ setColumnFullState(lastColumn, false);
13905
+ columnInfo = {
13906
+ column: lastColumn,
13907
+ index: lastColumnIndex,
13908
+ isLast: true
13909
+ };
13910
+ }
13911
+ }
13811
13912
  if (!columnInfo || !columnInfo.column) {
13812
13913
  _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, true, breakPointType);
13813
13914
  lastPage = getLastPage(pages);
@@ -13834,9 +13935,21 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13834
13935
  };
13835
13936
  const { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(sectionBreakConfig, paragraphConfig);
13836
13937
  const hasInlineCustomBlock = glyphGroup.some((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0);
13938
+ const positionedCustomBlockOnly = glyphGroup.length > 0 && paragraphNonInlineSkeDrawings != null && paragraphNonInlineSkeDrawings.size > 0 && glyphGroup.every((glyph) => {
13939
+ if (!glyph) return false;
13940
+ if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) return [...paragraphNonInlineSkeDrawings.values()].some((drawing) => drawing.drawingId === glyph.drawingId);
13941
+ return glyph.streamType === DataStreamTreeTokenType.PARAGRAPH || glyph.raw === DataStreamTreeTokenType.PARAGRAPH;
13942
+ });
13837
13943
  const glyphGroupCustomBlockIds = new Set(glyphGroup.filter((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.drawingId != null).map((glyph) => glyph.drawingId));
13838
13944
  let { paddingTop, paddingBottom, contentHeight, lineSpacingApply } = getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid, paragraphConfig.useWordStyleLineHeight, !hasInlineCustomBlock);
13945
+ if (positionedCustomBlockOnly) {
13946
+ paddingTop = 0;
13947
+ paddingBottom = 0;
13948
+ contentHeight = .01;
13949
+ lineSpacingApply = .01;
13950
+ }
13839
13951
  let { marginTop, spaceBelowApply } = __getParagraphSpace(ctx, lineSpacingApply, spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine);
13952
+ if (positionedCustomBlockOnly) spaceBelowApply = 0;
13840
13953
  if (isZeroWidthNonFlowFloatingAnchorLine) {
13841
13954
  paddingTop = 0;
13842
13955
  paddingBottom = 0;
@@ -13879,7 +13992,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13879
13992
  var _pDrawingAnchor$get2;
13880
13993
  needOpenNewPageByTableLayout = _updateAndPositionTable(ctx, lineTop, lineHeight, lastPage, column, section, skeTablesInParagraph, paragraphConfig.paragraphIndex, sectionBreakConfig, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get2 = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get2 === void 0 ? void 0 : _pDrawingAnchor$get2.top);
13881
13994
  }
13882
- const newLineTop = calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage);
13995
+ const newLineTop = positionedCustomBlockOnly ? lineTop : calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage);
13883
13996
  if (lineHeight + newLineTop - section.height > LINE_LAYOUT_OVERFLOW_TOLERANCE && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
13884
13997
  setColumnFullState(column, true);
13885
13998
  _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
@@ -14505,6 +14618,25 @@ function isColumnFull(page) {
14505
14618
  for (let i = 0; i < columnsLen; i++) if (!section.columns[i].isFull) return false;
14506
14619
  return true;
14507
14620
  }
14621
+ function isBlankColumn(column) {
14622
+ const lines = column.lines;
14623
+ if (lines.length > 1) return false;
14624
+ const line = lines[lines.length - 1];
14625
+ return isLineBlank(line);
14626
+ }
14627
+ function isLineBlank(line) {
14628
+ if (!line) return true;
14629
+ for (let i = 0; i < line.divides.length; i++) {
14630
+ const spanCount = line.divides[i].glyphGroup.length;
14631
+ if (spanCount > 1) return false;
14632
+ if (spanCount === 1) {
14633
+ const { glyphType, raw, streamType, width } = line.divides[i].glyphGroup[0];
14634
+ const isZeroWidthColumnBreak = width === 0 && (raw === DataStreamTreeTokenType.COLUMN_BREAK || streamType === DataStreamTreeTokenType.COLUMN_BREAK);
14635
+ if (glyphType !== 4 && glyphType !== 2 && !isZeroWidthColumnBreak) return false;
14636
+ }
14637
+ }
14638
+ return true;
14639
+ }
14508
14640
  function getNumberUnitValue(unitValue, benchMark) {
14509
14641
  if (!unitValue) return 0;
14510
14642
  const { v: value, u: unit } = unitValue;
@@ -14554,15 +14686,17 @@ function getCharSpaceConfig(sectionBreakConfig, paragraphConfig) {
14554
14686
  snapToGrid
14555
14687
  };
14556
14688
  }
14557
- function updateBlockIndex(pages, start = -1) {
14689
+ function updateBlockIndex(pages, start = -1, documentCompatibilityPolicy) {
14558
14690
  let prePageStartIndex = start;
14691
+ const shouldUseLayoutColumnWidth = (documentCompatibilityPolicy === null || documentCompatibilityPolicy === void 0 ? void 0 : documentCompatibilityPolicy.mode) !== "unspecified";
14559
14692
  for (const page of pages) {
14560
- const { sections, skeTables } = page;
14693
+ const { sections, skeTables, skeColumnGroups = /* @__PURE__ */ new Map() } = page;
14561
14694
  const pageStartIndex = prePageStartIndex;
14562
14695
  let preSectionStartIndex = pageStartIndex;
14563
14696
  let maxContentWidth = Number.NEGATIVE_INFINITY;
14564
14697
  let contentHeight = 0;
14565
14698
  for (const section of sections) {
14699
+ collapseRedundantColumnBreakOverflow(section);
14566
14700
  const { columns } = section;
14567
14701
  const sectionStartIndex = preSectionStartIndex;
14568
14702
  let preColumnStartIndex = sectionStartIndex;
@@ -14581,6 +14715,16 @@ function updateBlockIndex(pages, start = -1) {
14581
14715
  const table = skeTables.get(tableId);
14582
14716
  if (table) lineStartIndex = table.ed;
14583
14717
  }
14718
+ if (line.type === 1 && divides.length === 0) {
14719
+ line.st = Math.max(line.st, lineStartIndex + 1);
14720
+ line.ed = Math.max(line.ed, line.st);
14721
+ line.width = 0;
14722
+ line.asc = 0;
14723
+ line.dsc = 0;
14724
+ columnHeight = top + lineHeight;
14725
+ preLineStartIndex = Math.max(preLineStartIndex, line.ed);
14726
+ continue;
14727
+ }
14584
14728
  let preDivideStartIndex = lineStartIndex;
14585
14729
  let actualWidth = 0;
14586
14730
  let maxLineAsc = 0;
@@ -14620,8 +14764,9 @@ function updateBlockIndex(pages, start = -1) {
14620
14764
  column.st = columStartIndex + 1;
14621
14765
  column.ed = preLineStartIndex >= column.st ? preLineStartIndex : column.st;
14622
14766
  column.height = columnHeight;
14623
- column.width = maxColumnWidth;
14624
- sectionWidth += maxColumnWidth;
14767
+ const measuredColumnWidth = shouldUseLayoutColumnWidth && Number.isFinite(column.width) && column.width > 0 ? column.width : maxColumnWidth;
14768
+ column.width = measuredColumnWidth;
14769
+ sectionWidth += measuredColumnWidth;
14625
14770
  maxSectionHeight = Math.max(maxSectionHeight, column.height);
14626
14771
  preColumnStartIndex = column.ed;
14627
14772
  }
@@ -14636,6 +14781,10 @@ function updateBlockIndex(pages, start = -1) {
14636
14781
  const { ed } = table;
14637
14782
  preSectionStartIndex = Math.max(preSectionStartIndex, ed);
14638
14783
  }
14784
+ for (const columnGroup of skeColumnGroups.values()) {
14785
+ const { ed } = columnGroup;
14786
+ preSectionStartIndex = Math.max(preSectionStartIndex, ed);
14787
+ }
14639
14788
  page.st = pageStartIndex + 1;
14640
14789
  page.ed = preSectionStartIndex >= page.st ? preSectionStartIndex : page.st;
14641
14790
  page.height = contentHeight;
@@ -14643,6 +14792,28 @@ function updateBlockIndex(pages, start = -1) {
14643
14792
  prePageStartIndex = page.ed;
14644
14793
  }
14645
14794
  }
14795
+ function collapseRedundantColumnBreakOverflow(section) {
14796
+ var _targetColumn$height;
14797
+ const expectedColumnCount = section.colCount || section.columns.length;
14798
+ if (expectedColumnCount <= 0 || section.columns.length <= expectedColumnCount) return;
14799
+ const targetColumn = section.columns[expectedColumnCount - 1];
14800
+ if (!targetColumn) return;
14801
+ const overflowColumns = section.columns.slice(expectedColumnCount);
14802
+ if (!overflowColumns.some((column) => column.lines.length > 0)) return;
14803
+ const targetHeight = (_targetColumn$height = targetColumn.height) !== null && _targetColumn$height !== void 0 ? _targetColumn$height : 0;
14804
+ const overflowLines = overflowColumns.flatMap((column) => column.lines);
14805
+ overflowLines.forEach((line) => {
14806
+ line.top += targetHeight;
14807
+ line.parent = targetColumn;
14808
+ });
14809
+ targetColumn.lines.push(...overflowLines);
14810
+ targetColumn.height = Math.max(...overflowColumns.map((column) => {
14811
+ var _column$height;
14812
+ return targetHeight + ((_column$height = column.height) !== null && _column$height !== void 0 ? _column$height : 0);
14813
+ }), targetHeight);
14814
+ targetColumn.isFull = overflowColumns.some((column) => column.isFull);
14815
+ section.columns.splice(expectedColumnCount);
14816
+ }
14646
14817
  function updateInlineDrawingCoordsAndBorder(ctx, pages) {
14647
14818
  lineIterator(pages, (line, _, __, page) => {
14648
14819
  var _ctx$paragraphConfigC, _ctx$skeletonResource, _paragraphStyle$shadi;
@@ -14694,6 +14865,294 @@ function lineIterator(pagesOrCells, cb) {
14694
14865
  }
14695
14866
  }
14696
14867
  }
14868
+ function documentSkeletonTableIterator(pages, options = {}) {
14869
+ const { docsLeft = 0, docsTop = 0, pageMarginTop = 0, resolveViewport = true, skeFooters, skeHeaders, tableCellInsetX = 0, unitId = "" } = options;
14870
+ const contexts = [];
14871
+ pages.forEach((rootPage, pageIndex) => {
14872
+ var _skeHeaders$get, _skeFooters$get, _rootPage$skeColumnGr;
14873
+ const rootPageTop = ((rootPage.pageHeight === Infinity ? 0 : rootPage.pageHeight) + pageMarginTop) * pageIndex + rootPage.marginTop + docsTop;
14874
+ const rootPageLeft = rootPage.marginLeft + docsLeft;
14875
+ collectPageTables({
14876
+ contexts,
14877
+ docsLeft,
14878
+ page: rootPage,
14879
+ pageIndex,
14880
+ pageLeft: rootPageLeft,
14881
+ pageTop: rootPageTop,
14882
+ rootPage,
14883
+ source: "page",
14884
+ resolveViewport,
14885
+ tableCellInsetX,
14886
+ unitId
14887
+ });
14888
+ const rootPageDocumentTop = rootPageTop - rootPage.marginTop;
14889
+ const rootPageDocumentLeft = docsLeft + rootPage.marginLeft;
14890
+ const headerPage = rootPage.headerId == null ? void 0 : skeHeaders === null || skeHeaders === void 0 || (_skeHeaders$get = skeHeaders.get(rootPage.headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(rootPage.pageWidth);
14891
+ if (headerPage != null) collectPageTables({
14892
+ contexts,
14893
+ docsLeft,
14894
+ page: headerPage,
14895
+ pageIndex,
14896
+ pageLeft: rootPageDocumentLeft,
14897
+ pageTop: rootPageDocumentTop + headerPage.marginTop,
14898
+ rootPage,
14899
+ source: "header",
14900
+ resolveViewport,
14901
+ tableCellInsetX,
14902
+ unitId
14903
+ });
14904
+ const footerPage = rootPage.footerId == null ? void 0 : skeFooters === null || skeFooters === void 0 || (_skeFooters$get = skeFooters.get(rootPage.footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(rootPage.pageWidth);
14905
+ if (footerPage != null) collectPageTables({
14906
+ contexts,
14907
+ docsLeft,
14908
+ page: footerPage,
14909
+ pageIndex,
14910
+ pageLeft: rootPageDocumentLeft,
14911
+ pageTop: rootPageDocumentTop + rootPage.pageHeight - footerPage.height - footerPage.marginBottom,
14912
+ rootPage,
14913
+ source: "footer",
14914
+ resolveViewport,
14915
+ tableCellInsetX,
14916
+ unitId
14917
+ });
14918
+ (_rootPage$skeColumnGr = rootPage.skeColumnGroups) === null || _rootPage$skeColumnGr === void 0 || _rootPage$skeColumnGr.forEach((columnGroup) => {
14919
+ columnGroup.columns.forEach((columnGroupColumn) => {
14920
+ const nestedPage = columnGroupColumn.page;
14921
+ collectPageTables({
14922
+ contexts,
14923
+ docsLeft,
14924
+ page: nestedPage,
14925
+ pageIndex,
14926
+ pageLeft: rootPageLeft + columnGroup.left + columnGroupColumn.left + nestedPage.marginLeft,
14927
+ pageTop: rootPageTop + columnGroup.top + columnGroupColumn.top + nestedPage.marginTop,
14928
+ rootPage,
14929
+ source: "column",
14930
+ resolveViewport,
14931
+ tableCellInsetX,
14932
+ unitId
14933
+ });
14934
+ });
14935
+ });
14936
+ });
14937
+ return contexts;
14938
+ }
14939
+ function documentSkeletonLineIterator(pages, options, cb) {
14940
+ const { docsLeft = 0, pageMarginTop = 0, tableCellInsetX = 0, unitId = "" } = options;
14941
+ pages.forEach((page, pageIndex) => {
14942
+ var _page$skeTables, _page$skeColumnGroups;
14943
+ const pageTop = ((page.pageHeight === Infinity ? 0 : page.pageHeight) + pageMarginTop) * pageIndex + page.marginTop;
14944
+ const pageLeft = page.marginLeft;
14945
+ visitPageLines(page, {
14946
+ pageIndex,
14947
+ pageLeft,
14948
+ pageTop,
14949
+ source: "page",
14950
+ getBounds: (linePage, column, section) => getPageLineBounds(linePage, column, section.columns.length, pageLeft)
14951
+ }, cb);
14952
+ (_page$skeTables = page.skeTables) === null || _page$skeTables === void 0 || _page$skeTables.forEach((table) => {
14953
+ const viewport = getDocsTableRenderViewport(unitId, getSourceTableId(table.tableId));
14954
+ const hasHorizontalViewport = hasDocsTableHorizontalViewport(viewport);
14955
+ const tableViewportLeft = getTableViewportLeft(pageLeft, table.left, viewport, docsLeft);
14956
+ const tableViewportRight = tableViewportLeft + (hasHorizontalViewport ? viewport.viewportWidth : table.width);
14957
+ const tableScrollLeft = hasHorizontalViewport ? viewport.scrollLeft : 0;
14958
+ table.rows.forEach((row) => {
14959
+ row.cells.forEach((cell) => {
14960
+ const cellTop = pageTop + table.top + row.top + cell.marginTop;
14961
+ const cellLeft = pageLeft + table.left + cell.left - tableScrollLeft + cell.marginLeft;
14962
+ const cellContentRight = cellLeft + cell.pageWidth - cell.marginLeft - cell.marginRight;
14963
+ const visualLeft = cellLeft + tableCellInsetX;
14964
+ const visualRight = cellContentRight - tableCellInsetX;
14965
+ const visualWidth = Math.max(0, visualRight - visualLeft);
14966
+ const clipLeft = tableViewportLeft;
14967
+ const clipRight = Math.min(cellContentRight, tableViewportRight);
14968
+ if (visualWidth <= 0 || Math.min(visualRight, clipRight) <= Math.max(visualLeft, clipLeft)) return;
14969
+ visitPageLines(cell, {
14970
+ clipLeft,
14971
+ clipRight,
14972
+ pageIndex,
14973
+ pageLeft: cellLeft,
14974
+ pageTop: cellTop,
14975
+ source: "table-cell",
14976
+ visualLeft,
14977
+ visualWidth
14978
+ }, cb);
14979
+ });
14980
+ });
14981
+ });
14982
+ (_page$skeColumnGroups = page.skeColumnGroups) === null || _page$skeColumnGroups === void 0 || _page$skeColumnGroups.forEach((columnGroup) => {
14983
+ columnGroup.columns.forEach((columnGroupColumn) => {
14984
+ const nestedPage = columnGroupColumn.page;
14985
+ const nestedPageLeft = pageLeft + columnGroup.left + columnGroupColumn.left + nestedPage.marginLeft;
14986
+ const nestedPageTop = pageTop + columnGroup.top + columnGroupColumn.top + nestedPage.marginTop;
14987
+ const visualWidth = Math.max(0, columnGroupColumn.width - nestedPage.marginLeft - nestedPage.marginRight);
14988
+ visitPageLines(nestedPage, {
14989
+ pageIndex,
14990
+ pageLeft: nestedPageLeft,
14991
+ pageTop: nestedPageTop,
14992
+ source: "column",
14993
+ getBounds: (_linePage, column) => ({
14994
+ lineWidth: Math.max(getFiniteWidth(column.width), visualWidth - column.left),
14995
+ visualLeft: nestedPageLeft + column.left,
14996
+ visualWidth: Math.max(getFiniteWidth(column.width), visualWidth - column.left)
14997
+ })
14998
+ }, cb);
14999
+ });
15000
+ });
15001
+ });
15002
+ }
15003
+ function getDocumentSkeletonNestedPageOffset(page) {
15004
+ var _parent$parent, _parent$parent$column;
15005
+ const parent = page.parent;
15006
+ if ((parent === null || parent === void 0 ? void 0 : parent.page) === page && ((_parent$parent = parent.parent) === null || _parent$parent === void 0 ? void 0 : _parent$parent.columnGroupId) && ((_parent$parent$column = parent.parent.columns) === null || _parent$parent$column === void 0 ? void 0 : _parent$parent$column.includes(parent))) {
15007
+ var _parent$parent$left, _parent$left, _parent$parent$top, _parent$top;
15008
+ return {
15009
+ left: ((_parent$parent$left = parent.parent.left) !== null && _parent$parent$left !== void 0 ? _parent$parent$left : 0) + ((_parent$left = parent.left) !== null && _parent$left !== void 0 ? _parent$left : 0),
15010
+ top: ((_parent$parent$top = parent.parent.top) !== null && _parent$parent$top !== void 0 ? _parent$parent$top : 0) + ((_parent$top = parent.top) !== null && _parent$top !== void 0 ? _parent$top : 0)
15011
+ };
15012
+ }
15013
+ }
15014
+ function getDocumentSkeletonColumnPagePathInfo(position) {
15015
+ var _path$indexOf, _path$indexOf2, _path$indexOf3;
15016
+ const { path } = position;
15017
+ const pagesIndex = (_path$indexOf = path === null || path === void 0 ? void 0 : path.indexOf("pages")) !== null && _path$indexOf !== void 0 ? _path$indexOf : -1;
15018
+ const columnGroupIndex = (_path$indexOf2 = path === null || path === void 0 ? void 0 : path.indexOf("skeColumnGroups")) !== null && _path$indexOf2 !== void 0 ? _path$indexOf2 : -1;
15019
+ const columnsIndex = (_path$indexOf3 = path === null || path === void 0 ? void 0 : path.indexOf("columns")) !== null && _path$indexOf3 !== void 0 ? _path$indexOf3 : -1;
15020
+ if (pagesIndex === -1 || columnGroupIndex === -1 || columnsIndex === -1 || (path === null || path === void 0 ? void 0 : path[columnsIndex + 2]) !== "page") return;
15021
+ const pageIndex = path === null || path === void 0 ? void 0 : path[pagesIndex + 1];
15022
+ const columnGroupId = path === null || path === void 0 ? void 0 : path[columnGroupIndex + 1];
15023
+ const columnIndex = path === null || path === void 0 ? void 0 : path[columnsIndex + 1];
15024
+ if (typeof pageIndex !== "number" || typeof columnGroupId !== "string" || typeof columnIndex !== "number") return;
15025
+ return {
15026
+ columnGroupId,
15027
+ columnIndex,
15028
+ pageIndex
15029
+ };
15030
+ }
15031
+ function compareDocumentSkeletonNestedPagePathOrder(pos1, pos2) {
15032
+ const columnGroupOrder1 = getDocumentSkeletonColumnPagePathInfo(pos1);
15033
+ const columnGroupOrder2 = getDocumentSkeletonColumnPagePathInfo(pos2);
15034
+ if (columnGroupOrder1 && columnGroupOrder2 && columnGroupOrder1.pageIndex === columnGroupOrder2.pageIndex && columnGroupOrder1.columnGroupId === columnGroupOrder2.columnGroupId && columnGroupOrder1.columnIndex !== columnGroupOrder2.columnIndex) return columnGroupOrder1.columnIndex < columnGroupOrder2.columnIndex;
15035
+ }
15036
+ function visitPageLines(page, options, cb) {
15037
+ page.sections.forEach((section) => {
15038
+ section.columns.forEach((column) => {
15039
+ column.lines.forEach((line) => {
15040
+ var _options$getBounds, _ref, _bounds$lineWidth, _bounds$visualLeft, _bounds$visualWidth;
15041
+ const bounds = (_options$getBounds = options.getBounds) === null || _options$getBounds === void 0 ? void 0 : _options$getBounds.call(options, page, column, section);
15042
+ cb({
15043
+ clipLeft: options.clipLeft,
15044
+ clipRight: options.clipRight,
15045
+ column,
15046
+ line,
15047
+ lineWidth: (_ref = (_bounds$lineWidth = bounds === null || bounds === void 0 ? void 0 : bounds.lineWidth) !== null && _bounds$lineWidth !== void 0 ? _bounds$lineWidth : bounds === null || bounds === void 0 ? void 0 : bounds.visualWidth) !== null && _ref !== void 0 ? _ref : getFiniteWidth(column.width),
15048
+ page,
15049
+ pageIndex: options.pageIndex,
15050
+ pageLeft: options.pageLeft,
15051
+ section,
15052
+ sectionTop: options.pageTop + section.top,
15053
+ source: options.source,
15054
+ visualLeft: (_bounds$visualLeft = bounds === null || bounds === void 0 ? void 0 : bounds.visualLeft) !== null && _bounds$visualLeft !== void 0 ? _bounds$visualLeft : options.visualLeft,
15055
+ visualWidth: (_bounds$visualWidth = bounds === null || bounds === void 0 ? void 0 : bounds.visualWidth) !== null && _bounds$visualWidth !== void 0 ? _bounds$visualWidth : options.visualWidth
15056
+ });
15057
+ });
15058
+ });
15059
+ });
15060
+ }
15061
+ function getPageLineBounds(page, column, columnCount, pageLeft) {
15062
+ if (columnCount !== 1 || !Number.isFinite(page.pageWidth)) return;
15063
+ const visualLeft = pageLeft + column.left;
15064
+ const visualRight = page.pageWidth - page.marginRight;
15065
+ const visualWidth = Math.max(0, visualRight - visualLeft);
15066
+ const lineWidth = Math.max(0, page.pageWidth - page.marginLeft - page.marginRight);
15067
+ return visualWidth > 0 ? {
15068
+ lineWidth,
15069
+ visualLeft,
15070
+ visualWidth
15071
+ } : void 0;
15072
+ }
15073
+ function collectPageTables(options) {
15074
+ var _page$skeTables2;
15075
+ const { contexts, docsLeft, page, pageIndex, pageLeft, pageTop, resolveViewport, rootPage, source, tableCellInsetX, unitId } = options;
15076
+ (_page$skeTables2 = page.skeTables) === null || _page$skeTables2 === void 0 || _page$skeTables2.forEach((table, tableId) => {
15077
+ var _table$tableId;
15078
+ const effectiveTableId = (_table$tableId = table.tableId) !== null && _table$tableId !== void 0 ? _table$tableId : tableId;
15079
+ const tableLeft = pageLeft + table.left;
15080
+ const tableTop = pageTop + table.top;
15081
+ const sourceTableId = getSourceTableId(effectiveTableId);
15082
+ const viewport = resolveViewport ? getDocsTableRenderViewport(unitId, sourceTableId) : null;
15083
+ const hasHorizontalViewport = hasDocsTableHorizontalViewport(viewport);
15084
+ const tableViewportLeft = getTableViewportLeft(pageLeft, table.left, viewport, docsLeft);
15085
+ const tableViewportRight = tableViewportLeft + (hasHorizontalViewport ? viewport.viewportWidth : table.width);
15086
+ const tableScrollLeft = hasHorizontalViewport ? viewport.scrollLeft : 0;
15087
+ const cells = [];
15088
+ table.rows.forEach((row, rowIndex) => {
15089
+ row.cells.forEach((cell, columnIndex) => {
15090
+ var _cell$marginLeft, _cell$marginRight, _cell$marginTop, _cell$marginBottom, _cell$pageWidth, _cell$pageHeight, _row$top, _cell$left;
15091
+ if (cell.isMergedCellCovered) return;
15092
+ const cellMarginLeft = (_cell$marginLeft = cell.marginLeft) !== null && _cell$marginLeft !== void 0 ? _cell$marginLeft : 0;
15093
+ const cellMarginRight = (_cell$marginRight = cell.marginRight) !== null && _cell$marginRight !== void 0 ? _cell$marginRight : 0;
15094
+ const cellMarginTop = (_cell$marginTop = cell.marginTop) !== null && _cell$marginTop !== void 0 ? _cell$marginTop : 0;
15095
+ const cellMarginBottom = (_cell$marginBottom = cell.marginBottom) !== null && _cell$marginBottom !== void 0 ? _cell$marginBottom : 0;
15096
+ const cellPageWidth = (_cell$pageWidth = cell.pageWidth) !== null && _cell$pageWidth !== void 0 ? _cell$pageWidth : 0;
15097
+ const cellPageHeight = (_cell$pageHeight = cell.pageHeight) !== null && _cell$pageHeight !== void 0 ? _cell$pageHeight : 0;
15098
+ const cellTop = tableTop + ((_row$top = row.top) !== null && _row$top !== void 0 ? _row$top : 0) + cellMarginTop;
15099
+ const cellLeft = tableLeft + ((_cell$left = cell.left) !== null && _cell$left !== void 0 ? _cell$left : 0) - tableScrollLeft + cellMarginLeft;
15100
+ const cellContentRight = cellLeft + cellPageWidth - cellMarginLeft - cellMarginRight;
15101
+ const visualLeft = cellLeft + tableCellInsetX;
15102
+ const visualRight = cellContentRight - tableCellInsetX;
15103
+ const visualWidth = Math.max(0, visualRight - visualLeft);
15104
+ const clipLeft = tableViewportLeft;
15105
+ const clipRight = Math.min(cellContentRight, tableViewportRight);
15106
+ if (visualWidth <= 0 || Math.min(visualRight, clipRight) <= Math.max(visualLeft, clipLeft)) return;
15107
+ cells.push({
15108
+ cell,
15109
+ cellRect: {
15110
+ bottom: cellTop + cellPageHeight - cellMarginBottom - cellMarginTop,
15111
+ left: Math.max(cellLeft, tableViewportLeft),
15112
+ right: Math.min(cellContentRight, tableViewportRight),
15113
+ top: cellTop
15114
+ },
15115
+ clipLeft,
15116
+ clipRight,
15117
+ columnIndex,
15118
+ pageLeft: cellLeft,
15119
+ pageTop: cellTop,
15120
+ row,
15121
+ rowIndex,
15122
+ visualLeft,
15123
+ visualWidth
15124
+ });
15125
+ });
15126
+ });
15127
+ contexts.push({
15128
+ cells,
15129
+ page,
15130
+ pageIndex,
15131
+ pageLeft,
15132
+ pageTop,
15133
+ rootPage,
15134
+ source,
15135
+ table,
15136
+ tableId: effectiveTableId,
15137
+ tableRect: {
15138
+ bottom: tableTop + table.height,
15139
+ left: tableLeft,
15140
+ right: tableLeft + table.width,
15141
+ top: tableTop
15142
+ }
15143
+ });
15144
+ });
15145
+ }
15146
+ function getTableViewportLeft(pageLeft, tableLeft, viewport, docsLeft) {
15147
+ const viewportLeft = viewport === null || viewport === void 0 ? void 0 : viewport.viewportLeft;
15148
+ return viewportLeft != null ? viewportLeft - docsLeft : pageLeft + tableLeft;
15149
+ }
15150
+ function getSourceTableId(tableId) {
15151
+ return tableId.includes("#-#") ? tableId.split("#-#")[0] : tableId;
15152
+ }
15153
+ function getFiniteWidth(width) {
15154
+ return Number.isFinite(width) ? width : 0;
15155
+ }
14697
15156
  function columnIterator(pages, iteratorFunction) {
14698
15157
  for (const page of pages) {
14699
15158
  const { sections } = page;
@@ -14716,7 +15175,14 @@ function getPositionHorizon(positionH, column, page, objectWidth, isPageBreak =
14716
15175
  else if (align === AlignTypeH.CENTER) absoluteLeft = left + width / 2 - objectWidth / 2;
14717
15176
  return absoluteLeft;
14718
15177
  }
14719
- if (relativeFrom === ObjectRelativeFromH.LEFT_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.RIGHT_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.INSIDE_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.OUTSIDE_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.PAGE) {
15178
+ if (relativeFrom === ObjectRelativeFromH.LEFT_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.MARGIN) {
15179
+ const { pageWidth, marginLeft, marginRight } = page;
15180
+ const marginWidth = pageWidth - marginLeft - marginRight;
15181
+ let absoluteLeft = marginLeft;
15182
+ if (align === AlignTypeH.RIGHT) absoluteLeft = marginLeft + marginWidth - objectWidth;
15183
+ else if (align === AlignTypeH.CENTER) absoluteLeft = marginLeft + marginWidth / 2 - objectWidth / 2;
15184
+ return absoluteLeft;
15185
+ } else if (relativeFrom === ObjectRelativeFromH.RIGHT_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.INSIDE_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.OUTSIDE_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.PAGE) {
14720
15186
  const { pageWidth } = page;
14721
15187
  let absoluteLeft = 0;
14722
15188
  if (align === AlignTypeH.RIGHT) absoluteLeft = pageWidth - objectWidth;
@@ -14990,13 +15456,22 @@ function getPageFromPath(skeletonData, path) {
14990
15456
  const pageIndex = pathCopy.shift();
14991
15457
  page = skeletonData.pages[pageIndex];
14992
15458
  } else if (field === "skeTables") {
14993
- var _skeTables;
15459
+ var _page$skeTables3;
15460
+ if (page == null) return null;
14994
15461
  const tableId = pathCopy.shift();
14995
15462
  pathCopy.shift();
14996
15463
  const rowIndex = pathCopy.shift();
14997
15464
  pathCopy.shift();
14998
15465
  const cellIndex = pathCopy.shift();
14999
- page = (_skeTables = page.skeTables) === null || _skeTables === void 0 || (_skeTables = _skeTables.get(tableId)) === null || _skeTables === void 0 || (_skeTables = _skeTables.rows[rowIndex]) === null || _skeTables === void 0 ? void 0 : _skeTables.cells[cellIndex];
15466
+ page = (_page$skeTables3 = page.skeTables) === null || _page$skeTables3 === void 0 || (_page$skeTables3 = _page$skeTables3.get(tableId)) === null || _page$skeTables3 === void 0 || (_page$skeTables3 = _page$skeTables3.rows[rowIndex]) === null || _page$skeTables3 === void 0 ? void 0 : _page$skeTables3.cells[cellIndex];
15467
+ } else if (field === "skeColumnGroups") {
15468
+ var _page$skeColumnGroups2;
15469
+ if (page == null) return null;
15470
+ const columnGroupId = pathCopy.shift();
15471
+ pathCopy.shift();
15472
+ const columnIndex = pathCopy.shift();
15473
+ pathCopy.shift();
15474
+ page = (_page$skeColumnGroups2 = page.skeColumnGroups) === null || _page$skeColumnGroups2 === void 0 || (_page$skeColumnGroups2 = _page$skeColumnGroups2.get(columnGroupId)) === null || _page$skeColumnGroups2 === void 0 || (_page$skeColumnGroups2 = _page$skeColumnGroups2.columns[columnIndex]) === null || _page$skeColumnGroups2 === void 0 ? void 0 : _page$skeColumnGroups2.page;
15000
15475
  }
15001
15476
  }
15002
15477
  return page;
@@ -15063,8 +15538,8 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
15063
15538
  }
15064
15539
  page.originMarginTop = marginTop;
15065
15540
  page.originMarginBottom = marginBottom;
15066
- page.marginTop = _getVerticalMargin(marginTop, header, pageHeight);
15067
- page.marginBottom = _getVerticalMargin(marginBottom, footer, pageHeight);
15541
+ page.marginTop = _getVerticalMargin(marginTop, header);
15542
+ page.marginBottom = _getVerticalMargin(marginBottom, footer);
15068
15543
  const sections = page.sections;
15069
15544
  const lastSection = sections[sections.length - 1];
15070
15545
  const { marginTop: curPageMT, marginBottom: curPageMB, marginLeft: curPageML, marginRight: curPageMR } = page;
@@ -15103,11 +15578,13 @@ function _getNullPage(type = 0, segmentId = "") {
15103
15578
  ed: 0,
15104
15579
  skeDrawings: /* @__PURE__ */ new Map(),
15105
15580
  skeTables: /* @__PURE__ */ new Map(),
15581
+ skeColumnGroups: /* @__PURE__ */ new Map(),
15106
15582
  type,
15107
15583
  segmentId
15108
15584
  };
15109
15585
  }
15110
15586
  function _createSkeletonHeaderFooter(ctx, headerOrFooterViewModel, sectionBreakConfig, skeletonResourceReference, segmentId, isHeader = true, areaPage, count = 0) {
15587
+ var _sectionBreakConfig$d;
15111
15588
  const { lists, footerTreeMap, headerTreeMap, localeService, pageSize, drawings, marginLeft = 0, marginRight = 0, marginHeader = 0, marginFooter = 0 } = sectionBreakConfig;
15112
15589
  const pageWidth = (pageSize === null || pageSize === void 0 ? void 0 : pageSize.width) || Number.POSITIVE_INFINITY;
15113
15590
  const pageHeight = (pageSize === null || pageSize === void 0 ? void 0 : pageSize.height) || Number.POSITIVE_INFINITY;
@@ -15135,7 +15612,7 @@ function _createSkeletonHeaderFooter(ctx, headerOrFooterViewModel, sectionBreakC
15135
15612
  resetContext(ctx);
15136
15613
  return _createSkeletonHeaderFooter(ctx, headerOrFooterViewModel, sectionBreakConfig, skeletonResourceReference, segmentId, isHeader, areaPage, count);
15137
15614
  }
15138
- updateBlockIndex([page]);
15615
+ updateBlockIndex([page], -1, (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy());
15139
15616
  if (isHeader) Object.assign(page, {
15140
15617
  marginTop: marginHeader,
15141
15618
  marginBottom: 5
@@ -15196,7 +15673,7 @@ function createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, avai
15196
15673
  };
15197
15674
  }
15198
15675
  function createSkeletonCellPages(ctx, viewModel, cellNode, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY) {
15199
- var _ctx$dataModel, _ctx$dataModel$getBod;
15676
+ var _sectionBreakConfig$d2, _ctx$dataModel, _ctx$dataModel$getBod;
15200
15677
  const sectionNode = cellNode.children[0];
15201
15678
  const { page: areaPage, sectionBreakConfig: cellSectionBreakConfig } = createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, availableHeight, maxCellPageHeight);
15202
15679
  const { pages } = dealWithSection(ctx, viewModel, sectionNode, areaPage, cellSectionBreakConfig);
@@ -15204,8 +15681,8 @@ function createSkeletonCellPages(ctx, viewModel, cellNode, sectionBreakConfig, t
15204
15681
  p.type = 3;
15205
15682
  p.segmentId = tableConfig.tableId;
15206
15683
  }
15207
- updateBlockIndex(pages, cellNode.startIndex);
15208
- 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);
15684
+ updateBlockIndex(pages, cellNode.startIndex, (_sectionBreakConfig$d2 = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d2 !== void 0 ? _sectionBreakConfig$d2 : getDocumentCompatibilityPolicy());
15685
+ applyTrailingBlockRangeSpaceBelow(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);
15209
15686
  updateInlineDrawingCoordsAndBorder(ctx, pages);
15210
15687
  expandCellPageHeightForInlineDrawings(pages);
15211
15688
  return pages;
@@ -15221,7 +15698,7 @@ function expandCellPageHeightForInlineDrawings(pages) {
15221
15698
  });
15222
15699
  }
15223
15700
  }
15224
- function applyTrailingCellBlockRangeSpaceBelow(pages, body, cellEndIndex) {
15701
+ function applyTrailingBlockRangeSpaceBelow(pages, body, containerEndIndex) {
15225
15702
  const blockRanges = body === null || body === void 0 ? void 0 : body.blockRanges;
15226
15703
  const trailingBlockRangeSpace = 28;
15227
15704
  if (!(blockRanges === null || blockRanges === void 0 ? void 0 : blockRanges.length)) return;
@@ -15231,12 +15708,14 @@ function applyTrailingCellBlockRangeSpaceBelow(pages, body, cellEndIndex) {
15231
15708
  if (!lastLine) continue;
15232
15709
  const paragraphIndex = lastLine.paragraphIndex;
15233
15710
  if (!blockRanges.some((range) => range.startIndex < paragraphIndex && paragraphIndex < range.endIndex)) continue;
15234
- 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;
15711
+ 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 < containerEndIndex)) continue;
15235
15712
  page.height += lastLine.spaceBelowApply || trailingBlockRangeSpace;
15236
15713
  }
15237
15714
  }
15238
- function _getVerticalMargin(marginTB, _headerOrFooter, _pageHeight) {
15239
- return marginTB;
15715
+ function _getVerticalMargin(marginTB, headerOrFooter) {
15716
+ if (headerOrFooter == null) return marginTB;
15717
+ const { marginTop = 0, height = 0, marginBottom = 0 } = headerOrFooter;
15718
+ return Math.max(marginTB, marginTop + height + marginBottom);
15240
15719
  }
15241
15720
 
15242
15721
  //#endregion
@@ -15343,6 +15822,15 @@ function adjustGlyphsInDivide(divide, justificationRatio, extraJustification) {
15343
15822
  }
15344
15823
  setGlyphGroupLeft(divide.glyphGroup);
15345
15824
  }
15825
+ function distributeGlyphsInDivide(divide, remaining) {
15826
+ if (remaining <= 0) return false;
15827
+ const visibleGlyphs = divide.glyphGroup.filter((glyph) => glyph.content !== "" && glyph.width > 0);
15828
+ if (visibleGlyphs.length < 2) return false;
15829
+ const extraGap = remaining / (visibleGlyphs.length - 1);
15830
+ for (let i = 0; i < visibleGlyphs.length - 1; i++) visibleGlyphs[i].width += extraGap;
15831
+ setGlyphGroupLeft(divide.glyphGroup);
15832
+ return true;
15833
+ }
15346
15834
  /**
15347
15835
  * When aligning text horizontally within a document,
15348
15836
  * it may be ineffective if the total line width is not initially calculated.
@@ -15408,7 +15896,13 @@ function horizontalAlignHandler(line, horizontalAlign, allowOverflowHorizontalOf
15408
15896
  }
15409
15897
  }
15410
15898
  const inkBounds = allowOverflowHorizontalOffset ? getGlyphGroupInkBounds(divide) : null;
15411
- if (horizontalAlign === HorizontalAlign.CENTER && inkBounds) divide.paddingLeft = width / 2 - (inkBounds.left + inkBounds.right) / 2;
15899
+ if (horizontalAlign === HorizontalAlign.DISTRIBUTED) {
15900
+ if (distributeGlyphsInDivide(divide, width - glyphGroupWidth)) {
15901
+ glyphGroupWidth = getGlyphGroupWidth(divide);
15902
+ divide.glyphGroupWidth = glyphGroupWidth;
15903
+ }
15904
+ divide.paddingLeft = 0;
15905
+ } else if (horizontalAlign === HorizontalAlign.CENTER && inkBounds) divide.paddingLeft = width / 2 - (inkBounds.left + inkBounds.right) / 2;
15412
15906
  else if (horizontalAlign === HorizontalAlign.RIGHT && inkBounds) divide.paddingLeft = width - inkBounds.right;
15413
15907
  else if (horizontalAlign === HorizontalAlign.CENTER) divide.paddingLeft = (width - glyphGroupWidth) / 2;
15414
15908
  else if (horizontalAlign === HorizontalAlign.RIGHT) divide.paddingLeft = width - glyphGroupWidth;
@@ -15680,6 +16174,14 @@ function _isMarkedDocxColumnBreak(viewModel, absoluteIndex) {
15680
16174
  function _glyphCount(glyphs) {
15681
16175
  return glyphs.reduce((count, glyph) => count + glyph.count, 0);
15682
16176
  }
16177
+ function _isDocxColumnBreakVisuallyBlankColumn(column) {
16178
+ return column.lines.every((line) => line.divides.every((divide) => divide.glyphGroup.every((glyph) => {
16179
+ const { glyphType, raw, streamType, width } = glyph;
16180
+ const isParagraphMark = raw === DataStreamTreeTokenType.PARAGRAPH || streamType === DataStreamTreeTokenType.PARAGRAPH;
16181
+ const isColumnBreak = width === 0 && (raw === DataStreamTreeTokenType.COLUMN_BREAK || streamType === DataStreamTreeTokenType.COLUMN_BREAK);
16182
+ return glyphType === 4 || glyphType === 2 || isParagraphMark || isColumnBreak;
16183
+ })));
16184
+ }
15683
16185
  function _hasOnlyCustomBlockGlyphs(glyphs) {
15684
16186
  return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK);
15685
16187
  }
@@ -15736,7 +16238,9 @@ function _withMinSpacing(style, key, value) {
15736
16238
  };
15737
16239
  }
15738
16240
  function _getNextAdjacentBlockRange(blockRanges, blockRange) {
15739
- return blockRanges === null || blockRanges === void 0 ? void 0 : blockRanges.filter((range) => range.startIndex > blockRange.endIndex).sort((left, right) => left.startIndex - right.startIndex)[0];
16241
+ let nextBlockRange;
16242
+ for (const range of blockRanges !== null && blockRanges !== void 0 ? blockRanges : []) if (range.startIndex > blockRange.endIndex && (!nextBlockRange || range.startIndex < nextBlockRange.startIndex)) nextBlockRange = range;
16243
+ return nextBlockRange;
15740
16244
  }
15741
16245
  function _hasNextAdjacentLayoutBlockRange(blockRanges, blockRange) {
15742
16246
  const nextBlockRange = _getNextAdjacentBlockRange(blockRanges, blockRange);
@@ -15901,7 +16405,12 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
15901
16405
  const lastPage = allPages[allPages.length - 1];
15902
16406
  const columnInfo = getLastNotFullColumnInfo(lastPage);
15903
16407
  if (columnInfo && !columnInfo.isLast) setColumnFullState(columnInfo.column, true);
15904
- else allPages.push(createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, _getNextPageNumber(lastPage), 2));
16408
+ else if (columnInfo && columnInfo.isLast && isTraditionalDocumentCompatibility(documentCompatibilityPolicy) && (isBlankColumn(columnInfo.column) || _isDocxColumnBreakVisuallyBlankColumn(columnInfo.column))) {} else if (isTraditionalDocumentCompatibility(documentCompatibilityPolicy)) {
16409
+ var _getLastSection;
16410
+ const lastColumn = (_getLastSection = getLastSection(lastPage)) === null || _getLastSection === void 0 ? void 0 : _getLastSection.columns.at(-1);
16411
+ if (lastColumn && (isBlankColumn(lastColumn) || _isDocxColumnBreakVisuallyBlankColumn(lastColumn))) setColumnFullState(lastColumn, false);
16412
+ else allPages.push(createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, _getNextPageNumber(lastPage), 2));
16413
+ } else allPages.push(createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, _getNextPageNumber(lastPage), 2));
15905
16414
  shapedTextOffset += textGlyphCount;
15906
16415
  continue;
15907
16416
  }
@@ -16655,6 +17164,219 @@ function dealWidthParagraph(ctx, viewModel, paragraphNode, curPage, sectionBreak
16655
17164
  return allPages;
16656
17165
  }
16657
17166
 
17167
+ //#endregion
17168
+ //#region src/components/docs/layout/block/column.ts
17169
+ const EMPTY_COLUMN_GROUP_MIN_HEIGHT = 72;
17170
+ function createColumnGroupSkeleton(ctx, curPage, viewModel, columnGroupNode, sectionBreakConfig) {
17171
+ var _viewModel$getColumnG, _getLastNotFullColumn;
17172
+ const columnGroupSource = (_viewModel$getColumnG = viewModel.getColumnGroupByStartIndex(columnGroupNode.startIndex)) === null || _viewModel$getColumnG === void 0 ? void 0 : _viewModel$getColumnG.columnGroupSource;
17173
+ if (columnGroupSource == null) {
17174
+ console.warn("Column group not found when creating column group skeleton");
17175
+ return null;
17176
+ }
17177
+ const hostColumn = (_getLastNotFullColumn = getLastNotFullColumnInfo(curPage)) === null || _getLastNotFullColumn === void 0 ? void 0 : _getLastNotFullColumn.column;
17178
+ if (hostColumn == null) return null;
17179
+ const columnPages = columnGroupNode.children.map((columnNode, index) => {
17180
+ const sourceColumn = columnGroupSource.columns[index];
17181
+ return createColumnContentPage(ctx, viewModel, columnNode, sectionBreakConfig, Math.max(0, getInitialColumnWidth(columnGroupSource, sourceColumn, hostColumn.width)));
17182
+ });
17183
+ const columnHeights = columnPages.map((page) => Math.max(page.height, EMPTY_COLUMN_GROUP_MIN_HEIGHT));
17184
+ const layout = calculateColumnGroupLayout(columnGroupSource, hostColumn.width, columnHeights);
17185
+ const columns = layout.columns.map((layoutColumn, index) => {
17186
+ const page = columnPages[index];
17187
+ page.pageHeight = columnHeights[index];
17188
+ return {
17189
+ columnId: layoutColumn.columnId,
17190
+ left: layoutColumn.left,
17191
+ top: layoutColumn.top,
17192
+ width: layoutColumn.width,
17193
+ height: columnHeights[index],
17194
+ st: columnGroupNode.children[index].startIndex,
17195
+ ed: columnGroupNode.children[index].endIndex,
17196
+ page
17197
+ };
17198
+ });
17199
+ const columnGroupSkeleton = {
17200
+ columns,
17201
+ width: layout.width,
17202
+ height: layout.height,
17203
+ top: getNextBlockTop(hostColumn.lines),
17204
+ left: hostColumn.left,
17205
+ st: columnGroupNode.startIndex,
17206
+ ed: columnGroupNode.endIndex,
17207
+ columnGroupId: columnGroupSource.columnGroupId,
17208
+ columnGroupSource
17209
+ };
17210
+ columns.forEach((column) => {
17211
+ column.parent = columnGroupSkeleton;
17212
+ column.page.parent = column;
17213
+ });
17214
+ return columnGroupSkeleton;
17215
+ }
17216
+ function appendColumnGroupBlockLine(page, columnGroup) {
17217
+ const columnInfo = getLastNotFullColumnInfo(page);
17218
+ if (columnInfo == null) return false;
17219
+ const { column } = columnInfo;
17220
+ const line = createColumnGroupBlockLine(columnGroup, column.lines.length);
17221
+ line.parent = column;
17222
+ column.lines.push(line);
17223
+ page.skeColumnGroups.set(columnGroup.columnGroupId, columnGroup);
17224
+ columnGroup.parent = page;
17225
+ return true;
17226
+ }
17227
+ function createColumnContentPage(ctx, viewModel, columnNode, sectionBreakConfig, width) {
17228
+ var _sectionBreakConfig$d, _ctx$dataModel, _ctx$dataModel$getBod;
17229
+ const columnSectionBreakConfig = {
17230
+ ...sectionBreakConfig,
17231
+ pageSize: {
17232
+ width,
17233
+ height: Number.POSITIVE_INFINITY
17234
+ },
17235
+ marginTop: 0,
17236
+ marginBottom: 0,
17237
+ marginLeft: 0,
17238
+ marginRight: 0,
17239
+ columnProperties: []
17240
+ };
17241
+ const page = createSkeletonPage(ctx, columnSectionBreakConfig, ctx.skeletonResourceReference);
17242
+ page.type = 3;
17243
+ for (const paragraphNode of getColumnParagraphNodes(columnNode)) dealWidthParagraph(ctx, viewModel, paragraphNode, page, columnSectionBreakConfig);
17244
+ updateBlockIndex([page], columnNode.startIndex, (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy());
17245
+ applyTrailingBlockRangeSpaceBelow([page], (_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), columnNode.endIndex);
17246
+ return page;
17247
+ }
17248
+ function getColumnParagraphNodes(columnNode) {
17249
+ const firstChild = columnNode.children[0];
17250
+ if ((firstChild === null || firstChild === void 0 ? void 0 : firstChild.nodeType) === DataStreamTreeNodeType.SECTION_BREAK) return firstChild.children;
17251
+ return columnNode.children;
17252
+ }
17253
+ function createColumnGroupBlockLine(columnGroup, lineIndex) {
17254
+ const top = columnGroup.top;
17255
+ return {
17256
+ paragraphIndex: columnGroup.ed,
17257
+ type: 1,
17258
+ divides: [],
17259
+ divideLen: 0,
17260
+ lineHeight: columnGroup.height,
17261
+ contentHeight: columnGroup.height,
17262
+ top,
17263
+ asc: 0,
17264
+ dsc: 0,
17265
+ paddingTop: 0,
17266
+ paddingBottom: 0,
17267
+ marginTop: 0,
17268
+ marginBottom: 0,
17269
+ spaceBelowApply: 0,
17270
+ st: columnGroup.st,
17271
+ ed: columnGroup.ed,
17272
+ lineIndex,
17273
+ paragraphStart: true,
17274
+ isBehindTable: false,
17275
+ tableId: ""
17276
+ };
17277
+ }
17278
+ function getNextBlockTop(lines) {
17279
+ const lastLine = lines[lines.length - 1];
17280
+ if (lastLine == null) return 0;
17281
+ return lastLine.top + lastLine.lineHeight;
17282
+ }
17283
+ function calculateColumnGroupLayout(source, availableWidth, columnHeights) {
17284
+ var _source$gap$v, _source$gap;
17285
+ const width = Math.max(0, availableWidth);
17286
+ const gap = Math.max(0, (_source$gap$v = (_source$gap = source.gap) === null || _source$gap === void 0 ? void 0 : _source$gap.v) !== null && _source$gap$v !== void 0 ? _source$gap$v : 0);
17287
+ const columns = source.columns;
17288
+ if (columns.length === 0) return {
17289
+ mode: "horizontal",
17290
+ width,
17291
+ height: 0,
17292
+ columns: []
17293
+ };
17294
+ if (shouldStack(columns, width, gap, source.responsive)) {
17295
+ let top = 0;
17296
+ return {
17297
+ mode: "stack",
17298
+ width,
17299
+ height: sumHeights(columnHeights),
17300
+ columns: columns.map((column, index) => {
17301
+ var _columnHeights$index;
17302
+ const layoutColumn = {
17303
+ columnId: column.columnId,
17304
+ left: 0,
17305
+ top,
17306
+ width
17307
+ };
17308
+ top += Math.max(0, (_columnHeights$index = columnHeights[index]) !== null && _columnHeights$index !== void 0 ? _columnHeights$index : 0);
17309
+ return layoutColumn;
17310
+ })
17311
+ };
17312
+ }
17313
+ const widths = allocateHorizontalWidths(columns, Math.max(0, width - gap * (columns.length - 1)));
17314
+ let left = 0;
17315
+ return {
17316
+ mode: "horizontal",
17317
+ width,
17318
+ height: Math.max(0, ...columnHeights),
17319
+ columns: columns.map((column, index) => {
17320
+ const layoutColumn = {
17321
+ columnId: column.columnId,
17322
+ left,
17323
+ top: 0,
17324
+ width: widths[index]
17325
+ };
17326
+ left += widths[index] + gap;
17327
+ return layoutColumn;
17328
+ })
17329
+ };
17330
+ }
17331
+ function shouldStack(columns, availableWidth, gap, responsive) {
17332
+ if (responsive !== ColumnResponsiveType.STACK) return false;
17333
+ return columns.reduce((sum, column) => sum + getMinWidth(column), 0) + gap * Math.max(0, columns.length - 1) > availableWidth;
17334
+ }
17335
+ function getInitialColumnWidth(source, column, availableWidth) {
17336
+ var _source$gap$v2, _source$gap2;
17337
+ if (column == null) return availableWidth;
17338
+ const contentWidth = Math.max(0, availableWidth - Math.max(0, (_source$gap$v2 = (_source$gap2 = source.gap) === null || _source$gap2 === void 0 ? void 0 : _source$gap2.v) !== null && _source$gap$v2 !== void 0 ? _source$gap$v2 : 0) * Math.max(0, source.columns.length - 1));
17339
+ const ratioSum = source.columns.reduce((sum, item) => sum + Math.max(0, item.widthRatio || 0), 0) || source.columns.length;
17340
+ return Math.max(getMinWidth(column), contentWidth * (Math.max(0, column.widthRatio || 0) || 1) / ratioSum);
17341
+ }
17342
+ function allocateHorizontalWidths(columns, contentWidth) {
17343
+ const ratioSum = columns.reduce((sum, column) => sum + Math.max(0, column.widthRatio || 0), 0) || columns.length;
17344
+ const idealWidths = columns.map((column) => contentWidth * (Math.max(0, column.widthRatio || 0) || 1) / ratioSum);
17345
+ const minWidths = columns.map(getMinWidth);
17346
+ const widths = idealWidths.map((width, index) => Math.max(width, minWidths[index]));
17347
+ const overflow = widths.reduce((sum, width) => sum + width, 0) - contentWidth;
17348
+ if (overflow <= 0) return widths;
17349
+ return compressToFit(widths, minWidths, overflow);
17350
+ }
17351
+ function compressToFit(widths, minWidths, overflow) {
17352
+ const nextWidths = [...widths];
17353
+ let remainingOverflow = overflow;
17354
+ let flexibleIndexes = getFlexibleIndexes(nextWidths, minWidths);
17355
+ while (remainingOverflow > 0 && flexibleIndexes.length > 0) {
17356
+ const totalShrink = flexibleIndexes.reduce((sum, item) => sum + item.shrink, 0);
17357
+ for (const item of flexibleIndexes) {
17358
+ const shrink = Math.min(item.shrink, remainingOverflow * item.shrink / totalShrink);
17359
+ nextWidths[item.index] -= shrink;
17360
+ remainingOverflow -= shrink;
17361
+ }
17362
+ flexibleIndexes = getFlexibleIndexes(nextWidths, minWidths);
17363
+ }
17364
+ return nextWidths;
17365
+ }
17366
+ function getFlexibleIndexes(widths, minWidths) {
17367
+ return widths.map((width, index) => ({
17368
+ index,
17369
+ shrink: Math.max(0, width - minWidths[index])
17370
+ })).filter((item) => item.shrink > 0);
17371
+ }
17372
+ function getMinWidth(column) {
17373
+ var _column$minWidth$v, _column$minWidth;
17374
+ return Math.max(0, (_column$minWidth$v = (_column$minWidth = column.minWidth) === null || _column$minWidth === void 0 ? void 0 : _column$minWidth.v) !== null && _column$minWidth$v !== void 0 ? _column$minWidth$v : 0);
17375
+ }
17376
+ function sumHeights(heights) {
17377
+ return heights.reduce((sum, height) => sum + Math.max(0, height), 0);
17378
+ }
17379
+
16658
17380
  //#endregion
16659
17381
  //#region src/components/docs/layout/block/section.ts
16660
17382
  function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfig, layoutAnchor) {
@@ -16679,6 +17401,10 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
16679
17401
  if (ctx.paragraphsOpenNewPage.has(paragraphNode.endIndex)) currentPageCache = createSkeletonPage(ctx, sectionBreakConfig, ctx.skeletonResourceReference, currentPageCache.pageNumber + 1);
16680
17402
  skeletonPages = dealWidthParagraph(ctx, viewModel, paragraphNode, currentPageCache, sectionBreakConfig);
16681
17403
  }
17404
+ if (paragraphNode.nodeType === DataStreamTreeNodeType.COLUMN_GROUP) {
17405
+ const columnGroupSkeleton = createColumnGroupSkeleton(ctx, currentPageCache, viewModel, paragraphNode, sectionBreakConfig);
17406
+ if (columnGroupSkeleton && appendColumnGroupBlockLine(currentPageCache, columnGroupSkeleton)) skeletonPages = [currentPageCache];
17407
+ }
16682
17408
  if (skeletonPages.length === 0) skeletonPages = dealWithBlockError();
16683
17409
  _pushPage(allCurrentSkeletonPages, skeletonPages);
16684
17410
  if (ctx.isDirty) break;
@@ -17061,11 +17787,49 @@ function removeDupPages(ctx) {
17061
17787
  return !hasPage;
17062
17788
  });
17063
17789
  }
17790
+ function mergeContinuousDuplicatePages(pages) {
17791
+ for (let index = 1; index < pages.length;) {
17792
+ var _page$skeDrawings, _page$skeTables;
17793
+ const previousPage = pages[index - 1];
17794
+ const page = pages[index];
17795
+ if (previousPage.pageNumber !== page.pageNumber) {
17796
+ index++;
17797
+ continue;
17798
+ }
17799
+ const topOffset = previousPage.height;
17800
+ for (const section of page.sections) {
17801
+ section.top += topOffset;
17802
+ section.parent = previousPage;
17803
+ previousPage.sections.push(section);
17804
+ }
17805
+ (_page$skeDrawings = page.skeDrawings) === null || _page$skeDrawings === void 0 || _page$skeDrawings.forEach((drawing, drawingId) => {
17806
+ drawing.aTop += topOffset;
17807
+ previousPage.skeDrawings.set(drawingId, drawing);
17808
+ });
17809
+ (_page$skeTables = page.skeTables) === null || _page$skeTables === void 0 || _page$skeTables.forEach((table, tableId) => {
17810
+ table.top += topOffset;
17811
+ table.parent = previousPage;
17812
+ previousPage.skeTables.set(tableId, table);
17813
+ });
17814
+ previousPage.height += page.height;
17815
+ previousPage.width = Math.max(previousPage.width, page.width);
17816
+ previousPage.ed = Math.max(previousPage.ed, page.ed);
17817
+ pages.splice(index, 1);
17818
+ }
17819
+ }
17064
17820
  function getPagePath(page) {
17065
17821
  const path = [];
17066
17822
  let skeNode = page;
17067
17823
  let parent = skeNode.parent;
17068
17824
  while (parent) {
17825
+ var _parent$parent;
17826
+ if (parent.page === skeNode && ((_parent$parent = parent.parent) === null || _parent$parent === void 0 ? void 0 : _parent$parent.columns)) {
17827
+ const index = parent.parent.columns.indexOf(parent);
17828
+ if (index !== -1) path.unshift("columns", index, "page");
17829
+ skeNode = parent.parent;
17830
+ parent = skeNode === null || skeNode === void 0 ? void 0 : skeNode.parent;
17831
+ continue;
17832
+ }
17069
17833
  if (parent.pages) {
17070
17834
  const index = parent.pages.indexOf(skeNode);
17071
17835
  if (index !== -1) path.unshift("pages", index);
@@ -17076,11 +17840,73 @@ function getPagePath(page) {
17076
17840
  const index = parent.rows.indexOf(skeNode);
17077
17841
  if (index !== -1) path.unshift("rows", index);
17078
17842
  } else if (parent.skeTables && parent.skeTables.has(skeNode.tableId)) path.unshift("skeTables", skeNode.tableId);
17843
+ else if (parent.skeColumnGroups && parent.skeColumnGroups.has(skeNode.columnGroupId)) path.unshift("skeColumnGroups", skeNode.columnGroupId);
17079
17844
  skeNode = parent;
17080
17845
  parent = parent === null || parent === void 0 ? void 0 : parent.parent;
17081
17846
  }
17082
17847
  return path;
17083
17848
  }
17849
+ function getBoundaryGlyphInPage(page, useLast) {
17850
+ const sections = useLast ? [...page.sections].reverse() : page.sections;
17851
+ for (const section of sections) {
17852
+ const columns = useLast ? [...section.columns].reverse() : section.columns;
17853
+ for (const column of columns) {
17854
+ const lines = useLast ? [...column.lines].reverse() : column.lines;
17855
+ for (const line of lines) {
17856
+ const divides = useLast ? [...line.divides].reverse() : line.divides;
17857
+ for (const divide of divides) {
17858
+ const glyph = (useLast ? [...divide.glyphGroup].reverse() : divide.glyphGroup).find((item) => {
17859
+ var _item$content;
17860
+ return (_item$content = item.content) === null || _item$content === void 0 ? void 0 : _item$content.length;
17861
+ });
17862
+ if (glyph) return {
17863
+ section,
17864
+ column,
17865
+ line,
17866
+ divide,
17867
+ glyph
17868
+ };
17869
+ }
17870
+ }
17871
+ }
17872
+ }
17873
+ }
17874
+ function isHitTestAddressableGlyph(glyph) {
17875
+ var _glyph$content;
17876
+ return Boolean((_glyph$content = glyph.content) === null || _glyph$content === void 0 ? void 0 : _glyph$content.length) || glyph.streamType === DataStreamTreeTokenType.PARAGRAPH && glyph.count > 0;
17877
+ }
17878
+ function resolveMostSpecificPageByCharIndex(page, charIndex) {
17879
+ var _page$skeTables$value, _page$skeTables2, _page$skeColumnGroups, _page$skeColumnGroups2;
17880
+ for (const table of (_page$skeTables$value = (_page$skeTables2 = page.skeTables) === null || _page$skeTables2 === void 0 ? void 0 : _page$skeTables2.values()) !== null && _page$skeTables$value !== void 0 ? _page$skeTables$value : []) for (const row of table.rows) for (const cell of row.cells) {
17881
+ const { st, ed } = cell;
17882
+ if (charIndex >= st && charIndex <= ed) return resolveMostSpecificPageByCharIndex(cell, charIndex);
17883
+ }
17884
+ for (const columnGroup of (_page$skeColumnGroups = (_page$skeColumnGroups2 = page.skeColumnGroups) === null || _page$skeColumnGroups2 === void 0 ? void 0 : _page$skeColumnGroups2.values()) !== null && _page$skeColumnGroups !== void 0 ? _page$skeColumnGroups : []) for (const column of columnGroup.columns) {
17885
+ const { st, ed } = column;
17886
+ if (charIndex >= st && charIndex <= ed) return resolveMostSpecificPageByCharIndex(column.page, charIndex);
17887
+ }
17888
+ return page;
17889
+ }
17890
+ function getSegmentPageFromRelativePath(skeletonData, segmentPageIndex, path) {
17891
+ var _skeletonData$skeHead, _skeletonData$skeFoot;
17892
+ const rootPage = skeletonData.pages[segmentPageIndex];
17893
+ if (rootPage == null) return null;
17894
+ const { headerId, footerId, pageWidth } = rootPage;
17895
+ const segmentPages = [headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(pageWidth), footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(pageWidth)];
17896
+ for (const segmentPage of segmentPages) {
17897
+ if (segmentPage == null) continue;
17898
+ const page = getPageFromPath({
17899
+ ...skeletonData,
17900
+ pages: [segmentPage]
17901
+ }, [
17902
+ "pages",
17903
+ 0,
17904
+ ...path
17905
+ ]);
17906
+ if (page != null) return page;
17907
+ }
17908
+ return null;
17909
+ }
17084
17910
  var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17085
17911
  constructor(_docViewModel, localeService) {
17086
17912
  super(localeService);
@@ -17175,7 +18001,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17175
18001
  pageIndex = skeletonData.pages.indexOf(page);
17176
18002
  break;
17177
18003
  case 3:
17178
- pageIndex = path[1];
18004
+ pageIndex = typeof path[1] === "number" ? path[1] : segmentPage;
17179
18005
  break;
17180
18006
  default: throw new Error("Invalid page type");
17181
18007
  }
@@ -17221,7 +18047,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17221
18047
  pageIndex = pages.indexOf(page);
17222
18048
  break;
17223
18049
  case 3:
17224
- pageIndex = path[1];
18050
+ pageIndex = typeof path[1] === "number" ? path[1] : segmentPageIndex;
17225
18051
  break;
17226
18052
  default: throw new Error("Invalid page type");
17227
18053
  }
@@ -17264,7 +18090,8 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17264
18090
  if (skeFooter == null) return;
17265
18091
  else skePage = skeFooter;
17266
18092
  }
17267
- } else skePage = getPageFromPath(skeletonData, path);
18093
+ } else if (pageType === 3 && path[0] !== "pages") skePage = getSegmentPageFromRelativePath(skeletonData, segmentPage, path);
18094
+ else skePage = getPageFromPath(skeletonData, path);
17268
18095
  if (skePage == null) return;
17269
18096
  const glyphGroup = skePage.sections[section].columns[column].lines[line].divides[divide].glyphGroup;
17270
18097
  glyph = Math.min(glyph, glyphGroup.length - 1);
@@ -17380,7 +18207,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17380
18207
  return this._getNearestNode(cache.nearestNodeList, cache.nearestNodeDistanceList);
17381
18208
  }
17382
18209
  _collectNearestNode(segmentPage, pageType, page, segmentId, pi, cache, x, y, pageLength, nestLevel = 0) {
17383
- const { sections, skeTables } = segmentPage;
18210
+ const { sections, skeTables, skeColumnGroups = /* @__PURE__ */ new Map() } = segmentPage;
17384
18211
  this._findLiquid.translateSave();
17385
18212
  const pageLeft = this._findLiquid.x;
17386
18213
  const pageRight = pageLeft + page.pageWidth;
@@ -17441,7 +18268,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17441
18268
  this._findLiquid.translateDivide(divide);
17442
18269
  const { x: startX } = this._findLiquid;
17443
18270
  for (const glyph of glyphGroup) {
17444
- if (!glyph.content || glyph.content.length === 0) continue;
18271
+ if (!isHitTestAddressableGlyph(glyph)) continue;
17445
18272
  const { width: glyphWidth, left: glyphLeft } = glyph;
17446
18273
  const startX_fin = startX + glyphLeft;
17447
18274
  const endX_fin = startX + glyphLeft + glyphWidth;
@@ -17544,6 +18371,30 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17544
18371
  (_this$_findLiquid11 = this._findLiquid) === null || _this$_findLiquid11 === void 0 || _this$_findLiquid11.translateRestore();
17545
18372
  }
17546
18373
  }
18374
+ if (skeColumnGroups.size > 0) for (const columnGroup of skeColumnGroups.values()) {
18375
+ var _this$_findLiquid12, _this$_findLiquid13, _this$_findLiquid17;
18376
+ const { top: columnGroupTop, left: columnGroupLeft, width: columnGroupWidth, height: columnGroupHeight, columns } = columnGroup;
18377
+ const absoluteColumnGroupLeft = this._findLiquid.x + columnGroupLeft;
18378
+ const absoluteColumnGroupTop = this._findLiquid.y + columnGroupTop;
18379
+ if (x < absoluteColumnGroupLeft || x > absoluteColumnGroupLeft + columnGroupWidth || y < absoluteColumnGroupTop || y > absoluteColumnGroupTop + columnGroupHeight) continue;
18380
+ (_this$_findLiquid12 = this._findLiquid) === null || _this$_findLiquid12 === void 0 || _this$_findLiquid12.translateSave();
18381
+ (_this$_findLiquid13 = this._findLiquid) === null || _this$_findLiquid13 === void 0 || _this$_findLiquid13.translate(columnGroupLeft, columnGroupTop);
18382
+ for (const column of columns) {
18383
+ var _this$_findLiquid14, _this$_findLiquid15, _ref, _exactMatch4, _this$_findLiquid16;
18384
+ const absoluteColumnLeft = absoluteColumnGroupLeft + column.left;
18385
+ const absoluteColumnTop = absoluteColumnGroupTop + column.top;
18386
+ if (x < absoluteColumnLeft || x > absoluteColumnLeft + column.width || y < absoluteColumnTop || y > absoluteColumnTop + column.height) continue;
18387
+ const nestedCache = {
18388
+ nearestNodeList: [],
18389
+ nearestNodeDistanceList: []
18390
+ };
18391
+ (_this$_findLiquid14 = this._findLiquid) === null || _this$_findLiquid14 === void 0 || _this$_findLiquid14.translateSave();
18392
+ (_this$_findLiquid15 = this._findLiquid) === null || _this$_findLiquid15 === void 0 || _this$_findLiquid15.translate(column.left, column.top);
18393
+ exactMatch = (_ref = (_exactMatch4 = exactMatch) !== null && _exactMatch4 !== void 0 ? _exactMatch4 : this._collectNearestNode(column.page, 3, column.page, segmentId, pi, nestedCache, x, y, pageLength, nestLevel + 1)) !== null && _ref !== void 0 ? _ref : this._getNearestNode(nestedCache.nearestNodeList, nestedCache.nearestNodeDistanceList);
18394
+ (_this$_findLiquid16 = this._findLiquid) === null || _this$_findLiquid16 === void 0 || _this$_findLiquid16.translateRestore();
18395
+ }
18396
+ (_this$_findLiquid17 = this._findLiquid) === null || _this$_findLiquid17 === void 0 || _this$_findLiquid17.translateRestore();
18397
+ }
17547
18398
  if (exactMatch) {
17548
18399
  this._findLiquid.translateRestore();
17549
18400
  return exactMatch;
@@ -17688,7 +18539,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17688
18539
  let isContinuous = false;
17689
18540
  ctx.sectionBreakConfigCache.set(sectionNode.endIndex, sectionBreakConfig);
17690
18541
  if (sectionType === SectionType.CONTINUOUS && curSkeletonPage != null) {
17691
- updateBlockIndex(allSkeletonPages);
18542
+ updateBlockIndex(allSkeletonPages, -1, ctx.docsConfig.documentCompatibilityPolicy);
17692
18543
  this._addNewSectionByContinuous(curSkeletonPage, columnProperties, columnSeparatorType);
17693
18544
  isContinuous = true;
17694
18545
  } else if (layoutAnchor == null || curSkeletonPage == null) {
@@ -17697,7 +18548,10 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17697
18548
  }
17698
18549
  const { pages } = dealWithSection(ctx, viewModel, sectionNode, curSkeletonPage, sectionBreakConfig, layoutAnchor);
17699
18550
  if (sectionTypeNext === SectionType.CONTINUOUS && columnProperties.length > 0) {}
17700
- if (isContinuous) pages.splice(0, 1);
18551
+ if (isContinuous) {
18552
+ const continuousFirstPage = pages.shift();
18553
+ if (continuousFirstPage && allSkeletonPages.length > 0) allSkeletonPages[allSkeletonPages.length - 1] = continuousFirstPage;
18554
+ }
17701
18555
  allSkeletonPages.push(...pages);
17702
18556
  if (ctx.isDirty) break;
17703
18557
  }
@@ -17708,7 +18562,8 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17708
18562
  } else {
17709
18563
  this._iteratorCount = 0;
17710
18564
  removeDupPages(ctx);
17711
- updateBlockIndex(skeleton.pages);
18565
+ updateBlockIndex(skeleton.pages, -1, ctx.docsConfig.documentCompatibilityPolicy);
18566
+ mergeContinuousDuplicatePages(skeleton.pages);
17712
18567
  updateInlineDrawingCoordsAndBorder(ctx, skeleton.pages);
17713
18568
  for (const hSkeMap of skeleton.skeHeaders.values()) for (const page of hSkeMap.values()) updateInlineDrawingCoordsAndBorder(ctx, [page]);
17714
18569
  for (const fSkeMap of skeleton.skeFooters.values()) for (const page of fSkeMap.values()) updateInlineDrawingCoordsAndBorder(ctx, [page]);
@@ -17732,9 +18587,10 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17732
18587
  if (skeletonData == null) return;
17733
18588
  const { pages, skeFooters, skeHeaders } = skeletonData;
17734
18589
  for (const page of pages) {
18590
+ var _segmentPageParent$pa;
17735
18591
  const curPageIndex = pages.indexOf(page);
17736
18592
  if (segmentId && curPageIndex !== segmentPageIndex) continue;
17737
- const { pageWidth, skeTables } = page;
18593
+ const { pageWidth } = page;
17738
18594
  let segmentPage = page;
17739
18595
  if (segmentId) {
17740
18596
  var _skeHeaders$get5, _skeFooters$get5;
@@ -17743,28 +18599,23 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17743
18599
  if (maybeHeaderSke) segmentPage = maybeHeaderSke;
17744
18600
  else if (maybeFooterSke) segmentPage = maybeFooterSke;
17745
18601
  else continue;
17746
- }
17747
- if (segmentId === "") {
17748
- let foundCell = false;
17749
- for (const table of skeTables.values()) {
17750
- const { rows } = table;
17751
- for (const row of rows) {
17752
- const { cells } = row;
17753
- for (const cell of cells) {
17754
- const { st, ed } = cell;
17755
- if (charIndex >= st && charIndex <= ed) {
17756
- segmentPage = cell;
17757
- foundCell = true;
17758
- break;
17759
- }
17760
- }
17761
- if (foundCell) break;
17762
- }
17763
- if (foundCell) break;
18602
+ segmentPage = resolveMostSpecificPageByCharIndex(segmentPage, charIndex);
18603
+ } else segmentPage = resolveMostSpecificPageByCharIndex(page, charIndex);
18604
+ const { sections, st, ed } = segmentPage;
18605
+ const segmentPageParent = segmentPage.parent;
18606
+ const isColumnSegmentPage = segmentId === "" && (segmentPageParent === null || segmentPageParent === void 0 ? void 0 : segmentPageParent.page) === segmentPage && ((_segmentPageParent$pa = segmentPageParent.parent) === null || _segmentPageParent$pa === void 0 ? void 0 : _segmentPageParent$pa.columnGroupId);
18607
+ if (charIndex < st || charIndex > ed) {
18608
+ if (isColumnSegmentPage) {
18609
+ const boundary = getBoundaryGlyphInPage(segmentPage, charIndex >= ed);
18610
+ if (boundary) return {
18611
+ page: segmentPage,
18612
+ pageType: segmentPage.type,
18613
+ segmentPageIndex,
18614
+ ...boundary
18615
+ };
17764
18616
  }
18617
+ continue;
17765
18618
  }
17766
- const { sections, st, ed } = segmentPage;
17767
- if (charIndex < st || charIndex > ed) continue;
17768
18619
  for (const section of sections) {
17769
18620
  const { columns, st, ed } = section;
17770
18621
  if (charIndex < st || charIndex > ed) continue;
@@ -17797,6 +18648,15 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17797
18648
  }
17798
18649
  }
17799
18650
  }
18651
+ if (isColumnSegmentPage) {
18652
+ const boundary = getBoundaryGlyphInPage(segmentPage, charIndex >= segmentPage.ed);
18653
+ if (boundary) return {
18654
+ page: segmentPage,
18655
+ pageType: segmentPage.type,
18656
+ segmentPageIndex,
18657
+ ...boundary
18658
+ };
18659
+ }
17800
18660
  }
17801
18661
  }
17802
18662
  };
@@ -22569,7 +23429,7 @@ var Documents = class Documents extends DocComponent {
22569
23429
  for (let i = 0, len = pages.length; i < len; i++) {
22570
23430
  var _skeHeaders$get, _headerSkeletonPage$m, _skeFooters$get;
22571
23431
  const page = pages[i];
22572
- const { sections, marginTop: pagePaddingTop = 0, marginBottom: pagePaddingBottom = 0, marginLeft: pagePaddingLeft = 0, marginRight: pagePaddingRight = 0, width: actualWidth, height: actualHeight, pageWidth, headerId, footerId, renderConfig = {}, skeTables } = page;
23432
+ const { sections, marginTop: pagePaddingTop = 0, marginBottom: pagePaddingBottom = 0, marginLeft: pagePaddingLeft = 0, marginRight: pagePaddingRight = 0, width: actualWidth, height: actualHeight, pageWidth, headerId, footerId, renderConfig = {}, skeTables, skeColumnGroups = /* @__PURE__ */ new Map() } = page;
22573
23433
  const { verticalAlign = VerticalAlign.TOP, horizontalAlign = HorizontalAlign.LEFT, centerAngle: centerAngleDeg = 0, vertexAngle: vertexAngleDeg = 0, wrapStrategy = WrapStrategy.UNSPECIFIED, cellValueType } = renderConfig;
22574
23434
  const isVertical = vertexAngleDeg === 90 && centerAngleDeg === 90;
22575
23435
  const horizontalOffsetNoAngle = this._horizontalHandler(actualWidth, pagePaddingLeft, pagePaddingRight, horizontalAlign, vertexAngleDeg, centerAngleDeg, cellValueType);
@@ -22669,6 +23529,7 @@ var Documents = class Documents extends DocComponent {
22669
23529
  this._drawLiquid.translateRestore();
22670
23530
  }
22671
23531
  }
23532
+ if (skeColumnGroups.size > 0) this._drawColumnGroups(ctx, page, skeColumnGroups, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
22672
23533
  this._resetRotation(ctx, finalAngle);
22673
23534
  const footerSkeletonPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(pageWidth);
22674
23535
  if (footerSkeletonPage) {
@@ -22726,6 +23587,21 @@ var Documents = class Documents extends DocComponent {
22726
23587
  drawLiquid.translateRestore();
22727
23588
  }
22728
23589
  }
23590
+ _drawColumnGroups(ctx, page, skeColumnGroups, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale) {
23591
+ const drawLiquid = this._drawLiquid;
23592
+ if (drawLiquid == null) return;
23593
+ for (const columnGroup of skeColumnGroups.values()) {
23594
+ drawLiquid.translateSave();
23595
+ drawLiquid.translate(columnGroup.left, columnGroup.top);
23596
+ for (const column of columnGroup.columns) {
23597
+ drawLiquid.translateSave();
23598
+ drawLiquid.translate(column.left, column.top);
23599
+ this._drawNestedPageContent(ctx, page, column.page, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
23600
+ drawLiquid.translateRestore();
23601
+ }
23602
+ drawLiquid.translateRestore();
23603
+ }
23604
+ }
22729
23605
  _drawTableCellBackgrounds(ctx, page, tableSkeleton) {
22730
23606
  if (this._drawLiquid == null) return;
22731
23607
  const backgrounds = /* @__PURE__ */ new Map();
@@ -22834,15 +23710,33 @@ var Documents = class Documents extends DocComponent {
22834
23710
  _drawTableCell(ctx, page, cell, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale) {
22835
23711
  if (this._drawLiquid == null) return;
22836
23712
  this._drawTableCellBordersAndBg(ctx, page, cell, false);
22837
- const { sections, marginLeft, marginTop } = cell;
22838
- alignOffsetNoAngle = Vector2.create(alignOffsetNoAngle.x + marginLeft, alignOffsetNoAngle.y + marginTop);
23713
+ this._drawNestedPageContent(ctx, page, cell, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
23714
+ }
23715
+ _drawNestedPageContent(ctx, parentPage, nestedPage, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale) {
23716
+ if (this._drawLiquid == null) return;
23717
+ const { sections, marginLeft, marginTop, skeTables } = nestedPage;
23718
+ const alignOffset = Vector2.create(alignOffsetNoAngle.x + marginLeft, alignOffsetNoAngle.y + marginTop);
22839
23719
  ctx.save();
22840
23720
  const { x, y } = this._drawLiquid;
22841
- const { pageWidth, pageHeight } = cell;
23721
+ const { pageWidth, pageHeight } = nestedPage;
23722
+ const clipOrigin = getNestedPageClipOrigin(parentPage, nestedPage, {
23723
+ x,
23724
+ y
23725
+ }, alignOffset);
22842
23726
  ctx.beginPath();
22843
- ctx.rectByPrecision(x + page.marginLeft, y + page.marginTop, pageWidth, pageHeight);
23727
+ ctx.rectByPrecision(clipOrigin.x, clipOrigin.y, pageWidth, pageHeight);
22844
23728
  ctx.closePath();
22845
23729
  ctx.clip();
23730
+ if (skeTables.size > 0) if (isColumnGroupNestedPage(nestedPage)) {
23731
+ this._drawLiquid.translateSave();
23732
+ this._drawLiquid.translate(alignOffset.x, alignOffset.y);
23733
+ this._drawTable(ctx, {
23734
+ ...nestedPage,
23735
+ marginLeft: 0,
23736
+ marginTop: 0
23737
+ }, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, Vector2.create(0, 0), centerAngle, vertexAngle, renderConfig, parentScale);
23738
+ this._drawLiquid.translateRestore();
23739
+ } else this._drawTable(ctx, nestedPage, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffset, centerAngle, vertexAngle, renderConfig, parentScale);
22846
23740
  for (const section of sections) {
22847
23741
  const { columns } = section;
22848
23742
  this._drawLiquid.translateSave();
@@ -22852,7 +23746,6 @@ var Documents = class Documents extends DocComponent {
22852
23746
  this._drawLiquid.translateSave();
22853
23747
  this._drawLiquid.translateColumn(column);
22854
23748
  const linesCount = lines.length;
22855
- const alignOffset = alignOffsetNoAngle;
22856
23749
  for (let i = 0; i < linesCount; i++) {
22857
23750
  const line = lines[i];
22858
23751
  const { divides, asc = 0, type, lineHeight = 0 } = line;
@@ -22870,7 +23763,7 @@ var Documents = class Documents extends DocComponent {
22870
23763
  } else {
22871
23764
  this._drawLiquid.translateSave();
22872
23765
  this._drawLiquid.translateLine(line, true, true);
22873
- this._drawLineBackground(ctx, cell, line, page.marginLeft, page.marginTop);
23766
+ this._drawLineBackground(ctx, nestedPage, line);
22874
23767
  const divideLength = divides.length;
22875
23768
  for (let i = 0; i < divideLength; i++) {
22876
23769
  const divide = divides[i];
@@ -22899,7 +23792,7 @@ var Documents = class Documents extends DocComponent {
22899
23792
  }
22900
23793
  this._drawLiquid.translateRestore();
22901
23794
  }
22902
- if (line.borderBottom) this._drawBorderBottom(ctx, cell, line, page.marginLeft, page.marginTop);
23795
+ if (line.borderBottom) this._drawBorderBottom(ctx, nestedPage, line, parentPage.marginLeft, parentPage.marginTop);
22903
23796
  this._drawLiquid.translateRestore();
22904
23797
  }
22905
23798
  }
@@ -22978,7 +23871,15 @@ var Documents = class Documents extends DocComponent {
22978
23871
  if (this._drawLiquid == null) return;
22979
23872
  const { sections, skeTables } = page;
22980
23873
  const { y: originY } = this._drawLiquid;
22981
- if (skeTables.size > 0) this._drawTable(ctx, page, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
23874
+ if (skeTables.size > 0) {
23875
+ const tablePage = {
23876
+ ...page,
23877
+ marginLeft: parentPage.marginLeft,
23878
+ marginRight: parentPage.marginRight,
23879
+ marginTop: isHeader ? page.marginTop : page.marginTop + alignOffsetNoAngle.y
23880
+ };
23881
+ this._drawTable(ctx, tablePage, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
23882
+ }
22982
23883
  for (const section of sections) {
22983
23884
  const { columns } = section;
22984
23885
  this._drawLiquid.translateSave();
@@ -23102,6 +24003,21 @@ function setTableCellBorderDash(ctx, dashStyle) {
23102
24003
  }
23103
24004
  ctx.setLineDash([0]);
23104
24005
  }
24006
+ function isColumnGroupNestedPage(page) {
24007
+ var _parent$parent;
24008
+ const parent = page.parent;
24009
+ return (parent === null || parent === void 0 ? void 0 : parent.columnId) != null && ((_parent$parent = parent.parent) === null || _parent$parent === void 0 ? void 0 : _parent$parent.columnGroupId) != null;
24010
+ }
24011
+ function getNestedPageClipOrigin(parentPage, nestedPage, drawOrigin, alignOffset) {
24012
+ if (isColumnGroupNestedPage(nestedPage)) return {
24013
+ x: drawOrigin.x + alignOffset.x,
24014
+ y: drawOrigin.y + alignOffset.y
24015
+ };
24016
+ return {
24017
+ x: drawOrigin.x + parentPage.marginLeft,
24018
+ y: drawOrigin.y + parentPage.marginTop
24019
+ };
24020
+ }
23105
24021
  function fillRectByPrecisionBounds(ctx, x, y, width, height) {
23106
24022
  const { scaleX, scaleY } = ctx.getScale();
23107
24023
  const startX = fixLineWidthByScale(x, scaleX);
@@ -25684,7 +26600,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
25684
26600
  //#endregion
25685
26601
  //#region package.json
25686
26602
  var name = "@univerjs/engine-render";
25687
- var version = "1.0.0-alpha.0";
26603
+ var version = "1.0.0-alpha.2";
25688
26604
 
25689
26605
  //#endregion
25690
26606
  //#region src/config/config.ts
@@ -29962,4 +30878,4 @@ var Viewport = class {
29962
30878
  };
29963
30879
 
29964
30880
  //#endregion
29965
- 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 };
30881
+ 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, compareDocumentSkeletonNestedPagePathOrder, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, createCanvasElement, createImageElement, degToRad, documentSkeletonLineIterator, documentSkeletonTableIterator, drawDiagonalLineByBorderType, drawLineByBorderType, expandRangeIfIntersects, fixLineWidthByScale, generateRandomKey, getCellByIndexWithMergeInfo, getCellPositionByIndex, getCharSpaceApply, getColor, getCurrentScrollXY, getCurrentTypeOfRenderer, getDPI, getDevicePixelRatio, getDocsSkeletonPageSize, getDocsTableRenderViewport, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, 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 };