@univerjs/engine-render 1.0.0-alpha.1 → 1.0.0-alpha.3

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.
Files changed (28) hide show
  1. package/lib/cjs/index.js +1444 -372
  2. package/lib/es/index.js +1440 -347
  3. package/lib/types/basics/cjk-regexp.d.ts +61 -0
  4. package/lib/types/basics/const.d.ts +4 -0
  5. package/lib/types/basics/draw.d.ts +4 -4
  6. package/lib/types/basics/i-document-skeleton-cached.d.ts +10 -0
  7. package/lib/types/basics/index.d.ts +2 -0
  8. package/lib/types/basics/interfaces.d.ts +3 -1
  9. package/lib/types/basics/tools.d.ts +0 -3
  10. package/lib/types/components/docs/custom-block-render-viewport.d.ts +37 -0
  11. package/lib/types/components/docs/layout/block/paragraph/layout-ruler.d.ts +3 -1
  12. package/lib/types/components/docs/layout/doc-no-wrap-measure.d.ts +35 -0
  13. package/lib/types/components/docs/layout/tools.d.ts +5 -1
  14. package/lib/types/components/docs/view-model/document-view-model.d.ts +2 -1
  15. package/lib/types/components/extension.d.ts +2 -0
  16. package/lib/types/components/sheets/extensions/background.d.ts +2 -1
  17. package/lib/types/components/sheets/extensions/font.d.ts +2 -1
  18. package/lib/types/components/sheets/extensions/sheet-extension.d.ts +5 -0
  19. package/lib/types/components/sheets/interfaces.d.ts +3 -0
  20. package/lib/types/components/sheets/sheet.render-skeleton.d.ts +14 -9
  21. package/lib/types/index.d.ts +3 -0
  22. package/lib/types/render-manager/render-manager.service.d.ts +1 -1
  23. package/lib/types/render-manager/render-unit.d.ts +3 -0
  24. package/lib/types/shape/scroll-bar.d.ts +8 -0
  25. package/lib/types/shape/text.d.ts +4 -0
  26. package/lib/types/viewport.d.ts +7 -1
  27. package/lib/umd/index.js +5 -2
  28. package/package.json +4 -5
package/lib/es/index.js CHANGED
@@ -1,5 +1,4 @@
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
- import * as cjk from "cjk-regex";
1
+ import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnResponsiveType, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, 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, LookUp, 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, createSectionId, deleteContent, extractPureTextFromCell, getCellInfoInMergeData, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isCellCoverable, isClassDependencyItem, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, regexp, registerDependencies, remove, requestImmediateMacroTask, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReferences, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
3
2
  import { BehaviorSubject, Observable, Subject, Subscription, debounceTime, distinctUntilChanged, shareReplay, startWith } from "rxjs";
4
3
  import { parse } from "opentype.js";
5
4
  import { franc } from "franc-min";
@@ -89,6 +88,10 @@ let CURSOR_TYPE = /* @__PURE__ */ function(CURSOR_TYPE) {
89
88
  CURSOR_TYPE["SOUTH_WEST_RESIZE"] = "sw-resize";
90
89
  CURSOR_TYPE["SOUTH_RESIZE"] = "s-resize";
91
90
  CURSOR_TYPE["WEST_RESIZE"] = "w-resize";
91
+ CURSOR_TYPE["EAST_WEST_RESIZE"] = "ew-resize";
92
+ CURSOR_TYPE["NORTH_SOUTH_RESIZE"] = "ns-resize";
93
+ CURSOR_TYPE["NORTH_EAST_SOUTH_WEST_RESIZE"] = "nesw-resize";
94
+ CURSOR_TYPE["NORTH_WEST_SOUTH_EAST_RESIZE"] = "nwse-resize";
92
95
  CURSOR_TYPE["TEXT"] = "text";
93
96
  CURSOR_TYPE["WAIT"] = "wait";
94
97
  CURSOR_TYPE["HELP"] = "help";
@@ -203,6 +206,7 @@ const cancelRequestFrame = (requestID, requester) => {
203
206
  };
204
207
  const createCanvasElement = () => {
205
208
  const canvas = document.createElement("canvas");
209
+ canvas.dir = "ltr";
206
210
  try {
207
211
  canvas.style = canvas.style || {};
208
212
  } catch (e) {
@@ -294,7 +298,7 @@ function getFontStyleString(textStyle) {
294
298
  let bold = FontStyleType.BOLD;
295
299
  if (textStyle.bl === 0 || textStyle.bl === void 0) bold = FontStyleType.NORMAL;
296
300
  let originFontSize = defaultFontSize;
297
- if (textStyle.fs) originFontSize = Math.ceil(textStyle.fs);
301
+ if (textStyle.fs) originFontSize = textStyle.fs;
298
302
  let fontSize = originFontSize;
299
303
  const fontFamilyResult = normalizeFontFamily(textStyle.ff, defaultFont);
300
304
  const { va: baselineOffset } = textStyle;
@@ -318,18 +322,6 @@ function normalizeFontFamily(fontFamily, defaultFont) {
318
322
  return family.includes(" ") ? `"${family}"` : family;
319
323
  }).filter(Boolean).join(", ");
320
324
  }
321
- const CJK_LETTER_REG = cjk.letters().toRegExp();
322
- function hasCJKText(text) {
323
- return CJK_LETTER_REG.test(text);
324
- }
325
- const CJK_ALL_REG = cjk.all().toRegExp();
326
- function hasCJK(text) {
327
- return CJK_ALL_REG.test(text);
328
- }
329
- const CJK_PUNCTUATION_REG = cjk.punctuations().toRegExp();
330
- function hasCJKPunctuation(text) {
331
- return CJK_PUNCTUATION_REG.test(text);
332
- }
333
325
  function hasAllLatin(text) {
334
326
  if (!/[\u0000-\u024F]/gi.exec(text)) return false;
335
327
  return true;
@@ -918,6 +910,220 @@ _defineProperty(FontCache, "_context", void 0);
918
910
  _defineProperty(FontCache, "_fontDataMap", /* @__PURE__ */ new Map());
919
911
  _defineProperty(FontCache, "_globalFontMeasureCache", /* @__PURE__ */ new Map());
920
912
 
913
+ //#endregion
914
+ //#region src/basics/cjk-regexp.ts
915
+ /**
916
+ * Copyright 2023-present DreamNum Co., Ltd.
917
+ *
918
+ * Licensed under the Apache License, Version 2.0 (the "License");
919
+ * you may not use this file except in compliance with the License.
920
+ * You may obtain a copy of the License at
921
+ *
922
+ * http://www.apache.org/licenses/LICENSE-2.0
923
+ *
924
+ * Unless required by applicable law or agreed to in writing, software
925
+ * distributed under the License is distributed on an "AS IS" BASIS,
926
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
927
+ * See the License for the specific language governing permissions and
928
+ * limitations under the License.
929
+ */
930
+ /**
931
+ * Golden regex sources generated from `cjk-regex@3.4.0`.
932
+ *
933
+ * Keep these strings stable unless intentionally upgrading cjk-regex semantics. The tests
934
+ * assert exact source equality so document CJK layout behavior does not drift through
935
+ * manual range edits.
936
+ */
937
+ const CJK_LETTER_SOURCE = String.raw`[\u1100-\u11ff\u2e80-\u2e99\u2e9b-\u2ef3\u2f00-\u2fd5\u3005\u3007\u3021-\u3029\u3038-\u303b\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fd-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u321e\u3260-\u327e\u32d0-\u32fe\u3300-\u3357\u3400-\u4dbf\u4e00-\u9fff\ua960-\ua97c\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\uff66-\uff6f\uff71-\uff9d\uffa0-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]|[\ud840-\ud868\ud86a-\ud86d\ud86f-\ud872\ud874-\ud879\ud880-\ud883\ud885-\ud88c][\udc00-\udfff]|\ud81b[\udfe3\udff2-\udff6]|\ud82b[\udff0-\udff3\udff5-\udffb\udffd-\udffe]|\ud82c[\udc00-\udd22\udd32\udd50-\udd52\udd55\udd64-\udd67]|\ud83c[\ude00]|\ud869[\udc00-\udedf\udf00-\udfff]|\ud86e[\udc00-\udc1d\udc20-\udfff]|\ud873[\udc00-\udead\udeb0-\udfff]|\ud87a[\udc00-\udfe0\udff0-\udfff]|\ud87b[\udc00-\ude5d]|\ud87e[\udc00-\ude1d]|\ud884[\udc00-\udf4a\udf50-\udfff]|\ud88d[\udc00-\udc79]`;
938
+ const CJK_PUNCTUATION_SOURCE = String.raw`[\u2ff0-\u3004\u3006\u3008-\u3020\u302a-\u3037\u303c-\u303f\u30a0\u30fb-\u30fc\u3190-\u319f\u31c0-\u31ef\u321f-\u325f\u327f-\u32cf\u32ff\u3358-\u33ff\ufe10-\ufe1f\ufe30-\ufe6f\uff00-\uff65\uff70\uff9e-\uff9f\uffbf-\uffc1\uffc8-\uffc9\uffd0-\uffd1\uffd8-\uffd9\uffdd-\uffef]`;
939
+ const CJK_ALL_SOURCE = String.raw`[\u1100-\u11ff\u2e80-\u2e99\u2e9b-\u2ef3\u2f00-\u2fd5\u2ff0-\u303f\u3041-\u3096\u309d-\u30ff\u3105-\u312f\u3131-\u318e\u3190-\u4dbf\u4e00-\u9fff\ua960-\ua97c\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufe10-\ufe1f\ufe30-\ufe6f\uff00-\uffef]|[\ud840-\ud868\ud86a-\ud86d\ud86f-\ud872\ud874-\ud879\ud880-\ud883\ud885-\ud88c][\udc00-\udfff]|\ud81b[\udfe3\udff2-\udff6]|\ud82b[\udff0-\udff3\udff5-\udffb\udffd-\udffe]|\ud82c[\udc00-\udd22\udd32\udd50-\udd52\udd55\udd64-\udd67]|\ud83c[\ude00]|\ud869[\udc00-\udedf\udf00-\udfff]|\ud86e[\udc00-\udc1d\udc20-\udfff]|\ud873[\udc00-\udead\udeb0-\udfff]|\ud87a[\udc00-\udfe0\udff0-\udfff]|\ud87b[\udc00-\ude5d]|\ud87e[\udc00-\ude1d]|\ud884[\udc00-\udf4a\udf50-\udfff]|\ud88d[\udc00-\udc79]`;
940
+ const CJK_LETTER_REG = new RegExp(CJK_LETTER_SOURCE);
941
+ const CJK_PUNCTUATION_REG = new RegExp(CJK_PUNCTUATION_SOURCE);
942
+ const CJK_ALL_REG = new RegExp(CJK_ALL_SOURCE);
943
+ /**
944
+ * Golden code-point ranges generated from `cjk-regex@3.4.0` snapshots.
945
+ *
946
+ * These are kept alongside the regex sources so compatibility can be checked against
947
+ * both matching behavior and `Charset.data`-style range snapshots.
948
+ */
949
+ const CJK_LETTER_DATA = [
950
+ [4352, 4607],
951
+ [11904, 11929],
952
+ [11931, 12019],
953
+ [12032, 12245],
954
+ [12293, 12293],
955
+ [12295, 12295],
956
+ [12321, 12329],
957
+ [12344, 12347],
958
+ [12353, 12438],
959
+ [12445, 12447],
960
+ [12449, 12538],
961
+ [12541, 12543],
962
+ [12549, 12591],
963
+ [12593, 12686],
964
+ [12704, 12735],
965
+ [12784, 12830],
966
+ [12896, 12926],
967
+ [13008, 13054],
968
+ [13056, 13143],
969
+ [13312, 19903],
970
+ [19968, 40959],
971
+ [43360, 43388],
972
+ [44032, 55203],
973
+ [55216, 55238],
974
+ [55243, 55291],
975
+ [63744, 64109],
976
+ [64112, 64217],
977
+ [65382, 65391],
978
+ [65393, 65437],
979
+ [65440, 65470],
980
+ [65474, 65479],
981
+ [65482, 65487],
982
+ [65490, 65495],
983
+ [65498, 65500],
984
+ [94179, 94179],
985
+ [94194, 94198],
986
+ [110576, 110579],
987
+ [110581, 110587],
988
+ [110589, 110590],
989
+ [110592, 110882],
990
+ [110898, 110898],
991
+ [110928, 110930],
992
+ [110933, 110933],
993
+ [110948, 110951],
994
+ [127488, 127488],
995
+ [131072, 173791],
996
+ [173824, 178205],
997
+ [178208, 183981],
998
+ [183984, 191456],
999
+ [191472, 192093],
1000
+ [194560, 195101],
1001
+ [196608, 201546],
1002
+ [201552, 210041]
1003
+ ];
1004
+ const CJK_PUNCTUATION_DATA = [
1005
+ [12272, 12292],
1006
+ [12294, 12294],
1007
+ [12296, 12320],
1008
+ [12330, 12343],
1009
+ [12348, 12351],
1010
+ [12448, 12448],
1011
+ [12539, 12540],
1012
+ [12688, 12703],
1013
+ [12736, 12783],
1014
+ [12831, 12895],
1015
+ [12927, 13007],
1016
+ [13055, 13055],
1017
+ [13144, 13311],
1018
+ [65040, 65055],
1019
+ [65072, 65135],
1020
+ [65280, 65381],
1021
+ [65392, 65392],
1022
+ [65438, 65439],
1023
+ [65471, 65473],
1024
+ [65480, 65481],
1025
+ [65488, 65489],
1026
+ [65496, 65497],
1027
+ [65501, 65519]
1028
+ ];
1029
+ const CJK_ALL_DATA = [
1030
+ [4352, 4607],
1031
+ [11904, 11929],
1032
+ [11931, 12019],
1033
+ [12032, 12245],
1034
+ [12272, 12351],
1035
+ [12353, 12438],
1036
+ [12445, 12543],
1037
+ [12549, 12591],
1038
+ [12593, 12686],
1039
+ [12688, 19903],
1040
+ [19968, 40959],
1041
+ [43360, 43388],
1042
+ [44032, 55203],
1043
+ [55216, 55238],
1044
+ [55243, 55291],
1045
+ [63744, 64109],
1046
+ [64112, 64217],
1047
+ [65040, 65055],
1048
+ [65072, 65135],
1049
+ [65280, 65519],
1050
+ [94179, 94179],
1051
+ [94194, 94198],
1052
+ [110576, 110579],
1053
+ [110581, 110587],
1054
+ [110589, 110590],
1055
+ [110592, 110882],
1056
+ [110898, 110898],
1057
+ [110928, 110930],
1058
+ [110933, 110933],
1059
+ [110948, 110951],
1060
+ [127488, 127488],
1061
+ [131072, 173791],
1062
+ [173824, 178205],
1063
+ [178208, 183981],
1064
+ [183984, 191456],
1065
+ [191472, 192093],
1066
+ [194560, 195101],
1067
+ [196608, 201546],
1068
+ [201552, 210041]
1069
+ ];
1070
+ /**
1071
+ * Returns the CJK letter charset generated from `cjk-regex@3.4.0`.
1072
+ */
1073
+ function letters() {
1074
+ return regexp.charset(...CJK_LETTER_DATA);
1075
+ }
1076
+ /**
1077
+ * Returns the CJK punctuation charset generated from `cjk-regex@3.4.0`.
1078
+ */
1079
+ function punctuations() {
1080
+ return regexp.charset(...CJK_PUNCTUATION_DATA);
1081
+ }
1082
+ /**
1083
+ * Returns the combined CJK letter and punctuation charset generated from `cjk-regex@3.4.0`.
1084
+ */
1085
+ function all() {
1086
+ return regexp.charset(...CJK_ALL_DATA);
1087
+ }
1088
+ /**
1089
+ * Returns true when text contains CJK letters, excluding punctuation and symbols.
1090
+ */
1091
+ function hasCJKText(text) {
1092
+ return CJK_LETTER_REG.test(text);
1093
+ }
1094
+ /**
1095
+ * Returns true when text contains CJK letters or CJK punctuation.
1096
+ */
1097
+ function hasCJK(text) {
1098
+ return CJK_ALL_REG.test(text);
1099
+ }
1100
+ /**
1101
+ * Returns true when text contains CJK punctuation, excluding CJK letters.
1102
+ */
1103
+ function hasCJKPunctuation(text) {
1104
+ return CJK_PUNCTUATION_REG.test(text);
1105
+ }
1106
+ /**
1107
+ * Namespace-style CJK regex API used by document rendering and layout.
1108
+ */
1109
+ const cjk = {
1110
+ CJK_LETTER_SOURCE,
1111
+ CJK_PUNCTUATION_SOURCE,
1112
+ CJK_ALL_SOURCE,
1113
+ CJK_LETTER_REG,
1114
+ CJK_PUNCTUATION_REG,
1115
+ CJK_ALL_REG,
1116
+ CJK_LETTER_DATA,
1117
+ CJK_PUNCTUATION_DATA,
1118
+ CJK_ALL_DATA,
1119
+ letters,
1120
+ punctuations,
1121
+ all,
1122
+ hasCJKText,
1123
+ hasCJK,
1124
+ hasCJKPunctuation
1125
+ };
1126
+
921
1127
  //#endregion
922
1128
  //#region src/basics/i-document-skeleton-cached.ts
923
1129
  let DocumentSkeletonPageType = /* @__PURE__ */ function(DocumentSkeletonPageType) {
@@ -4828,6 +5034,13 @@ var SheetExtension = class extends ComponentExtension {
4828
5034
  super(..._args);
4829
5035
  _defineProperty(this, "type", 0);
4830
5036
  }
5037
+ /**
5038
+ * Return an isolated instance when this extension is safe to render in a print scene.
5039
+ * Editor-only extensions remain excluded by default.
5040
+ */
5041
+ copyForPrinting() {
5042
+ return null;
5043
+ }
4831
5044
  isRenderDiffRangesByCell(rangeP, diffRanges) {
4832
5045
  if (diffRanges == null || diffRanges.length === 0) return true;
4833
5046
  for (const range of diffRanges) {
@@ -4914,6 +5127,11 @@ const UNIQUE_KEY$10 = "DefaultBackgroundExtension";
4914
5127
  */
4915
5128
  const DOC_EXTENSION_Z_INDEX$3 = 21;
4916
5129
  const PRINTING_Z_INDEX = 21;
5130
+ function getRangeCellCount(ranges) {
5131
+ return ranges.reduce((sum, range) => {
5132
+ return sum + Math.max(range.endRow - range.startRow + 1, 0) * Math.max(range.endColumn - range.startColumn + 1, 0);
5133
+ }, 0);
5134
+ }
4917
5135
  var Background = class extends SheetExtension {
4918
5136
  constructor(..._args) {
4919
5137
  super(..._args);
@@ -4925,7 +5143,7 @@ var Background = class extends SheetExtension {
4925
5143
  var _this$parent;
4926
5144
  return ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.isPrinting) ? this.PRINTING_Z_INDEX : this.Z_INDEX;
4927
5145
  }
4928
- draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges, { viewRanges, checkOutOfViewBound }) {
5146
+ draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges, { viewRanges, checkOutOfViewBound, hasMergeData = true }) {
4929
5147
  const { stylesCache, worksheet, rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;
4930
5148
  const { background: bgMatrixCacheByColor, backgroundPositions } = stylesCache;
4931
5149
  if (!worksheet || !bgMatrixCacheByColor) return;
@@ -4943,15 +5161,19 @@ var Background = class extends SheetExtension {
4943
5161
  spreadsheetSkeleton
4944
5162
  };
4945
5163
  const mergeRanges = [];
4946
- viewRanges.forEach((range) => {
5164
+ if (hasMergeData) viewRanges.forEach((range) => {
4947
5165
  const intersectMergeRangesInViewRanges = spreadsheetSkeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn);
4948
5166
  mergeRanges.push(...intersectMergeRangesInViewRanges);
4949
5167
  });
4950
5168
  const renderBGCore = (rgb) => {
4951
5169
  const bgColorMatrix = bgMatrixCacheByColor[rgb];
5170
+ const renderRanges = diffRanges && diffRanges.length > 0 ? diffRanges : viewRanges;
4952
5171
  const rangeForEachFn = (row, col, bgConfigParam) => {
4953
- if (spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(row, col) !== -1) return;
4954
- const cellInfo = spreadsheetSkeleton.getCellByIndexWithNoHeader(row, col);
5172
+ var _backgroundPositions$;
5173
+ if (hasMergeData) {
5174
+ if (spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(row, col) !== -1) return;
5175
+ }
5176
+ const cellInfo = (_backgroundPositions$ = backgroundPositions === null || backgroundPositions === void 0 ? void 0 : backgroundPositions.getValue(row, col)) !== null && _backgroundPositions$ !== void 0 ? _backgroundPositions$ : spreadsheetSkeleton.getCellByIndexWithNoHeader(row, col);
4955
5177
  if (!cellInfo) return;
4956
5178
  if (bgConfigParam || bgColorMatrix.getValue(row, col)) {
4957
5179
  renderBGContext.cellInfo = cellInfo;
@@ -4967,12 +5189,16 @@ var Background = class extends SheetExtension {
4967
5189
  renderBGContext.backgroundPaths = backgroundPaths;
4968
5190
  ctx.beginPath();
4969
5191
  const matrixSize = bgColorMatrix.getSizeOf();
4970
- if (viewRanges.reduce((sum, range) => {
4971
- return sum + (range.endRow - range.startRow) * (range.endColumn - range.startColumn);
4972
- }, 0) < matrixSize) viewRanges.forEach((range) => {
4973
- Range.foreach(range, rangeForEachFn);
4974
- });
4975
- else bgColorMatrix.forValue(rangeForEachFn);
5192
+ if (getRangeCellCount(renderRanges) < matrixSize) {
5193
+ renderBGContext.skipRenderRangeCheck = true;
5194
+ renderRanges.forEach((range) => {
5195
+ Range.foreach(range, rangeForEachFn);
5196
+ });
5197
+ renderBGContext.skipRenderRangeCheck = false;
5198
+ } else {
5199
+ renderBGContext.skipRenderRangeCheck = false;
5200
+ bgColorMatrix.forValue(rangeForEachFn);
5201
+ }
4976
5202
  ctx.fill(backgroundPaths);
4977
5203
  ctx.closePath();
4978
5204
  };
@@ -5001,12 +5227,12 @@ var Background = class extends SheetExtension {
5001
5227
  for (let index = 0; index < rgbList.length; index++) {
5002
5228
  const rgb = rgbList[index];
5003
5229
  renderBGCore(rgb);
5004
- renderBGForMergedCells(rgb);
5230
+ if (hasMergeData) renderBGForMergedCells(rgb);
5005
5231
  }
5006
5232
  ctx.restore();
5007
5233
  }
5008
5234
  renderBGByCell(bgContext, row, col) {
5009
- const { spreadsheetSkeleton, backgroundPaths, scaleX, scaleY, viewRanges, diffRanges, cellInfo } = bgContext;
5235
+ const { spreadsheetSkeleton, backgroundPaths, scaleX, scaleY, viewRanges, diffRanges, cellInfo, skipRenderRangeCheck } = bgContext;
5010
5236
  let { startY, endY, startX, endX } = cellInfo;
5011
5237
  const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
5012
5238
  const renderRange = diffRanges && diffRanges.length > 0 ? diffRanges : viewRanges;
@@ -5014,7 +5240,7 @@ var Background = class extends SheetExtension {
5014
5240
  endY = mergeInfo.endY;
5015
5241
  startX = mergeInfo.startX;
5016
5242
  endX = mergeInfo.endX;
5017
- if (!isMerged && !isMergedMainCell && !inViewRanges(renderRange, row, col)) return true;
5243
+ if (!skipRenderRangeCheck && !isMerged && !isMergedMainCell && !inViewRanges(renderRange, row, col)) return true;
5018
5244
  if (!isMerged && !isMergedMainCell) {
5019
5245
  if (!spreadsheetSkeleton.worksheet.getRowVisible(row)) return true;
5020
5246
  if (!spreadsheetSkeleton.worksheet.getColVisible(col)) return true;
@@ -11782,11 +12008,12 @@ var Text = class Text extends Shape {
11782
12008
  this.skeleton = new DocSimpleSkeleton(props.text, props.fontStyle, Boolean(props.warp), props.width, props.height);
11783
12009
  }
11784
12010
  static drawWith(ctx, props, _skeleton) {
11785
- var _props$color;
12011
+ var _cachedLayout$lines, _cachedLayout$totalHe, _props$color;
11786
12012
  const { text, fontStyle, warp, hAlign, vAlign, width, height, left = 0, top = 0, cellValueType } = props;
11787
- const skeleton = _skeleton !== null && _skeleton !== void 0 ? _skeleton : new DocSimpleSkeleton(text, fontStyle, Boolean(warp), width, vAlign === VerticalAlign.TOP ? height : Infinity);
11788
- const lines = skeleton.calculate();
11789
- const totalHeight = skeleton.getTotalHeight();
12013
+ const cachedLayout = !_skeleton && !warp ? Text._getCachedLayout(text, fontStyle) : null;
12014
+ const skeleton = cachedLayout ? null : _skeleton !== null && _skeleton !== void 0 ? _skeleton : new DocSimpleSkeleton(text, fontStyle, Boolean(warp), width, vAlign === VerticalAlign.TOP ? height : Infinity);
12015
+ const lines = (_cachedLayout$lines = cachedLayout === null || cachedLayout === void 0 ? void 0 : cachedLayout.lines) !== null && _cachedLayout$lines !== void 0 ? _cachedLayout$lines : skeleton.calculate();
12016
+ const totalHeight = (_cachedLayout$totalHe = cachedLayout === null || cachedLayout === void 0 ? void 0 : cachedLayout.totalHeight) !== null && _cachedLayout$totalHe !== void 0 ? _cachedLayout$totalHe : skeleton.getTotalHeight();
11790
12017
  let lineTop = top + (vAlign === VerticalAlign.TOP ? 0 : vAlign === VerticalAlign.MIDDLE ? (height - totalHeight) / 2 : height - totalHeight);
11791
12018
  ctx.save();
11792
12019
  ctx.font = fontStyle;
@@ -11837,6 +12064,46 @@ var Text = class Text extends Shape {
11837
12064
  ctx.restore();
11838
12065
  return totalHeight;
11839
12066
  }
12067
+ static drawPlainWith(ctx, props) {
12068
+ var _props$color2;
12069
+ const { text, fontStyle, hAlign, vAlign, width, height, left = 0, top = 0, cellValueType } = props;
12070
+ const { lines, totalHeight } = Text._getCachedLayout(text, fontStyle);
12071
+ let lineTop = top + (vAlign === VerticalAlign.TOP ? 0 : vAlign === VerticalAlign.MIDDLE ? (height - totalHeight) / 2 : height - totalHeight);
12072
+ ctx.font = fontStyle;
12073
+ ctx.fillStyle = (_props$color2 = props.color) !== null && _props$color2 !== void 0 ? _props$color2 : COLOR_BLACK_RGB;
12074
+ for (const line of lines) {
12075
+ const lineWidth = line.width;
12076
+ let lineX = 0;
12077
+ if (!(width < lineWidth && cellValueType === CellValueType.NUMBER)) switch (hAlign) {
12078
+ case HorizontalAlign.CENTER:
12079
+ lineX = (width - lineWidth) / 2;
12080
+ break;
12081
+ case HorizontalAlign.RIGHT:
12082
+ lineX = width - lineWidth;
12083
+ break;
12084
+ default: lineX = 0;
12085
+ }
12086
+ ctx.fillText(line.text, left + lineX, lineTop + line.baseline);
12087
+ lineTop += line.height;
12088
+ }
12089
+ return totalHeight;
12090
+ }
12091
+ static _getCachedLayout(text, fontStyle) {
12092
+ const cacheKey = `${fontStyle}\u0000${text}`;
12093
+ const cached = Text._layoutCache.get(cacheKey);
12094
+ if (cached) return cached;
12095
+ const skeleton = new DocSimpleSkeleton(text, fontStyle, false, 0, Infinity);
12096
+ const layout = {
12097
+ lines: skeleton.calculate(),
12098
+ totalHeight: skeleton.getTotalHeight()
12099
+ };
12100
+ Text._layoutCache.set(cacheKey, layout);
12101
+ if (Text._layoutCache.size > Text._MAX_LAYOUT_CACHE_SIZE) {
12102
+ const oldestKey = Text._layoutCache.keys().next().value;
12103
+ if (oldestKey !== void 0) Text._layoutCache.delete(oldestKey);
12104
+ }
12105
+ return layout;
12106
+ }
11840
12107
  /**
11841
12108
  * Draw text decoration lines (underline, strikethrough, etc.)
11842
12109
  */
@@ -11969,6 +12236,8 @@ var Text = class Text extends Shape {
11969
12236
  };
11970
12237
  }
11971
12238
  };
12239
+ _defineProperty(Text, "_MAX_LAYOUT_CACHE_SIZE", 5e3);
12240
+ _defineProperty(Text, "_layoutCache", /* @__PURE__ */ new Map());
11972
12241
 
11973
12242
  //#endregion
11974
12243
  //#region src/components/docs/document-compatibility.ts
@@ -12446,8 +12715,9 @@ function parseDataStreamToTree(dataStream, tables) {
12446
12715
  };
12447
12716
  }
12448
12717
  var DocumentViewModel = class DocumentViewModel {
12449
- constructor(_documentDataModel) {
12718
+ constructor(_documentDataModel, _tableSource) {
12450
12719
  this._documentDataModel = _documentDataModel;
12720
+ this._tableSource = _tableSource;
12451
12721
  _defineProperty(this, "_interceptor", null);
12452
12722
  _defineProperty(this, "_cacheSize", 1e3);
12453
12723
  _defineProperty(this, "_textRunsCache", /* @__PURE__ */ new Map());
@@ -12625,10 +12895,10 @@ var DocumentViewModel = class DocumentViewModel {
12625
12895
  }
12626
12896
  }
12627
12897
  _buildTableCache() {
12628
- var _this$getBody4;
12898
+ var _this$getBody4, _this$_tableSource;
12629
12899
  this._tableCache.clear();
12630
12900
  const tables = (_this$getBody4 = this.getBody()) === null || _this$getBody4 === void 0 ? void 0 : _this$getBody4.tables;
12631
- const tableConfig = this.getSnapshot().tableSource;
12901
+ const tableConfig = (_this$_tableSource = this._tableSource) !== null && _this$_tableSource !== void 0 ? _this$_tableSource : this.getSnapshot().tableSource;
12632
12902
  if (tables == null || tableConfig == null) return;
12633
12903
  for (const table of tables) {
12634
12904
  const { startIndex, tableId } = table;
@@ -12670,18 +12940,47 @@ var DocumentViewModel = class DocumentViewModel {
12670
12940
  _buildHeaderFooterViewModel() {
12671
12941
  const { headerModelMap, footerModelMap } = this._documentDataModel;
12672
12942
  const viewModels = [];
12943
+ const tableSource = this.getSnapshot().tableSource;
12673
12944
  for (const [headerId, headerModel] of headerModelMap) {
12674
- this._headerTreeMap.set(headerId, new DocumentViewModel(headerModel));
12945
+ this._headerTreeMap.set(headerId, new DocumentViewModel(headerModel, tableSource));
12675
12946
  viewModels.push(this._headerTreeMap.get(headerId));
12676
12947
  }
12677
12948
  for (const [footerId, footerModel] of footerModelMap) {
12678
- this._footerTreeMap.set(footerId, new DocumentViewModel(footerModel));
12949
+ this._footerTreeMap.set(footerId, new DocumentViewModel(footerModel, tableSource));
12679
12950
  viewModels.push(this._footerTreeMap.get(footerId));
12680
12951
  }
12681
12952
  this._segmentViewModels$.next(viewModels);
12682
12953
  }
12683
12954
  };
12684
12955
 
12956
+ //#endregion
12957
+ //#region src/components/docs/custom-block-render-viewport.ts
12958
+ let docsCustomBlockRenderViewportProvider = null;
12959
+ const docsCustomBlockRenderViewportProviders = /* @__PURE__ */ new Set();
12960
+ function setDocsCustomBlockRenderViewportProvider(provider) {
12961
+ if (provider == null) {
12962
+ docsCustomBlockRenderViewportProvider = null;
12963
+ docsCustomBlockRenderViewportProviders.clear();
12964
+ return () => {};
12965
+ }
12966
+ docsCustomBlockRenderViewportProvider = provider;
12967
+ docsCustomBlockRenderViewportProviders.add(provider);
12968
+ return () => {
12969
+ var _providers;
12970
+ docsCustomBlockRenderViewportProviders.delete(provider);
12971
+ const providers = Array.from(docsCustomBlockRenderViewportProviders);
12972
+ docsCustomBlockRenderViewportProvider = (_providers = providers[providers.length - 1]) !== null && _providers !== void 0 ? _providers : null;
12973
+ };
12974
+ }
12975
+ function getDocsCustomBlockRenderViewport(unitId, blockId, input) {
12976
+ const providers = docsCustomBlockRenderViewportProviders.size ? Array.from(docsCustomBlockRenderViewportProviders).reverse() : docsCustomBlockRenderViewportProvider ? [docsCustomBlockRenderViewportProvider] : [];
12977
+ for (const provider of providers) {
12978
+ const viewport = provider(unitId, blockId, input);
12979
+ if (viewport != null) return viewport;
12980
+ }
12981
+ return null;
12982
+ }
12983
+
12685
12984
  //#endregion
12686
12985
  //#region src/components/docs/layout/model/glyph.ts
12687
12986
  function isSpace(char) {
@@ -12692,7 +12991,7 @@ function isSpace(char) {
12692
12991
  ].includes(char);
12693
12992
  }
12694
12993
  function isJustifiable(content) {
12695
- return isSpace(content) || hasCJKText(content) || isCjkLeftAlignedPunctuation(content) || isCjkRightAlignedPunctuation(content) || isCjkCenterAlignedPunctuation(content);
12994
+ return isSpace(content) || cjk.hasCJKText(content) || isCjkLeftAlignedPunctuation(content) || isCjkRightAlignedPunctuation(content) || isCjkCenterAlignedPunctuation(content);
12696
12995
  }
12697
12996
  function baseAdjustability(content, width) {
12698
12997
  if (isSpace(content)) return {
@@ -12821,7 +13120,7 @@ function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, gly
12821
13120
  const { width: contentWidth = 0 } = bBox;
12822
13121
  let width = glyphWidth !== null && glyphWidth !== void 0 ? glyphWidth : contentWidth;
12823
13122
  if (validationGrid(gridType, snapToGrid)) {
12824
- width = contentWidth + (hasCJK(content) ? charSpace : charSpace / 2);
13123
+ width = contentWidth + (cjk.hasCJK(content) ? charSpace : charSpace / 2);
12825
13124
  if (gridType === GridType.SNAP_TO_CHARS) xOffset = (width - contentWidth) / 2;
12826
13125
  }
12827
13126
  if (glyphInfo && glyphInfo.kerning !== 0 && glyphInfo.font) {
@@ -13717,6 +14016,12 @@ function isBeyondDivideWidth(width, divideWidth) {
13717
14016
  const tolerance = Math.min(MAX_LINE_WIDTH_TOLERANCE, Math.max(MIN_LINE_WIDTH_TOLERANCE, divideWidth * RELATIVE_LINE_WIDTH_TOLERANCE));
13718
14017
  return width - divideWidth > tolerance;
13719
14018
  }
14019
+ function isGlyphGroupBeyondDivideWidth(glyphGroup, offsetLeft, divideWidth) {
14020
+ var _glyphGroup$adjustabi, _glyphGroup;
14021
+ const width = __getGlyphGroupWidth(glyphGroup);
14022
+ const trailingShrinkability = (_glyphGroup$adjustabi = (_glyphGroup = glyphGroup[glyphGroup.length - 1]) === null || _glyphGroup === void 0 || (_glyphGroup = _glyphGroup.adjustability) === null || _glyphGroup === void 0 || (_glyphGroup = _glyphGroup.shrinkability) === null || _glyphGroup === void 0 ? void 0 : _glyphGroup[1]) !== null && _glyphGroup$adjustabi !== void 0 ? _glyphGroup$adjustabi : 0;
14023
+ return isBeyondDivideWidth(offsetLeft + width - trailingShrinkability, divideWidth);
14024
+ }
13720
14025
  function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal") {
13721
14026
  if (isParagraphFirstShapedText) if (paragraphConfig.bulletSkeleton) {
13722
14027
  var _paragraphProperties$;
@@ -13793,12 +14098,11 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13793
14098
  const divideInfo = getLastNotFullDivideInfo(getLastPage(pages));
13794
14099
  if (divideInfo) {
13795
14100
  var _divide$glyphGroup;
13796
- const width = __getGlyphGroupWidth(glyphGroup);
13797
14101
  const { divide, isLast } = divideInfo;
13798
14102
  const lastGlyph = divide === null || divide === void 0 || (_divide$glyphGroup = divide.glyphGroup) === null || _divide$glyphGroup === void 0 ? void 0 : _divide$glyphGroup[divide.glyphGroup.length - 1];
13799
14103
  const preOffsetLeft = ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.width) || 0) + ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.left) || 0);
13800
14104
  const { hyphenationZone } = sectionBreakConfig;
13801
- if (isBeyondDivideWidth(preOffsetLeft + width, divide.width)) {
14105
+ if (isGlyphGroupBeyondDivideWidth(glyphGroup, preOffsetLeft, divide.width)) {
13802
14106
  if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0 && glyphGroup.length > 0 && glyphGroup[0].streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) {
13803
14107
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13804
14108
  updateDivideInfo(divide, { breakType: breakPointType });
@@ -13821,7 +14125,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13821
14125
  const sliceGlyphGroup = [];
13822
14126
  while (glyphGroup.length) {
13823
14127
  sliceGlyphGroup.push(glyphGroup.shift());
13824
- if (isBeyondDivideWidth(__getGlyphGroupWidth(sliceGlyphGroup), divide.width)) {
14128
+ if (isGlyphGroupBeyondDivideWidth(sliceGlyphGroup, 0, divide.width)) {
13825
14129
  if (sliceGlyphGroup.length > 1) glyphGroup.unshift(sliceGlyphGroup.pop());
13826
14130
  break;
13827
14131
  }
@@ -13872,7 +14176,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13872
14176
  if (anchorDrawings.length > 0) {
13873
14177
  var _paragraphConfig$para, _paragraphConfig$pDra;
13874
14178
  const paragraphAnchorLeft = __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, (_paragraphConfig$para = paragraphConfig.paragraphStyle) === null || _paragraphConfig$para === void 0 ? void 0 : _paragraphConfig$para.indentStart);
13875
- 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);
14179
+ const drawings = __getDrawingPosition(ctx, 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, false);
13876
14180
  __updateDrawingPosition(currentLine.parent, drawings);
13877
14181
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13878
14182
  updateDivideInfo(divide, { breakType: breakPointType });
@@ -13972,6 +14276,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13972
14276
  }
13973
14277
  }
13974
14278
  let deferredInlineGroupAnchorDrawings = [];
14279
+ let deferredTopBottomAnchorDrawings = [];
13975
14280
  if (paragraphNonInlineSkeDrawings != null && paragraphNonInlineSkeDrawings.size > 0) {
13976
14281
  var _pDrawingAnchor$get;
13977
14282
  let targetDrawings = [...paragraphNonInlineSkeDrawings.values()].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom !== ObjectRelativeFromV.LINE);
@@ -13979,13 +14284,17 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13979
14284
  deferredInlineGroupAnchorDrawings = targetDrawings.filter((drawing) => glyphGroupCustomBlockIds.has(drawing.drawingId) && drawing.drawingOrigin.docTransform.positionV.relativeFrom === ObjectRelativeFromV.LINE);
13980
14285
  targetDrawings = targetDrawings.filter((drawing) => !deferredInlineGroupAnchorDrawings.includes(drawing));
13981
14286
  }
13982
- __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get === void 0 ? void 0 : _pDrawingAnchor$get.top, paragraphAnchorLeft);
14287
+ deferredTopBottomAnchorDrawings = targetDrawings.filter((drawing) => glyphGroupCustomBlockIds.has(drawing.drawingId) && drawing.drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM);
14288
+ targetDrawings = targetDrawings.filter((drawing) => drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM);
14289
+ __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get === void 0 ? void 0 : _pDrawingAnchor$get.top, paragraphAnchorLeft, false, deferredTopBottomAnchorDrawings.length > 0);
13983
14290
  }
13984
14291
  if (skeTablesInParagraph != null && skeTablesInParagraph.length > 0) {
13985
14292
  var _pDrawingAnchor$get2;
13986
14293
  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);
13987
14294
  }
13988
- const newLineTop = positionedCustomBlockOnly ? lineTop : calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage);
14295
+ const calculatedLineTop = positionedCustomBlockOnly ? lineTop : calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage);
14296
+ const previousTopBottomCustomBlockFlowBottom = deferredTopBottomAnchorDrawings.length > 0 ? paragraphConfig.topBottomCustomBlockFlowBottom : void 0;
14297
+ const newLineTop = previousTopBottomCustomBlockFlowBottom == null ? calculatedLineTop : Math.max(calculatedLineTop, previousTopBottomCustomBlockFlowBottom);
13989
14298
  if (lineHeight + newLineTop - section.height > LINE_LAYOUT_OVERFLOW_TOLERANCE && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
13990
14299
  setColumnFullState(column, true);
13991
14300
  _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
@@ -14019,16 +14328,21 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
14019
14328
  }, column.width, lineIndex, isParagraphFirstShapedText, paragraphConfig, lastPage, headerPage, footerPage);
14020
14329
  column.lines.push(newLine);
14021
14330
  newLine.parent = column;
14022
- createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor);
14331
+ const blockAnchorTop = deferredTopBottomAnchorDrawings.length > 0 ? newLineTop : lineTop;
14332
+ createAndUpdateBlockAnchor(paragraphIndex, newLine, blockAnchorTop, pDrawingAnchor);
14333
+ if (deferredTopBottomAnchorDrawings.length > 0) {
14334
+ __updateAndPositionDrawings(ctx, newLineTop, lineHeight, column, deferredTopBottomAnchorDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, blockAnchorTop, paragraphAnchorLeft, true, true);
14335
+ __updateTopBottomCustomBlockFlowBottom(paragraphConfig, deferredTopBottomAnchorDrawings);
14336
+ }
14023
14337
  _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
14024
14338
  if (deferredInlineGroupAnchorDrawings.length > 0) {
14025
14339
  var _pDrawingAnchor$get3;
14026
14340
  __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, deferredInlineGroupAnchorDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get3 = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get3 === void 0 ? void 0 : _pDrawingAnchor$get3.top, paragraphAnchorLeft, true);
14027
14341
  }
14028
14342
  }
14029
- function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop, drawingAnchorLeft = 0, skipRelayoutCheck = false) {
14343
+ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop, drawingAnchorLeft = 0, skipRelayoutCheck = false, overwriteTopBottomPosition = false) {
14030
14344
  if (targetDrawings.length === 0) return;
14031
- const drawings = __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
14345
+ const drawings = __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
14032
14346
  if (drawings == null || drawings.size === 0) return;
14033
14347
  const floatObjects = [...drawings.values()].filter((drawing) => {
14034
14348
  const layoutType = drawing.drawingOrigin.layoutType;
@@ -14050,7 +14364,7 @@ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDra
14050
14364
  };
14051
14365
  });
14052
14366
  if (!skipRelayoutCheck) _reLayoutCheck(ctx, floatObjects, column, paragraphIndex);
14053
- __updateDrawingPosition(column, drawings);
14367
+ __updateDrawingPosition(column, drawings, overwriteTopBottomPosition);
14054
14368
  }
14055
14369
  function __updateWrapTablePosition(ctx, table, lineTop, lineHeight, column, paragraphIndex, drawingAnchorTop) {
14056
14370
  const wrapTablePosition = __getWrapTablePosition(table, column, lineTop, lineHeight, drawingAnchorTop);
@@ -14161,6 +14475,15 @@ function _getCustomBlockIdsInLine(line) {
14161
14475
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) customBlockIds.push(glyph.drawingId);
14162
14476
  return customBlockIds;
14163
14477
  }
14478
+ function __updateTopBottomCustomBlockFlowBottom(paragraphConfig, drawings) {
14479
+ for (const drawing of drawings) {
14480
+ var _drawingOrigin$distB, _paragraphConfig$topB;
14481
+ const { drawingOrigin } = drawing;
14482
+ if (drawingOrigin.layoutType !== PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM || drawingOrigin.behindDoc === BooleanNumber.TRUE) continue;
14483
+ const bottom = drawing.aTop + drawing.height + ((_drawingOrigin$distB = drawingOrigin.distB) !== null && _drawingOrigin$distB !== void 0 ? _drawingOrigin$distB : 0);
14484
+ paragraphConfig.topBottomCustomBlockFlowBottom = Math.max((_paragraphConfig$topB = paragraphConfig.topBottomCustomBlockFlowBottom) !== null && _paragraphConfig$topB !== void 0 ? _paragraphConfig$topB : Number.NEGATIVE_INFINITY, bottom);
14485
+ }
14486
+ }
14164
14487
  function __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings) {
14165
14488
  return __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings).length > 0;
14166
14489
  }
@@ -14364,7 +14687,8 @@ function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitc
14364
14687
  }
14365
14688
  const usesDocumentGrid = spacingRule === SpacingRule.AUTO && snapToGrid === BooleanNumber.TRUE && gridType !== GridType.DEFAULT;
14366
14689
  if (spacingRule === SpacingRule.AUTO) {
14367
- const lineSpacingApply = usesDocumentGrid ? lineSpacing * linePitch : scaleAutoLineSpacingByGlyphHeight ? lineSpacing * glyphLineHeight : glyphLineHeight;
14690
+ let lineSpacingApply = usesDocumentGrid ? lineSpacing * linePitch : scaleAutoLineSpacingByGlyphHeight ? lineSpacing * glyphLineHeight : glyphLineHeight;
14691
+ if (!usesDocumentGrid && scaleAutoLineSpacingByGlyphHeight && lineSpacing <= 1.05 && glyphLineHeight >= 30) lineSpacingApply *= 1.18;
14368
14692
  const padding = (lineSpacingApply - glyphLineHeight) / 2;
14369
14693
  return {
14370
14694
  paddingTop: padding,
@@ -14392,7 +14716,7 @@ function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitc
14392
14716
  lineSpacingApply: exactLineSpacingApply
14393
14717
  };
14394
14718
  }
14395
- function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnchorTop, paragraphNonInlineSkeDrawings) {
14719
+ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId = "", blockAnchorTop, paragraphNonInlineSkeDrawings) {
14396
14720
  var _line$parent, _section$top;
14397
14721
  const column = line.parent;
14398
14722
  const section = column === null || column === void 0 ? void 0 : column.parent;
@@ -14404,6 +14728,7 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14404
14728
  const sectionTop = (_section$top = section === null || section === void 0 ? void 0 : section.top) !== null && _section$top !== void 0 ? _section$top : 0;
14405
14729
  const lineTop = sectionTop + top;
14406
14730
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0) {
14731
+ var _viewport$width, _viewport$height, _viewport$offsetLeft;
14407
14732
  const { drawingId } = glyph;
14408
14733
  if (drawingId == null) continue;
14409
14734
  const drawing = paragraphInlineSkeDrawings === null || paragraphInlineSkeDrawings === void 0 ? void 0 : paragraphInlineSkeDrawings.get(drawingId);
@@ -14413,7 +14738,19 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14413
14738
  const { size, angle } = docTransform;
14414
14739
  const { width = 0, height = 0 } = size;
14415
14740
  const glyphHeight = glyph.bBox.bd + glyph.bBox.ba;
14416
- drawing.aLeft = column.left + divide.left + divide.paddingLeft + glyph.left + .5 * glyph.width - .5 * width || 0;
14741
+ const glyphLeft = divide.left + divide.paddingLeft + glyph.left;
14742
+ const blockLeft = column.left + glyphLeft;
14743
+ const viewport = getDocsCustomBlockRenderViewport(unitId, drawingId, {
14744
+ blockLeft,
14745
+ fallbackHeight: height,
14746
+ fallbackWidth: width,
14747
+ pageMarginLeft: page.marginLeft,
14748
+ pageMarginRight: page.marginRight,
14749
+ pageWidth: page.pageWidth
14750
+ });
14751
+ const drawingWidth = (_viewport$width = viewport === null || viewport === void 0 ? void 0 : viewport.width) !== null && _viewport$width !== void 0 ? _viewport$width : width;
14752
+ const drawingHeight = (_viewport$height = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _viewport$height !== void 0 ? _viewport$height : height;
14753
+ drawing.aLeft = viewport ? blockLeft + ((_viewport$offsetLeft = viewport.offsetLeft) !== null && _viewport$offsetLeft !== void 0 ? _viewport$offsetLeft : 0) : blockLeft + .5 * glyph.width - .5 * drawingWidth || 0;
14417
14754
  if (glyph.width > divide.width) {
14418
14755
  var _paragraphNonInlineSk;
14419
14756
  for (const positionedDrawing of (_paragraphNonInlineSk = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.values()) !== null && _paragraphNonInlineSk !== void 0 ? _paragraphNonInlineSk : []) {
@@ -14423,17 +14760,25 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14423
14760
  const lineBottom = lineTop + lineHeight;
14424
14761
  if (positionedDrawing.aTop >= lineBottom || positionedBottom <= lineTop) continue;
14425
14762
  const positionedRight = positionedDrawing.aLeft + positionedDrawing.width;
14426
- const drawingRight = drawing.aLeft + width;
14763
+ const drawingRight = drawing.aLeft + drawingWidth;
14427
14764
  if (positionedDrawing.aLeft < drawingRight && positionedRight > drawing.aLeft) {
14428
14765
  var _positionedOrigin$dis;
14429
14766
  drawing.aLeft = Math.max(drawing.aLeft, positionedDrawing.aLeft + positionedDrawing.width + ((_positionedOrigin$dis = positionedOrigin.distR) !== null && _positionedOrigin$dis !== void 0 ? _positionedOrigin$dis : 0));
14430
14767
  }
14431
14768
  }
14432
14769
  }
14433
- drawing.aTop = lineTop + lineHeight - .5 * glyphHeight - .5 * height - marginBottom;
14434
- drawing.width = width;
14435
- drawing.height = height;
14770
+ drawing.width = drawingWidth;
14771
+ drawing.height = drawingHeight;
14772
+ drawing.aTop = lineTop + lineHeight - .5 * glyphHeight - .5 * drawingHeight - marginBottom;
14436
14773
  drawing.angle = angle;
14774
+ drawing.customBlockRenderViewport = viewport ? {
14775
+ bleedLeft: viewport.bleedLeft,
14776
+ bleedWidth: viewport.bleedWidth,
14777
+ contentHeight: viewport.contentHeight,
14778
+ contentWidth: viewport.contentWidth,
14779
+ height: viewport.height,
14780
+ viewportHeight: viewport.viewportHeight
14781
+ } : void 0;
14437
14782
  drawing.isPageBreak = isPageBreak;
14438
14783
  drawing.lineTop = lineTop;
14439
14784
  drawing.columnLeft = column.left;
@@ -14443,7 +14788,7 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14443
14788
  }
14444
14789
  page.skeDrawings = new Map([...page.skeDrawings, ...drawings]);
14445
14790
  }
14446
- function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = [], blockAnchorLeft = 0) {
14791
+ function __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = [], blockAnchorLeft = 0, normalizeTraditionalColumnAnchor = true) {
14447
14792
  var _column$parent3;
14448
14793
  const page = (_column$parent3 = column.parent) === null || _column$parent3 === void 0 ? void 0 : _column$parent3.parent;
14449
14794
  if (page == null || needPositionDrawings.length === 0) return;
@@ -14451,22 +14796,42 @@ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShape
14451
14796
  const isPageBreak = __checkPageBreak(column);
14452
14797
  if (isPageBreak && !isParagraphFirstShapedText) return;
14453
14798
  for (const drawing of needPositionDrawings) {
14454
- var _getPositionHorizon2, _getPositionVertical2;
14799
+ var _ctx$dataModel$getUni, _ctx$dataModel$getUni2, _ctx$dataModel, _viewport$width2, _viewport$height2, _getPositionHorizon2, _getPositionVertical2;
14455
14800
  const { drawingOrigin } = drawing;
14456
14801
  if (!drawingOrigin) continue;
14457
14802
  const { docTransform } = drawingOrigin;
14458
14803
  const { positionH, positionV, size, angle } = docTransform;
14459
- const { width = 0, height = 0 } = size;
14460
- let aLeft = (_getPositionHorizon2 = getPositionHorizon(positionH, column, page, width, isPageBreak)) !== null && _getPositionHorizon2 !== void 0 ? _getPositionHorizon2 : 0;
14804
+ const { width, height } = size;
14805
+ const fallbackWidth = width !== null && width !== void 0 ? width : 0;
14806
+ const fallbackHeight = height !== null && height !== void 0 ? height : 0;
14807
+ const viewport = drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM ? getDocsCustomBlockRenderViewport((_ctx$dataModel$getUni = (_ctx$dataModel$getUni2 = (_ctx$dataModel = ctx.dataModel).getUnitId) === null || _ctx$dataModel$getUni2 === void 0 ? void 0 : _ctx$dataModel$getUni2.call(_ctx$dataModel)) !== null && _ctx$dataModel$getUni !== void 0 ? _ctx$dataModel$getUni : "", drawing.drawingId, {
14808
+ fallbackHeight,
14809
+ fallbackWidth,
14810
+ pageMarginLeft: page.marginLeft,
14811
+ pageMarginRight: page.marginRight,
14812
+ pageWidth: page.pageWidth
14813
+ }) : null;
14814
+ const drawingWidth = (_viewport$width2 = viewport === null || viewport === void 0 ? void 0 : viewport.width) !== null && _viewport$width2 !== void 0 ? _viewport$width2 : fallbackWidth;
14815
+ const drawingHeight = (_viewport$height2 = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _viewport$height2 !== void 0 ? _viewport$height2 : fallbackHeight;
14816
+ let aLeft = (_getPositionHorizon2 = getPositionHorizon(positionH, column, page, drawingWidth, isPageBreak)) !== null && _getPositionHorizon2 !== void 0 ? _getPositionHorizon2 : 0;
14461
14817
  if (positionH.relativeFrom === ObjectRelativeFromH.COLUMN && blockAnchorLeft > 0) {
14462
14818
  const renderedColumnOrigin = isPageBreak ? 0 : column.left || page.marginLeft;
14463
14819
  aLeft += blockAnchorLeft - renderedColumnOrigin;
14820
+ if (normalizeTraditionalColumnAnchor && ctx.dataModel.documentStyle.documentFlavor === DocumentFlavor.TRADITIONAL && positionV.relativeFrom === ObjectRelativeFromV.PARAGRAPH) aLeft -= page.marginLeft;
14464
14821
  }
14465
14822
  drawing.aLeft = aLeft;
14466
- drawing.aTop = (_getPositionVertical2 = getPositionVertical(positionV, page, lineTop, lineHeight, height, blockAnchorTop, isPageBreak)) !== null && _getPositionVertical2 !== void 0 ? _getPositionVertical2 : 0;
14467
- drawing.width = width;
14468
- drawing.height = height;
14823
+ drawing.aTop = (_getPositionVertical2 = getPositionVertical(positionV, page, lineTop, lineHeight, drawingHeight, blockAnchorTop, isPageBreak)) !== null && _getPositionVertical2 !== void 0 ? _getPositionVertical2 : 0;
14824
+ drawing.width = drawingWidth;
14825
+ drawing.height = drawingHeight;
14469
14826
  drawing.angle = angle;
14827
+ drawing.customBlockRenderViewport = viewport ? {
14828
+ bleedLeft: viewport.bleedLeft,
14829
+ bleedWidth: viewport.bleedWidth,
14830
+ contentHeight: viewport.contentHeight,
14831
+ contentWidth: viewport.contentWidth,
14832
+ height: viewport.height,
14833
+ viewportHeight: viewport.viewportHeight
14834
+ } : void 0;
14470
14835
  drawing.initialState = true;
14471
14836
  drawing.columnLeft = column.left;
14472
14837
  drawing.lineTop = lineTop;
@@ -14477,16 +14842,18 @@ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShape
14477
14842
  }
14478
14843
  return drawings;
14479
14844
  }
14480
- function __updateDrawingPosition(column, drawings) {
14845
+ function __updateDrawingPosition(column, drawings, overwriteTopBottomPosition = false) {
14481
14846
  var _column$parent4;
14482
14847
  const page = (_column$parent4 = column.parent) === null || _column$parent4 === void 0 ? void 0 : _column$parent4.parent;
14483
14848
  if (drawings == null || drawings.size === 0 || page == null) return;
14484
14849
  for (const drawing of drawings.values()) {
14485
14850
  const originDrawing = page.skeDrawings.get(drawing.drawingId);
14486
- if (originDrawing) if (originDrawing.drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) {
14851
+ if (originDrawing) if (originDrawing.drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) if (overwriteTopBottomPosition) page.skeDrawings.set(drawing.drawingId, drawing);
14852
+ else {
14487
14853
  const lowerDrawing = originDrawing.aTop > drawing.aTop ? originDrawing : drawing;
14488
14854
  page.skeDrawings.set(drawing.drawingId, lowerDrawing);
14489
- } else page.skeDrawings.set(drawing.drawingId, drawing);
14855
+ }
14856
+ else page.skeDrawings.set(drawing.drawingId, drawing);
14490
14857
  else page.skeDrawings.set(drawing.drawingId, drawing);
14491
14858
  }
14492
14859
  }
@@ -14815,7 +15182,10 @@ function updateInlineDrawingCoordsAndBorder(ctx, pages) {
14815
15182
  const affectInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphInlineSkeDrawings;
14816
15183
  const affectNonInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphNonInlineSkeDrawings;
14817
15184
  const drawingAnchor = (_ctx$skeletonResource = ctx.skeletonResourceReference) === null || _ctx$skeletonResource === void 0 || (_ctx$skeletonResource = _ctx$skeletonResource.drawingAnchor) === null || _ctx$skeletonResource === void 0 || (_ctx$skeletonResource = _ctx$skeletonResource.get(segmentId)) === null || _ctx$skeletonResource === void 0 ? void 0 : _ctx$skeletonResource.get(line.paragraphIndex);
14818
- if (affectInlineDrawings && affectInlineDrawings.size > 0) updateInlineDrawingPosition(line, affectInlineDrawings, drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top, affectNonInlineDrawings);
15185
+ if (affectInlineDrawings && affectInlineDrawings.size > 0) {
15186
+ var _ctx$dataModel$getUni, _ctx$dataModel$getUni2, _ctx$dataModel;
15187
+ updateInlineDrawingPosition(line, affectInlineDrawings, (_ctx$dataModel$getUni = (_ctx$dataModel$getUni2 = (_ctx$dataModel = ctx.dataModel).getUnitId) === null || _ctx$dataModel$getUni2 === void 0 ? void 0 : _ctx$dataModel$getUni2.call(_ctx$dataModel)) !== null && _ctx$dataModel$getUni !== void 0 ? _ctx$dataModel$getUni : "", drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top, affectNonInlineDrawings);
15188
+ }
14819
15189
  const paragraphStyle = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphStyle;
14820
15190
  const paragraphBackgroundColor = paragraphStyle === null || paragraphStyle === void 0 || (_paragraphStyle$shadi = paragraphStyle.shading) === null || _paragraphStyle$shadi === void 0 ? void 0 : _paragraphStyle$shadi.backgroundColor;
14821
15191
  if (paragraphBackgroundColor) line.backgroundColor = paragraphBackgroundColor;
@@ -14859,10 +15229,10 @@ function lineIterator(pagesOrCells, cb) {
14859
15229
  }
14860
15230
  }
14861
15231
  function documentSkeletonTableIterator(pages, options = {}) {
14862
- const { docsLeft = 0, docsTop = 0, pageMarginTop = 0, resolveViewport = true, tableCellInsetX = 0, unitId = "" } = options;
15232
+ const { docsLeft = 0, docsTop = 0, pageMarginTop = 0, resolveViewport = true, skeFooters, skeHeaders, tableCellInsetX = 0, unitId = "" } = options;
14863
15233
  const contexts = [];
14864
15234
  pages.forEach((rootPage, pageIndex) => {
14865
- var _rootPage$skeColumnGr;
15235
+ var _skeHeaders$get, _skeFooters$get, _rootPage$skeColumnGr;
14866
15236
  const rootPageTop = ((rootPage.pageHeight === Infinity ? 0 : rootPage.pageHeight) + pageMarginTop) * pageIndex + rootPage.marginTop + docsTop;
14867
15237
  const rootPageLeft = rootPage.marginLeft + docsLeft;
14868
15238
  collectPageTables({
@@ -14878,6 +15248,36 @@ function documentSkeletonTableIterator(pages, options = {}) {
14878
15248
  tableCellInsetX,
14879
15249
  unitId
14880
15250
  });
15251
+ const rootPageDocumentTop = rootPageTop - rootPage.marginTop;
15252
+ const rootPageDocumentLeft = docsLeft + rootPage.marginLeft;
15253
+ 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);
15254
+ if (headerPage != null) collectPageTables({
15255
+ contexts,
15256
+ docsLeft,
15257
+ page: headerPage,
15258
+ pageIndex,
15259
+ pageLeft: rootPageDocumentLeft,
15260
+ pageTop: rootPageDocumentTop + headerPage.marginTop,
15261
+ rootPage,
15262
+ source: "header",
15263
+ resolveViewport,
15264
+ tableCellInsetX,
15265
+ unitId
15266
+ });
15267
+ 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);
15268
+ if (footerPage != null) collectPageTables({
15269
+ contexts,
15270
+ docsLeft,
15271
+ page: footerPage,
15272
+ pageIndex,
15273
+ pageLeft: rootPageDocumentLeft,
15274
+ pageTop: rootPageDocumentTop + rootPage.pageHeight - footerPage.height - footerPage.marginBottom,
15275
+ rootPage,
15276
+ source: "footer",
15277
+ resolveViewport,
15278
+ tableCellInsetX,
15279
+ unitId
15280
+ });
14881
15281
  (_rootPage$skeColumnGr = rootPage.skeColumnGroups) === null || _rootPage$skeColumnGr === void 0 || _rootPage$skeColumnGr.forEach((columnGroup) => {
14882
15282
  columnGroup.columns.forEach((columnGroupColumn) => {
14883
15283
  const nestedPage = columnGroupColumn.page;
@@ -15280,6 +15680,12 @@ function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig
15280
15680
  if (!hasAddonStyle && originTextRun) fontCreateConfigCache.setValue(st, ed, result);
15281
15681
  return result;
15282
15682
  }
15683
+ function getCustomRangeGlyphWidth(index, viewModel, paragraphNode, config) {
15684
+ const customRange = viewModel.getCustomRange(index + paragraphNode.startIndex);
15685
+ const glyphWidthEm = customRange === null || customRange === void 0 ? void 0 : customRange.glyphWidthEm;
15686
+ if (typeof glyphWidthEm !== "number" || !Number.isFinite(glyphWidthEm) || glyphWidthEm < 0) return;
15687
+ return glyphWidthEm * config.fontStyle.originFontSize;
15688
+ }
15283
15689
  function getNullSkeleton() {
15284
15690
  return {
15285
15691
  pages: [],
@@ -15296,6 +15702,7 @@ function setPageParent(pages, parent) {
15296
15702
  for (const page of pages) page.parent = parent;
15297
15703
  }
15298
15704
  const DEFAULT_SECTION_BREAK = {
15705
+ sectionId: "section_render_default",
15299
15706
  columnProperties: [],
15300
15707
  columnSeparatorType: ColumnSeparatorType.NONE,
15301
15708
  sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,
@@ -15343,6 +15750,11 @@ function prepareSectionBreakConfig(ctx, nodeIndex) {
15343
15750
  let { documentStyle } = dataModel;
15344
15751
  const { documentFlavor } = documentStyle;
15345
15752
  let sectionBreak = viewModel.getSectionBreak(sectionNode.endIndex) || DEFAULT_SECTION_BREAK;
15753
+ const sectionBreaks = viewModel.getChildren().map((node) => viewModel.getSectionBreak(node.endIndex) || DEFAULT_SECTION_BREAK);
15754
+ sectionBreak = {
15755
+ ...sectionBreak,
15756
+ ...resolveSectionHeaderFooterReferences(documentStyle, sectionBreaks, nodeIndex)
15757
+ };
15346
15758
  if (documentFlavor === DocumentFlavor.MODERN) {
15347
15759
  var _documentStyle$pageSi, _documentStyle$pageSi2;
15348
15760
  const modernPageWidth = (_documentStyle$pageSi = (_documentStyle$pageSi2 = documentStyle.pageSize) === null || _documentStyle$pageSi2 === void 0 ? void 0 : _documentStyle$pageSi2.width) !== null && _documentStyle$pageSi !== void 0 ? _documentStyle$pageSi : DEFAULT_MODERN_DOCUMENT_STYLE.pageSize.width;
@@ -15359,7 +15771,7 @@ function prepareSectionBreakConfig(ctx, nodeIndex) {
15359
15771
  vertexAngle: 0,
15360
15772
  wrapStrategy: WrapStrategy.UNSPECIFIED
15361
15773
  } } = documentStyle;
15362
- const { charSpace = 0, linePitch = 15.6, gridType = GridType.LINES, pageNumberStart = global_pageNumberStart, pageSize = global_pageSize, pageOrient = global_pageOrient, marginTop = global_marginTop, marginBottom = global_marginBottom, marginRight = global_marginRight, marginLeft = global_marginLeft, marginHeader = global_marginHeader, marginFooter = global_marginFooter, defaultHeaderId = global_defaultHeaderId, defaultFooterId = global_defaultFooterId, evenPageHeaderId = global_evenPageHeaderId, evenPageFooterId = global_evenPageFooterId, firstPageHeaderId = global_firstPageHeaderId, firstPageFooterId = global_firstPageFooterId, useFirstPageHeaderFooter = global_useFirstPageHeaderFooter, evenAndOddHeaders = global_evenAndOddHeaders, columnProperties = [], columnSeparatorType = ColumnSeparatorType.NONE, contentDirection, sectionType, textDirection, renderConfig = global_renderConfig } = sectionBreak;
15774
+ const { sectionId, charSpace = 0, linePitch = 15.6, gridType = GridType.LINES, pageNumberStart = global_pageNumberStart, pageSize = global_pageSize, pageOrient = global_pageOrient, marginTop = global_marginTop, marginBottom = global_marginBottom, marginRight = global_marginRight, marginLeft = global_marginLeft, marginHeader = global_marginHeader, marginFooter = global_marginFooter, defaultHeaderId = global_defaultHeaderId, defaultFooterId = global_defaultFooterId, evenPageHeaderId = global_evenPageHeaderId, evenPageFooterId = global_evenPageFooterId, firstPageHeaderId = global_firstPageHeaderId, firstPageFooterId = global_firstPageFooterId, useFirstPageHeaderFooter = global_useFirstPageHeaderFooter, evenAndOddHeaders = global_evenAndOddHeaders, columnProperties = [], columnSeparatorType = ColumnSeparatorType.NONE, contentDirection, sectionType, textDirection, renderConfig = global_renderConfig } = sectionBreak;
15363
15775
  const sectionNodeNext = viewModel.getChildren()[nodeIndex + 1];
15364
15776
  const sectionTypeNext = (_viewModel$getSection = viewModel.getSectionBreak(sectionNodeNext === null || sectionNodeNext === void 0 ? void 0 : sectionNodeNext.endIndex)) === null || _viewModel$getSection === void 0 ? void 0 : _viewModel$getSection.sectionType;
15365
15777
  const headerIds = {
@@ -15375,6 +15787,7 @@ function prepareSectionBreakConfig(ctx, nodeIndex) {
15375
15787
  if (pageSize.width === null) pageSize.width = Number.POSITIVE_INFINITY;
15376
15788
  if (pageSize.height === null) pageSize.height = Number.POSITIVE_INFINITY;
15377
15789
  return {
15790
+ sectionId,
15378
15791
  charSpace,
15379
15792
  linePitch,
15380
15793
  gridType,
@@ -15419,20 +15832,22 @@ function getPageFromPath(skeletonData, path) {
15419
15832
  const pageIndex = pathCopy.shift();
15420
15833
  page = skeletonData.pages[pageIndex];
15421
15834
  } else if (field === "skeTables") {
15422
- var _skeTables;
15835
+ var _page$skeTables3;
15836
+ if (page == null) return null;
15423
15837
  const tableId = pathCopy.shift();
15424
15838
  pathCopy.shift();
15425
15839
  const rowIndex = pathCopy.shift();
15426
15840
  pathCopy.shift();
15427
15841
  const cellIndex = pathCopy.shift();
15428
- 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];
15842
+ 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];
15429
15843
  } else if (field === "skeColumnGroups") {
15430
- var _skeColumnGroups;
15844
+ var _page$skeColumnGroups2;
15845
+ if (page == null) return null;
15431
15846
  const columnGroupId = pathCopy.shift();
15432
15847
  pathCopy.shift();
15433
15848
  const columnIndex = pathCopy.shift();
15434
15849
  pathCopy.shift();
15435
- page = (_skeColumnGroups = page.skeColumnGroups) === null || _skeColumnGroups === void 0 || (_skeColumnGroups = _skeColumnGroups.get(columnGroupId)) === null || _skeColumnGroups === void 0 || (_skeColumnGroups = _skeColumnGroups.columns[columnIndex]) === null || _skeColumnGroups === void 0 ? void 0 : _skeColumnGroups.page;
15850
+ 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;
15436
15851
  }
15437
15852
  }
15438
15853
  return page;
@@ -15445,13 +15860,14 @@ function getHeaderFooterMaxHeight(pageHeight) {
15445
15860
  }
15446
15861
  function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, pageNumber = 1, breakType = 0) {
15447
15862
  const page = _getNullPage();
15448
- const { pageNumberStart = 1, pageSize = {
15863
+ const { sectionId, pageNumberStart = 1, pageSize = {
15449
15864
  width: Number.POSITIVE_INFINITY,
15450
15865
  height: Number.POSITIVE_INFINITY
15451
15866
  }, pageOrient = PageOrientType.PORTRAIT, headerIds = {}, footerIds = {}, useFirstPageHeaderFooter, evenAndOddHeaders, footerTreeMap, headerTreeMap, columnProperties = [], columnSeparatorType, marginTop = 0, marginBottom = 0, marginHeader: _marginHeader = 0, marginFooter: _marginFooter = 0, marginLeft = 0, marginRight = 0, renderConfig = {} } = sectionBreakConfig;
15452
15867
  const { skeHeaders, skeFooters } = skeletonResourceReference;
15453
15868
  const { width: pageWidth = Number.POSITIVE_INFINITY, height: pageHeight = Number.POSITIVE_INFINITY } = pageSize;
15454
15869
  page.pageNumber = pageNumber;
15870
+ page.sectionId = sectionId;
15455
15871
  page.pageNumberStart = pageNumberStart;
15456
15872
  page.renderConfig = renderConfig;
15457
15873
  page.marginLeft = marginLeft;
@@ -15499,8 +15915,8 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
15499
15915
  }
15500
15916
  page.originMarginTop = marginTop;
15501
15917
  page.originMarginBottom = marginBottom;
15502
- page.marginTop = _getVerticalMargin(marginTop, header, pageHeight);
15503
- page.marginBottom = _getVerticalMargin(marginBottom, footer, pageHeight);
15918
+ page.marginTop = _getVerticalMargin(marginTop, header);
15919
+ page.marginBottom = _getVerticalMargin(marginBottom, footer);
15504
15920
  const sections = page.sections;
15505
15921
  const lastSection = sections[sections.length - 1];
15506
15922
  const { marginTop: curPageMT, marginBottom: curPageMB, marginLeft: curPageML, marginRight: curPageMR } = page;
@@ -15546,10 +15962,11 @@ function _getNullPage(type = 0, segmentId = "") {
15546
15962
  }
15547
15963
  function _createSkeletonHeaderFooter(ctx, headerOrFooterViewModel, sectionBreakConfig, skeletonResourceReference, segmentId, isHeader = true, areaPage, count = 0) {
15548
15964
  var _sectionBreakConfig$d;
15549
- const { lists, footerTreeMap, headerTreeMap, localeService, pageSize, drawings, marginLeft = 0, marginRight = 0, marginHeader = 0, marginFooter = 0 } = sectionBreakConfig;
15965
+ const { sectionId, lists, footerTreeMap, headerTreeMap, localeService, pageSize, drawings, marginLeft = 0, marginRight = 0, marginHeader = 0, marginFooter = 0 } = sectionBreakConfig;
15550
15966
  const pageWidth = (pageSize === null || pageSize === void 0 ? void 0 : pageSize.width) || Number.POSITIVE_INFINITY;
15551
15967
  const pageHeight = (pageSize === null || pageSize === void 0 ? void 0 : pageSize.height) || Number.POSITIVE_INFINITY;
15552
15968
  const headerFooterConfig = {
15969
+ sectionId,
15553
15970
  lists,
15554
15971
  footerTreeMap,
15555
15972
  headerTreeMap,
@@ -15586,7 +16003,7 @@ function _createSkeletonHeaderFooter(ctx, headerOrFooterViewModel, sectionBreakC
15586
16003
  }
15587
16004
  function createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY) {
15588
16005
  var _ref, _cellConfig$margin, _cellConfig$columnSpa;
15589
- const { lists, footerTreeMap, headerTreeMap, localeService, drawings } = sectionBreakConfig;
16006
+ const { sectionId, lists, footerTreeMap, headerTreeMap, localeService, drawings } = sectionBreakConfig;
15590
16007
  const { skeletonResourceReference } = ctx;
15591
16008
  const { cellMargin, tableRows, tableColumns, tableId } = tableConfig;
15592
16009
  const cellConfig = tableRows[row].tableCells[col];
@@ -15608,6 +16025,7 @@ function createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, avai
15608
16025
  }
15609
16026
  const pageHeight = maxCellPageHeight;
15610
16027
  const cellSectionBreakConfig = {
16028
+ sectionId,
15611
16029
  lists,
15612
16030
  footerTreeMap,
15613
16031
  headerTreeMap,
@@ -15673,8 +16091,10 @@ function applyTrailingBlockRangeSpaceBelow(pages, body, containerEndIndex) {
15673
16091
  page.height += lastLine.spaceBelowApply || trailingBlockRangeSpace;
15674
16092
  }
15675
16093
  }
15676
- function _getVerticalMargin(marginTB, _headerOrFooter, _pageHeight) {
15677
- return marginTB;
16094
+ function _getVerticalMargin(marginTB, headerOrFooter) {
16095
+ if (headerOrFooter == null) return marginTB;
16096
+ const { marginTop = 0, height = 0, marginBottom = 0 } = headerOrFooter;
16097
+ return Math.max(marginTB, marginTop + height + marginBottom);
15678
16098
  }
15679
16099
 
15680
16100
  //#endregion
@@ -15766,7 +16186,7 @@ function getDivideStretchability(divide) {
15766
16186
  function getJustifiables(divide) {
15767
16187
  const justifiables = divide.glyphGroup.filter((glyph) => glyph.isJustifiable).length;
15768
16188
  const lastGlyph = divide.glyphGroup[divide.glyphGroup.length - 1];
15769
- if (hasCJK(lastGlyph.content)) return justifiables - 1;
16189
+ if (cjk.hasCJK(lastGlyph.content)) return justifiables - 1;
15770
16190
  return justifiables;
15771
16191
  }
15772
16192
  function adjustGlyphsInDivide(divide, justificationRatio, extraJustification) {
@@ -15871,7 +16291,7 @@ function horizontalAlignHandler(line, horizontalAlign, allowOverflowHorizontalOf
15871
16291
  function restoreLastCJKGlyphWidth(line) {
15872
16292
  for (const divide of line.divides) {
15873
16293
  const lastGlyph = divide.glyphGroup[divide.glyphGroup.length - 1];
15874
- if (lastGlyph && divide.isFull && hasCJKText(lastGlyph.content) && lastGlyph.width - lastGlyph.xOffset > lastGlyph.bBox.width) {
16294
+ if (lastGlyph && divide.isFull && cjk.hasCJKText(lastGlyph.content) && lastGlyph.width - lastGlyph.xOffset > lastGlyph.bBox.width) {
15875
16295
  const shrinkAmount = lastGlyph.width - lastGlyph.xOffset - lastGlyph.bBox.width;
15876
16296
  lastGlyph.width -= shrinkAmount;
15877
16297
  lastGlyph.adjustability.shrinkability[1] = 0;
@@ -16144,22 +16564,66 @@ function _isDocxColumnBreakVisuallyBlankColumn(column) {
16144
16564
  function _hasOnlyCustomBlockGlyphs(glyphs) {
16145
16565
  return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK);
16146
16566
  }
16147
- function _mergeAdjacentCustomBlockShapedTexts(shapedTextList) {
16567
+ function _mergeAdjacentCustomBlockShapedTexts(shapedTextList, customBlockDrawings) {
16148
16568
  const mergedShapedTextList = [];
16149
- for (const shapedText of shapedTextList) {
16150
- const lastShapedText = mergedShapedTextList[mergedShapedTextList.length - 1];
16151
- if (lastShapedText && _hasOnlyCustomBlockGlyphs(lastShapedText.glyphs) && _hasOnlyCustomBlockGlyphs(shapedText.glyphs)) {
16152
- lastShapedText.text += shapedText.text;
16153
- lastShapedText.glyphs.push(...shapedText.glyphs);
16154
- lastShapedText.breakPointType = shapedText.breakPointType;
16155
- continue;
16569
+ for (const originShapedText of shapedTextList) {
16570
+ const splitShapedTexts = _splitTopBottomCustomBlockShapedText(originShapedText, customBlockDrawings);
16571
+ for (const shapedText of splitShapedTexts) {
16572
+ const lastShapedText = mergedShapedTextList[mergedShapedTextList.length - 1];
16573
+ if (lastShapedText && _hasOnlyCustomBlockGlyphs(lastShapedText.glyphs) && _hasOnlyCustomBlockGlyphs(shapedText.glyphs) && !_hasTopBottomCustomBlockGlyph(lastShapedText.glyphs, customBlockDrawings) && !_hasTopBottomCustomBlockGlyph(shapedText.glyphs, customBlockDrawings)) {
16574
+ lastShapedText.text += shapedText.text;
16575
+ lastShapedText.glyphs.push(...shapedText.glyphs);
16576
+ lastShapedText.breakPointType = shapedText.breakPointType;
16577
+ continue;
16578
+ }
16579
+ mergedShapedTextList.push({
16580
+ ...shapedText,
16581
+ glyphs: [...shapedText.glyphs]
16582
+ });
16156
16583
  }
16157
- mergedShapedTextList.push({
16584
+ }
16585
+ return mergedShapedTextList;
16586
+ }
16587
+ function _splitTopBottomCustomBlockShapedText(shapedText, customBlockDrawings) {
16588
+ const splitShapedTexts = [];
16589
+ let pendingGlyphs = [];
16590
+ let pendingText = "";
16591
+ let textOffset = 0;
16592
+ const flushPending = () => {
16593
+ if (pendingGlyphs.length === 0) return;
16594
+ splitShapedTexts.push({
16158
16595
  ...shapedText,
16159
- glyphs: [...shapedText.glyphs]
16596
+ text: pendingText,
16597
+ glyphs: pendingGlyphs
16160
16598
  });
16599
+ pendingGlyphs = [];
16600
+ pendingText = "";
16601
+ };
16602
+ for (const glyph of shapedText.glyphs) {
16603
+ const glyphText = shapedText.text.slice(textOffset, textOffset + glyph.count);
16604
+ textOffset += glyph.count;
16605
+ if (_isTopBottomCustomBlockGlyph(glyph, customBlockDrawings)) {
16606
+ flushPending();
16607
+ splitShapedTexts.push({
16608
+ ...shapedText,
16609
+ text: glyphText,
16610
+ glyphs: [glyph]
16611
+ });
16612
+ continue;
16613
+ }
16614
+ pendingGlyphs.push(glyph);
16615
+ pendingText += glyphText;
16161
16616
  }
16162
- return mergedShapedTextList;
16617
+ flushPending();
16618
+ return splitShapedTexts.length > 0 ? splitShapedTexts : [shapedText];
16619
+ }
16620
+ function _hasTopBottomCustomBlockGlyph(glyphs, customBlockDrawings) {
16621
+ return glyphs.some((glyph) => _isTopBottomCustomBlockGlyph(glyph, customBlockDrawings));
16622
+ }
16623
+ function _isTopBottomCustomBlockGlyph(glyph, customBlockDrawings) {
16624
+ var _customBlockDrawings$;
16625
+ if (glyph.streamType !== DataStreamTreeTokenType.CUSTOM_BLOCK || glyph.drawingId == null) return false;
16626
+ return ((_customBlockDrawings$ = customBlockDrawings.get(glyph.drawingId)) === null || _customBlockDrawings$ === void 0 ? void 0 : _customBlockDrawings$.drawingOrigin.layoutType) === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM;
16163
16627
  }
16164
16628
  function _getListLevelAncestors(bullet, listLevel) {
16165
16629
  if (!bullet || !listLevel) return;
@@ -16205,26 +16669,17 @@ function _hasNextAdjacentLayoutBlockRange(blockRanges, blockRange) {
16205
16669
  const nextBlockRange = _getNextAdjacentBlockRange(blockRanges, blockRange);
16206
16670
  return nextBlockRange != null && BLOCK_LAYOUT_OUTER_SPACING_MAP.has(nextBlockRange.blockType) && nextBlockRange.startIndex === blockRange.endIndex + 1;
16207
16671
  }
16208
- function _applyDefaultLayoutParagraphStyle(style, hasBlockRange) {
16209
- if (style.lineSpacing == null) style.lineSpacing = DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING;
16210
- if (hasBlockRange) return;
16211
- if (style.spaceAbove == null) style.spaceAbove = { v: DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE };
16212
- if (style.spaceBelow == null) style.spaceBelow = { v: DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW };
16213
- }
16214
- function _applyBlockRangeLayoutParagraphStyle(body, paragraph, paragraphStyle, shouldApplyDocumentDefaults) {
16672
+ function _applyBlockRangeLayoutParagraphStyle(body, paragraph, paragraphStyle, documentStyle, useLegacyModernDefaults) {
16215
16673
  var _body$paragraphs, _BLOCK_LAYOUT_OUTER_S;
16216
- const style = Tools.deepClone(paragraphStyle);
16217
16674
  const blockRanges = body === null || body === void 0 ? void 0 : body.blockRanges;
16218
- if (!(blockRanges === null || blockRanges === void 0 ? void 0 : blockRanges.length)) {
16219
- if (shouldApplyDocumentDefaults) _applyDefaultLayoutParagraphStyle(style, false);
16220
- return style;
16221
- }
16675
+ if (!(blockRanges === null || blockRanges === void 0 ? void 0 : blockRanges.length)) return resolveDocumentParagraphStyle(documentStyle, paragraphStyle, { useLegacyModernDefaults });
16222
16676
  const blockRange = blockRanges.find((range) => BLOCK_LAYOUT_OUTER_SPACING_MAP.has(range.blockType) && paragraph.startIndex > range.startIndex && paragraph.startIndex < range.endIndex);
16223
- if (!blockRange) {
16224
- if (shouldApplyDocumentDefaults) _applyDefaultLayoutParagraphStyle(style, false);
16225
- return style;
16226
- }
16227
- _applyDefaultLayoutParagraphStyle(style, true);
16677
+ if (!blockRange) return resolveDocumentParagraphStyle(documentStyle, paragraphStyle, { useLegacyModernDefaults });
16678
+ const style = resolveDocumentParagraphStyle(documentStyle, paragraphStyle, {
16679
+ excludeDocumentOuterSpacing: true,
16680
+ useLegacyModernDefaults
16681
+ });
16682
+ if (style.lineSpacing == null) style.lineSpacing = DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING;
16228
16683
  const blockParagraphs = ((_body$paragraphs = body === null || body === void 0 ? void 0 : body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).filter((item) => item.startIndex > blockRange.startIndex && item.startIndex < blockRange.endIndex).sort((left, right) => left.startIndex - right.startIndex);
16229
16684
  const firstParagraph = blockParagraphs[0];
16230
16685
  const lastParagraph = blockParagraphs[blockParagraphs.length - 1];
@@ -16273,7 +16728,7 @@ function _getNextPageNumber(lastPage) {
16273
16728
  return lastPage.pageNumber + 1;
16274
16729
  }
16275
16730
  function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, sectionBreakConfig, tableSkeleton) {
16276
- var _sectionBreakConfig$d, _viewModel$getSnapsho, _viewModel$getBody2, _viewModel$getBody3;
16731
+ var _viewModel$getSnapsho, _sectionBreakConfig$d, _viewModel$getBody2, _viewModel$getBody3;
16277
16732
  const { skeletonResourceReference } = ctx;
16278
16733
  const { lists, drawings = {}, localeService } = sectionBreakConfig;
16279
16734
  const { endIndex, blocks = [], children } = paragraphNode;
@@ -16283,7 +16738,8 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
16283
16738
  paragraphId: "para_render_fallback"
16284
16739
  };
16285
16740
  const { paragraphStyle = {}, bullet } = paragraph;
16286
- const documentCompatibilityPolicy = (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy((_viewModel$getSnapsho = viewModel.getSnapshot) === null || _viewModel$getSnapsho === void 0 || (_viewModel$getSnapsho = _viewModel$getSnapsho.call(viewModel)) === null || _viewModel$getSnapsho === void 0 ? void 0 : _viewModel$getSnapsho.documentStyle.documentFlavor);
16741
+ const documentStyle = (_viewModel$getSnapsho = viewModel.getSnapshot) === null || _viewModel$getSnapsho === void 0 || (_viewModel$getSnapsho = _viewModel$getSnapsho.call(viewModel)) === null || _viewModel$getSnapsho === void 0 ? void 0 : _viewModel$getSnapsho.documentStyle;
16742
+ const documentCompatibilityPolicy = (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy(documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor);
16287
16743
  const shouldApplyDocumentDefaults = documentCompatibilityPolicy.applyDocumentDefaultParagraphStyle;
16288
16744
  const useWordStyleLineHeight = documentCompatibilityPolicy.useWordStyleLineHeight;
16289
16745
  const { skeHeaders, skeFooters, skeListLevel, drawingAnchor } = skeletonResourceReference;
@@ -16299,7 +16755,7 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
16299
16755
  const paragraphConfig = {
16300
16756
  paragraphIndex: endIndex,
16301
16757
  documentCompatibilityPolicy,
16302
- paragraphStyle: _applyBlockRangeLayoutParagraphStyle((_viewModel$getBody2 = (_viewModel$getBody3 = viewModel.getBody) === null || _viewModel$getBody3 === void 0 ? void 0 : _viewModel$getBody3.call(viewModel)) !== null && _viewModel$getBody2 !== void 0 ? _viewModel$getBody2 : null, paragraph, paragraphStyle, shouldApplyDocumentDefaults),
16758
+ paragraphStyle: _applyBlockRangeLayoutParagraphStyle((_viewModel$getBody2 = (_viewModel$getBody3 = viewModel.getBody) === null || _viewModel$getBody3 === void 0 ? void 0 : _viewModel$getBody3.call(viewModel)) !== null && _viewModel$getBody2 !== void 0 ? _viewModel$getBody2 : null, paragraph, paragraphStyle, documentStyle, shouldApplyDocumentDefaults),
16303
16759
  docxFallbackAnchorLeft: _getFollowingIndentedParagraphAnchorLeft(viewModel, paragraph, paragraphNode, drawings, isTraditionalDocumentCompatibility(documentCompatibilityPolicy)),
16304
16760
  useWordStyleLineHeight,
16305
16761
  paragraphNonInlineSkeDrawings,
@@ -16342,7 +16798,7 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
16342
16798
  let allPages = [curPage];
16343
16799
  let isParagraphFirstShapedText = true;
16344
16800
  let shapedTextOffset = 0;
16345
- for (const [_index, { text, glyphs, breakPointType }] of _mergeAdjacentCustomBlockShapedTexts(shapedTextList).entries()) {
16801
+ for (const [_index, { text, glyphs, breakPointType }] of _mergeAdjacentCustomBlockShapedTexts(shapedTextList, paragraphNonInlineSkeDrawingsByBlockId).entries()) {
16346
16802
  const textStartIndex = paragraphNode.startIndex + shapedTextOffset;
16347
16803
  const textGlyphCount = _glyphCount(glyphs);
16348
16804
  const textEndIndex = textStartIndex + textGlyphCount;
@@ -16859,7 +17315,8 @@ function otherHandler(index, charArray, viewModel, paragraphNode, sectionBreakCo
16859
17315
  const char = (_src$match = src.match(/^[\s\S]/gu)) === null || _src$match === void 0 ? void 0 : _src$match[0];
16860
17316
  if (char == null) break;
16861
17317
  if (hasSpace(char) || startWithEmoji(charArray.substring(step))) break;
16862
- const glyph = createSkeletonLetterGlyph(char, getFontCreateConfig(index + step, viewModel, paragraphNode, sectionBreakConfig, paragraph));
17318
+ const config = getFontCreateConfig(index + step, viewModel, paragraphNode, sectionBreakConfig, paragraph);
17319
+ const glyph = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphWidth(index + step, viewModel, paragraphNode, config));
16863
17320
  glyphGroup.push(glyph);
16864
17321
  src = src.substring(char.length);
16865
17322
  step += char.length;
@@ -16935,7 +17392,7 @@ function punctuationSpaceAdjustment(shapedGlyphs) {
16935
17392
  const nextGlyph = shapedGlyphs[i + 1];
16936
17393
  const { width, content } = curGlyph;
16937
17394
  const delta = width / 2;
16938
- if (hasCJKPunctuation(content) && hasCJKPunctuation(nextGlyph.content) && curGlyph.adjustability.shrinkability[1] + nextGlyph.adjustability.shrinkability[0] >= delta) {
17395
+ if (cjk.hasCJKPunctuation(content) && cjk.hasCJKPunctuation(nextGlyph.content) && curGlyph.adjustability.shrinkability[1] + nextGlyph.adjustability.shrinkability[0] >= delta) {
16939
17396
  const leftDelta = Math.min(curGlyph.adjustability.shrinkability[1], delta);
16940
17397
  glyphShrinkRight(curGlyph, leftDelta);
16941
17398
  glyphShrinkLeft(nextGlyph, delta - leftDelta);
@@ -16951,11 +17408,11 @@ function addCJKLatinSpacing(shapedTextList) {
16951
17408
  const curGlyph = shapedGlyphs[i];
16952
17409
  const nextGlyph = i < len - 1 ? shapedGlyphs[i + 1] : null;
16953
17410
  const { width } = curGlyph;
16954
- if (hasCJKText(curGlyph.content) && nextGlyph && LATIN_REG.test(nextGlyph.content)) {
17411
+ if (cjk.hasCJKText(curGlyph.content) && nextGlyph && LATIN_REG.test(nextGlyph.content)) {
16955
17412
  curGlyph.width += width / 4;
16956
17413
  curGlyph.adjustability.shrinkability[1] += width / 8;
16957
17414
  }
16958
- if (hasCJKText(curGlyph.content) && prevGlyph && LATIN_REG.test(prevGlyph.content)) {
17415
+ if (cjk.hasCJKText(curGlyph.content) && prevGlyph && LATIN_REG.test(prevGlyph.content)) {
16959
17416
  curGlyph.width += width / 4;
16960
17417
  curGlyph.xOffset += width / 4;
16961
17418
  curGlyph.adjustability.shrinkability[0] += width / 8;
@@ -17017,7 +17474,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
17017
17474
  const newSpan = createSkeletonLetterGlyph(char, config);
17018
17475
  shapedGlyphs.push(newSpan);
17019
17476
  } else {
17020
- const newSpan = createSkeletonLetterGlyph(char, config, void 0, glyphInfo);
17477
+ const newSpan = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphWidth(start, viewModel, paragraphNode, config), glyphInfo);
17021
17478
  shapedGlyphs.push(newSpan);
17022
17479
  }
17023
17480
  }
@@ -17036,24 +17493,29 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
17036
17493
  const { blockId } = customBlock;
17037
17494
  const drawingOrigin = drawings[blockId];
17038
17495
  if ((drawingOrigin === null || drawingOrigin === void 0 ? void 0 : drawingOrigin.layoutType) === PositionedObjectLayoutType.INLINE) {
17496
+ var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3, _boundingBox$height, _boundingBox$width, _ref, _viewport$layoutWidth, _viewport$height;
17039
17497
  const { angle } = drawingOrigin.docTransform;
17040
17498
  const { width = 0, height = 0 } = drawingOrigin.docTransform.size;
17041
17499
  const boundingBox = getBoundingBox(angle, 0, width, 0, height);
17042
- newGlyph = createSkeletonCustomBlockGlyph(config, boundingBox.width, boundingBox.height, drawingOrigin.drawingId);
17500
+ const viewport = getDocsCustomBlockRenderViewport((_viewModel$getDataMod = (_viewModel$getDataMod2 = (_viewModel$getDataMod3 = viewModel.getDataModel()).getUnitId) === null || _viewModel$getDataMod2 === void 0 ? void 0 : _viewModel$getDataMod2.call(_viewModel$getDataMod3)) !== null && _viewModel$getDataMod !== void 0 ? _viewModel$getDataMod : "", drawingOrigin.drawingId, {
17501
+ fallbackHeight: (_boundingBox$height = boundingBox.height) !== null && _boundingBox$height !== void 0 ? _boundingBox$height : 0,
17502
+ fallbackWidth: (_boundingBox$width = boundingBox.width) !== null && _boundingBox$width !== void 0 ? _boundingBox$width : 0
17503
+ });
17504
+ newGlyph = createSkeletonCustomBlockGlyph(config, (_ref = (_viewport$layoutWidth = viewport === null || viewport === void 0 ? void 0 : viewport.layoutWidth) !== null && _viewport$layoutWidth !== void 0 ? _viewport$layoutWidth : viewport === null || viewport === void 0 ? void 0 : viewport.width) !== null && _ref !== void 0 ? _ref : boundingBox.width, (_viewport$height = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _viewport$height !== void 0 ? _viewport$height : boundingBox.height, drawingOrigin.drawingId);
17043
17505
  } else if (drawingOrigin != null) newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
17044
17506
  }
17045
17507
  if (newGlyph == null) newGlyph = createSkeletonLetterGlyph(char, config);
17046
17508
  shapedGlyphs.push(newGlyph);
17047
17509
  i += char.length;
17048
17510
  src = src.substring(char.length);
17049
- } else if (/\s/.test(char) || hasCJK(char)) {
17511
+ } else if (/\s/.test(char) || cjk.hasCJK(char)) {
17050
17512
  const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
17051
17513
  let newGlyph = null;
17052
17514
  if (char === DataStreamTreeTokenType.TAB) newGlyph = createSkeletonTabGlyph(config, getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid));
17053
17515
  else if (char === DataStreamTreeTokenType.PARAGRAPH) {
17054
17516
  var _sectionBreakConfig$r;
17055
17517
  if (((_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.zeroWidthParagraphBreak) === BooleanNumber.TRUE) newGlyph = createSkeletonLetterGlyph(char, config, 0);
17056
- else newGlyph = createSkeletonLetterGlyph(char, config);
17518
+ else newGlyph = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphWidth(i, viewModel, paragraphNode, config));
17057
17519
  } else newGlyph = createSkeletonLetterGlyph(char, config);
17058
17520
  shapedGlyphs.push(newGlyph);
17059
17521
  i += char.length;
@@ -17200,6 +17662,7 @@ function createColumnContentPage(ctx, viewModel, columnNode, sectionBreakConfig,
17200
17662
  const page = createSkeletonPage(ctx, columnSectionBreakConfig, ctx.skeletonResourceReference);
17201
17663
  page.type = 3;
17202
17664
  for (const paragraphNode of getColumnParagraphNodes(columnNode)) dealWidthParagraph(ctx, viewModel, paragraphNode, page, columnSectionBreakConfig);
17665
+ updateInlineDrawingCoordsAndBorder(ctx, [page]);
17203
17666
  updateBlockIndex([page], columnNode.startIndex, (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy());
17204
17667
  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);
17205
17668
  return page;
@@ -17846,6 +18309,26 @@ function resolveMostSpecificPageByCharIndex(page, charIndex) {
17846
18309
  }
17847
18310
  return page;
17848
18311
  }
18312
+ function getSegmentPageFromRelativePath(skeletonData, segmentPageIndex, path) {
18313
+ var _skeletonData$skeHead, _skeletonData$skeFoot;
18314
+ const rootPage = skeletonData.pages[segmentPageIndex];
18315
+ if (rootPage == null) return null;
18316
+ const { headerId, footerId, pageWidth } = rootPage;
18317
+ 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)];
18318
+ for (const segmentPage of segmentPages) {
18319
+ if (segmentPage == null) continue;
18320
+ const page = getPageFromPath({
18321
+ ...skeletonData,
18322
+ pages: [segmentPage]
18323
+ }, [
18324
+ "pages",
18325
+ 0,
18326
+ ...path
18327
+ ]);
18328
+ if (page != null) return page;
18329
+ }
18330
+ return null;
18331
+ }
17849
18332
  var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17850
18333
  constructor(_docViewModel, localeService) {
17851
18334
  super(localeService);
@@ -17940,7 +18423,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17940
18423
  pageIndex = skeletonData.pages.indexOf(page);
17941
18424
  break;
17942
18425
  case 3:
17943
- pageIndex = path[1];
18426
+ pageIndex = typeof path[1] === "number" ? path[1] : segmentPage;
17944
18427
  break;
17945
18428
  default: throw new Error("Invalid page type");
17946
18429
  }
@@ -17986,7 +18469,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17986
18469
  pageIndex = pages.indexOf(page);
17987
18470
  break;
17988
18471
  case 3:
17989
- pageIndex = path[1];
18472
+ pageIndex = typeof path[1] === "number" ? path[1] : segmentPageIndex;
17990
18473
  break;
17991
18474
  default: throw new Error("Invalid page type");
17992
18475
  }
@@ -18029,7 +18512,8 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
18029
18512
  if (skeFooter == null) return;
18030
18513
  else skePage = skeFooter;
18031
18514
  }
18032
- } else skePage = getPageFromPath(skeletonData, path);
18515
+ } else if (pageType === 3 && path[0] !== "pages") skePage = getSegmentPageFromRelativePath(skeletonData, segmentPage, path);
18516
+ else skePage = getPageFromPath(skeletonData, path);
18033
18517
  if (skePage == null) return;
18034
18518
  const glyphGroup = skePage.sections[section].columns[column].lines[line].divides[divide].glyphGroup;
18035
18519
  glyph = Math.min(glyph, glyphGroup.length - 1);
@@ -18537,8 +19021,8 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
18537
19021
  if (maybeHeaderSke) segmentPage = maybeHeaderSke;
18538
19022
  else if (maybeFooterSke) segmentPage = maybeFooterSke;
18539
19023
  else continue;
18540
- }
18541
- if (segmentId === "") segmentPage = resolveMostSpecificPageByCharIndex(page, charIndex);
19024
+ segmentPage = resolveMostSpecificPageByCharIndex(segmentPage, charIndex);
19025
+ } else segmentPage = resolveMostSpecificPageByCharIndex(page, charIndex);
18542
19026
  const { sections, st, ed } = segmentPage;
18543
19027
  const segmentPageParent = segmentPage.parent;
18544
19028
  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);
@@ -18620,7 +19104,10 @@ function createDocumentModelWithStyle(content, textStyle, config = {}) {
18620
19104
  paragraphId: createParagraphId(/* @__PURE__ */ new Set()),
18621
19105
  paragraphStyle: { horizontalAlign }
18622
19106
  }],
18623
- sectionBreaks: [{ startIndex: contentLength + 1 }]
19107
+ sectionBreaks: [{
19108
+ sectionId: createSectionId(/* @__PURE__ */ new Set()),
19109
+ startIndex: contentLength + 1
19110
+ }]
18624
19111
  },
18625
19112
  documentStyle: {
18626
19113
  pageSize: {
@@ -18704,6 +19191,36 @@ const DEFAULT_PADDING_DATA = {
18704
19191
  r: 2
18705
19192
  };
18706
19193
  const RENDER_RAW_FORMULA_KEY = "RENDER_RAW_FORMULA";
19194
+ function getResolvedRenderHorizontalAlign$1(horizontalAlign, cellData) {
19195
+ if (horizontalAlign !== HorizontalAlign.UNSPECIFIED) return horizontalAlign;
19196
+ if ((cellData === null || cellData === void 0 ? void 0 : cellData.t) === CellValueType.NUMBER || !Tools.isDefine(cellData === null || cellData === void 0 ? void 0 : cellData.t) && typeof (cellData === null || cellData === void 0 ? void 0 : cellData.v) === "number") return HorizontalAlign.RIGHT;
19197
+ if ((cellData === null || cellData === void 0 ? void 0 : cellData.t) === CellValueType.BOOLEAN) return HorizontalAlign.CENTER;
19198
+ return horizontalAlign;
19199
+ }
19200
+ function setRenderTextCache(cacheItem, cellData) {
19201
+ var _cacheItem$horizontal;
19202
+ if (cacheItem.documentSkeleton) {
19203
+ cacheItem.displayText = void 0;
19204
+ cacheItem.resolvedHorizontalAlign = void 0;
19205
+ return;
19206
+ }
19207
+ cacheItem.displayText = getDisplayValueFromCell(cellData);
19208
+ cacheItem.resolvedHorizontalAlign = getResolvedRenderHorizontalAlign$1((_cacheItem$horizontal = cacheItem.horizontalAlign) !== null && _cacheItem$horizontal !== void 0 ? _cacheItem$horizontal : HorizontalAlign.UNSPECIFIED, cellData);
19209
+ }
19210
+ function pushRowRange(ranges, row, startColumn, endColumn) {
19211
+ if (endColumn < startColumn) return;
19212
+ const last = ranges[ranges.length - 1];
19213
+ if (last && last.startRow === row && last.endRow === row && last.endColumn + 1 === startColumn) {
19214
+ last.endColumn = endColumn;
19215
+ return;
19216
+ }
19217
+ ranges.push({
19218
+ startRow: row,
19219
+ endRow: row,
19220
+ startColumn,
19221
+ endColumn
19222
+ });
19223
+ }
18707
19224
  const CACHE_COUNT = 100;
18708
19225
  let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18709
19226
  constructor(worksheet, _styles, _localeService, _contextService, _configService, _injector) {
@@ -18717,6 +19234,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18717
19234
  _defineProperty(this, "_cacheRangeMap", /* @__PURE__ */ new Map());
18718
19235
  _defineProperty(this, "_visibleRangeMap", /* @__PURE__ */ new Map());
18719
19236
  _defineProperty(this, "_overflowCache", new ObjectMatrix());
19237
+ _defineProperty(this, "_incrementalFontRenderRanges", []);
18720
19238
  _defineProperty(this, "_stylesCache", {
18721
19239
  background: {},
18722
19240
  backgroundPositions: new ObjectMatrix(),
@@ -18774,6 +19292,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18774
19292
  get overflowCache() {
18775
19293
  return this._overflowCache;
18776
19294
  }
19295
+ get incrementalFontRenderRanges() {
19296
+ return this._incrementalFontRenderRanges;
19297
+ }
18777
19298
  get showGridlines() {
18778
19299
  return this._showGridlines;
18779
19300
  }
@@ -18859,7 +19380,31 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18859
19380
  this.updateVisibleRange(vpInfo);
18860
19381
  const rowColumnSegment = this._drawingRange;
18861
19382
  const columnWidthAccumulation = this.columnWidthAccumulation;
18862
- const styleRanges = !!vpInfo && !vpInfo.isDirty && !vpInfo.isForceDirty && (!!((_vpInfo$diffBounds = vpInfo.diffBounds) === null || _vpInfo$diffBounds === void 0 ? void 0 : _vpInfo$diffBounds.length) || !!((_vpInfo$diffCacheBoun = vpInfo.diffCacheBounds) === null || _vpInfo$diffCacheBoun === void 0 ? void 0 : _vpInfo$diffCacheBoun.length) || !!vpInfo.diffX || !!vpInfo.diffY) ? vpInfo.shouldCacheUpdate ? (_vpInfo$diffCacheBoun2 = (_vpInfo$diffCacheBoun3 = vpInfo.diffCacheBounds) === null || _vpInfo$diffCacheBoun3 === void 0 ? void 0 : _vpInfo$diffCacheBoun3.map((bound) => this.getRangeByViewBound(bound))) !== null && _vpInfo$diffCacheBoun2 !== void 0 ? _vpInfo$diffCacheBoun2 : [] : [] : [rowColumnSegment];
19383
+ const isIncrementalScroll = !!vpInfo && !vpInfo.isDirty && !vpInfo.isForceDirty && (!!((_vpInfo$diffBounds = vpInfo.diffBounds) === null || _vpInfo$diffBounds === void 0 ? void 0 : _vpInfo$diffBounds.length) || !!((_vpInfo$diffCacheBoun = vpInfo.diffCacheBounds) === null || _vpInfo$diffCacheBoun === void 0 ? void 0 : _vpInfo$diffCacheBoun.length) || !!vpInfo.diffX || !!vpInfo.diffY);
19384
+ const hasMergeData = this.worksheet.getMergeData().length > 0;
19385
+ const isScrolling = !!vpInfo && (!!vpInfo.diffX || !!vpInfo.diffY);
19386
+ const shouldRefreshCacheForScroll = isIncrementalScroll && (hasMergeData && isScrolling || !!vpInfo.shouldCacheUpdate && !!vpInfo.diffX);
19387
+ const shouldUseIncrementalStyleRange = isIncrementalScroll && !shouldRefreshCacheForScroll;
19388
+ const styleRanges = shouldUseIncrementalStyleRange ? vpInfo.shouldCacheUpdate ? (_vpInfo$diffCacheBoun2 = (_vpInfo$diffCacheBoun3 = vpInfo.diffCacheBounds) === null || _vpInfo$diffCacheBoun3 === void 0 ? void 0 : _vpInfo$diffCacheBoun3.map((bound) => this.getRangeByViewBound(bound))) !== null && _vpInfo$diffCacheBoun2 !== void 0 ? _vpInfo$diffCacheBoun2 : [] : [] : [rowColumnSegment];
19389
+ const visibleCellOptions = hasMergeData ? null : {
19390
+ cacheItem: {
19391
+ bg: true,
19392
+ border: true
19393
+ },
19394
+ reuseExisting: shouldUseIncrementalStyleRange,
19395
+ hasMergeData,
19396
+ rowVisible: true
19397
+ };
19398
+ const overflowCellOptions = hasMergeData ? null : {
19399
+ cacheItem: {
19400
+ bg: false,
19401
+ border: false
19402
+ },
19403
+ reuseExisting: shouldUseIncrementalStyleRange,
19404
+ hasMergeData,
19405
+ rowVisible: true
19406
+ };
19407
+ this._incrementalFontRenderRanges = [];
18863
19408
  for (const styleRange of styleRanges) {
18864
19409
  const { startRow: visibleStartRow, endRow: visibleEndRow, startColumn: visibleStartColumn, endColumn: visibleEndColumn } = styleRange;
18865
19410
  if (visibleEndColumn === -1 || visibleEndRow === -1) continue;
@@ -18884,26 +19429,57 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18884
19429
  startColumn: visibleStartColumn,
18885
19430
  endColumn: visibleEndColumn
18886
19431
  });
18887
- for (let c = visibleStartColumn; c <= visibleEndColumn; c++) this._setStylesCacheForOneCell(r, c, { cacheItem: {
18888
- bg: true,
18889
- border: true
18890
- } });
18891
- for (let c = expandStartCol; c < visibleEndColumn; c++) this._setStylesCacheForOneCell(r, c, { cacheItem: {
18892
- bg: false,
18893
- border: false
18894
- } });
19432
+ for (let c = visibleStartColumn; c <= visibleEndColumn; c++) this._setStylesCacheForOneCell(r, c, visibleCellOptions !== null && visibleCellOptions !== void 0 ? visibleCellOptions : {
19433
+ cacheItem: {
19434
+ bg: true,
19435
+ border: true
19436
+ },
19437
+ reuseExisting: shouldUseIncrementalStyleRange,
19438
+ hasMergeData,
19439
+ rowVisible: true
19440
+ });
19441
+ if (shouldUseIncrementalStyleRange) pushRowRange(this._incrementalFontRenderRanges, r, visibleStartColumn, visibleEndColumn);
19442
+ for (let c = visibleStartColumn - 1; c >= expandStartCol; c--) {
19443
+ this._setStylesCacheForOneCell(r, c, overflowCellOptions !== null && overflowCellOptions !== void 0 ? overflowCellOptions : {
19444
+ cacheItem: {
19445
+ bg: false,
19446
+ border: false
19447
+ },
19448
+ reuseExisting: shouldUseIncrementalStyleRange,
19449
+ hasMergeData,
19450
+ rowVisible: true
19451
+ });
19452
+ if (shouldUseIncrementalStyleRange) pushRowRange(this._incrementalFontRenderRanges, r, c, c);
19453
+ if (!isCellCoverable(this.worksheet.getCell(r, c)) || hasMergeData && this.intersectMergeRange(r, c)) break;
19454
+ }
18895
19455
  if (visibleEndColumn === 0) continue;
18896
- for (let c = visibleEndColumn + 1; c < expandEndCol; c++) this._setStylesCacheForOneCell(r, c, { cacheItem: {
18897
- bg: false,
18898
- border: false
18899
- } });
19456
+ for (let c = visibleEndColumn + 1; c <= expandEndCol; c++) {
19457
+ this._setStylesCacheForOneCell(r, c, overflowCellOptions !== null && overflowCellOptions !== void 0 ? overflowCellOptions : {
19458
+ cacheItem: {
19459
+ bg: false,
19460
+ border: false
19461
+ },
19462
+ reuseExisting: shouldUseIncrementalStyleRange,
19463
+ hasMergeData,
19464
+ rowVisible: true
19465
+ });
19466
+ if (shouldUseIncrementalStyleRange) pushRowRange(this._incrementalFontRenderRanges, r, c, c);
19467
+ if (!isCellCoverable(this.worksheet.getCell(r, c)) || hasMergeData && this.intersectMergeRange(r, c)) break;
19468
+ }
18900
19469
  }
18901
19470
  const mergeRanges = [];
18902
19471
  for (const mergeVisibleRange of mergeVisibleRanges) {
18903
19472
  const mergeRangeInVisible = this.getCurrentRowColumnSegmentMergeData(mergeVisibleRange);
18904
19473
  mergeRanges.push(...mergeRangeInVisible);
18905
19474
  }
18906
- for (const mergeRange of mergeRanges) this._setStylesCacheForOneCell(mergeRange.startRow, mergeRange.startColumn, { mergeRange });
19475
+ for (const mergeRange of mergeRanges) {
19476
+ this._setStylesCacheForOneCell(mergeRange.startRow, mergeRange.startColumn, {
19477
+ mergeRange,
19478
+ reuseExisting: shouldUseIncrementalStyleRange,
19479
+ hasMergeData
19480
+ });
19481
+ if (shouldUseIncrementalStyleRange) pushRowRange(this._incrementalFontRenderRanges, mergeRange.startRow, mergeRange.startColumn, mergeRange.startColumn);
19482
+ }
18907
19483
  }
18908
19484
  return this;
18909
19485
  }
@@ -19188,6 +19764,22 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19188
19764
  endColumn
19189
19765
  };
19190
19766
  }
19767
+ _isOverflowBlockedByAdjacentCell(row, column, horizontalAlign, hasMergeData = true) {
19768
+ const leftBlocked = () => this._isOverflowSideBlocked(row, column, -1, hasMergeData);
19769
+ const rightBlocked = () => this._isOverflowSideBlocked(row, column, 1, hasMergeData);
19770
+ if (horizontalAlign === HorizontalAlign.CENTER) return leftBlocked() && rightBlocked();
19771
+ if (horizontalAlign === HorizontalAlign.RIGHT) return leftBlocked();
19772
+ return rightBlocked();
19773
+ }
19774
+ _isOverflowSideBlocked(row, column, direction, hasMergeData = true) {
19775
+ var _this$_stylesCache$fo;
19776
+ const adjacentColumn = column + direction;
19777
+ if (adjacentColumn < 0 || adjacentColumn >= this.getColumnCount()) return true;
19778
+ const rawAdjacentCell = this._cellData.getValue(row, adjacentColumn);
19779
+ if (rawAdjacentCell && !isCellCoverable(rawAdjacentCell)) return true;
19780
+ const cachedAdjacentCell = (_this$_stylesCache$fo = this._stylesCache.fontMatrix.getValue(row, adjacentColumn)) === null || _this$_stylesCache$fo === void 0 ? void 0 : _this$_stylesCache$fo.cellData;
19781
+ return !isCellCoverable(cachedAdjacentCell !== null && cachedAdjacentCell !== void 0 ? cachedAdjacentCell : this.worksheet.getCell(row, adjacentColumn)) || hasMergeData && this.intersectMergeRange(row, adjacentColumn);
19782
+ }
19191
19783
  /**
19192
19784
  * Get cell by pos(offsetX, offsetY).
19193
19785
  * @deprecated Please use `getCellWithCoordByOffset` instead.
@@ -19357,7 +19949,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19357
19949
  * the text content of this cell can be drawn to both sides, not limited by the cell's width.
19358
19950
  * Overflow on the left or right is aligned according to the text's horizontal alignment.
19359
19951
  */
19360
- _calculateOverflowCell(row, column, docsConfig) {
19952
+ _calculateOverflowCell(row, column, docsConfig, hasMergeData = true) {
19361
19953
  const { documentSkeleton, vertexAngle = 0, centerAngle = 0, horizontalAlign, wrapStrategy } = docsConfig;
19362
19954
  const { t: cellValueType = CellValueType.STRING } = this._cellData.getValue(row, column) || {};
19363
19955
  let horizontalAlignPos = horizontalAlign;
@@ -19373,7 +19965,13 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19373
19965
  * Numerical and Boolean values are not displayed with overflow.
19374
19966
  */
19375
19967
  if ((wrapStrategy === WrapStrategy.OVERFLOW || wrapStrategy === WrapStrategy.UNSPECIFIED) && cellValueType !== CellValueType.NUMBER && cellValueType !== CellValueType.BOOLEAN && horizontalAlign !== HorizontalAlign.JUSTIFIED) {
19376
- if (this.intersectMergeRange(row, column)) return true;
19968
+ var _docsConfig$cellData$, _docsConfig$cellData, _docsConfig$cellData2;
19969
+ docsConfig.textFitsCurrentCell = false;
19970
+ if (hasMergeData && this.intersectMergeRange(row, column)) return true;
19971
+ const columnStart = this.columnWidthAccumulation[column - 1] || 0;
19972
+ const currentColumnWidth = (this.columnWidthAccumulation[column] || columnStart) - columnStart;
19973
+ const rawText = (_docsConfig$cellData$ = (_docsConfig$cellData = docsConfig.cellData) === null || _docsConfig$cellData === void 0 || (_docsConfig$cellData = _docsConfig$cellData.p) === null || _docsConfig$cellData === void 0 || (_docsConfig$cellData = _docsConfig$cellData.body) === null || _docsConfig$cellData === void 0 ? void 0 : _docsConfig$cellData.dataStream) !== null && _docsConfig$cellData$ !== void 0 ? _docsConfig$cellData$ : (_docsConfig$cellData2 = docsConfig.cellData) === null || _docsConfig$cellData2 === void 0 ? void 0 : _docsConfig$cellData2.v;
19974
+ if ((Boolean(documentSkeleton) || `${rawText !== null && rawText !== void 0 ? rawText : ""}`.length * 4 > currentColumnWidth) && this._isOverflowBlockedByAdjacentCell(row, column, horizontalAlignPos, hasMergeData)) return true;
19377
19975
  let contentSize;
19378
19976
  if (documentSkeleton) contentSize = getDocsSkeletonPageSize(documentSkeleton, vertexAngle);
19379
19977
  else {
@@ -19393,11 +19991,15 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19393
19991
  height: cellHeight
19394
19992
  };
19395
19993
  }
19994
+ if (contentSize.width < currentColumnWidth) {
19995
+ docsConfig.textFitsCurrentCell = true;
19996
+ return true;
19997
+ }
19396
19998
  const { startColumn, endColumn } = this.getOverflowPosition(contentSize, horizontalAlignPos, row, column, this.getColumnCount());
19397
19999
  if (startColumn === endColumn) return true;
19398
20000
  this.appendToOverflowCache(row, column, startColumn, endColumn);
19399
20001
  } else if (wrapStrategy === WrapStrategy.WRAP && vertexAngle !== 0) {
19400
- if (this.intersectMergeRange(row, column)) return true;
20002
+ if (hasMergeData && this.intersectMergeRange(row, column)) return true;
19401
20003
  const { startY, endY } = this.getCellWithCoordByIndex(row, column);
19402
20004
  const cellHeight = endY - startY;
19403
20005
  documentSkeleton.getViewModel().getDataModel().updateDocumentDataPageSize(cellHeight);
@@ -19429,16 +20031,18 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19429
20031
  const startRow = searchArray(rowHeightAccumulation, Math.round(viewBound.top) - this.columnHeaderHeightAndMarginTop);
19430
20032
  const endY = Math.round(viewBound.bottom) - this.columnHeaderHeightAndMarginTop;
19431
20033
  let endRow = searchArray(rowHeightAccumulation, endY);
19432
- if (endRow < lenOfRowData && rowHeightAccumulation[endRow - 1] === endY) endRow -= 1;
20034
+ const isEndYOnBoundary = endRow < lenOfRowData && rowHeightAccumulation[endRow - 1] === endY;
20035
+ if (isEndYOnBoundary) endRow -= 1;
19433
20036
  const startColumn = searchArray(columnWidthAccumulation, Math.round(viewBound.left) - this.rowHeaderWidthAndMarginLeft);
19434
20037
  const endX = Math.round(viewBound.right) - this.rowHeaderWidthAndMarginLeft;
19435
20038
  let endColumn = searchArray(columnWidthAccumulation, endX);
19436
- if (endColumn < lenOfColData && columnWidthAccumulation[endColumn - 1] === endX) endColumn -= 1;
20039
+ const isEndXOnBoundary = endColumn < lenOfColData && columnWidthAccumulation[endColumn - 1] === endX;
20040
+ if (isEndXOnBoundary) endColumn -= 1;
19437
20041
  if (isPrinting) return {
19438
20042
  startRow,
19439
- endRow: endRow === lenOfRowData - 1 ? endRow : endRow - 1,
20043
+ endRow: endRow === lenOfRowData - 1 || isEndYOnBoundary ? endRow : endRow - 1,
19440
20044
  startColumn,
19441
- endColumn: endColumn === lenOfColData - 1 ? endColumn : endColumn - 1
20045
+ endColumn: endColumn === lenOfColData - 1 || isEndXOnBoundary ? endColumn : endColumn - 1
19442
20046
  };
19443
20047
  return {
19444
20048
  startRow,
@@ -19489,7 +20093,15 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19489
20093
  for (let i = 0; i < ranges.length; i++) {
19490
20094
  const range = ranges[i];
19491
20095
  Range.foreach(range, (row, col) => {
20096
+ var _this$_stylesCache$bo, _this$_stylesCache$ba, _this$_stylesCache$ba2;
19492
20097
  this._stylesCache.fontMatrix.realDeleteValue(row, col);
20098
+ (_this$_stylesCache$bo = this._stylesCache.border) === null || _this$_stylesCache$bo === void 0 || _this$_stylesCache$bo.realDeleteValue(row, col);
20099
+ (_this$_stylesCache$ba = this._stylesCache.backgroundPositions) === null || _this$_stylesCache$ba === void 0 || _this$_stylesCache$ba.realDeleteValue(row, col);
20100
+ this._handleBgMatrix.realDeleteValue(row, col);
20101
+ this._handleBorderMatrix.realDeleteValue(row, col);
20102
+ Object.values((_this$_stylesCache$ba2 = this._stylesCache.background) !== null && _this$_stylesCache$ba2 !== void 0 ? _this$_stylesCache$ba2 : {}).forEach((backgroundMatrix) => {
20103
+ backgroundMatrix.realDeleteValue(row, col);
20104
+ });
19493
20105
  });
19494
20106
  }
19495
20107
  this.makeDirty(true);
@@ -19530,15 +20142,15 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19530
20142
  }).bg) return;
19531
20143
  this._handleBgMatrix.setValue(row, col, true);
19532
20144
  if (style && style.bg && style.bg.rgb) {
19533
- var _this$_stylesCache$ba;
20145
+ var _this$_stylesCache$ba3;
19534
20146
  const rgb = style.bg.rgb;
19535
20147
  if (!this._stylesCache.background[rgb]) this._stylesCache.background[rgb] = new ObjectMatrix();
19536
20148
  this._stylesCache.background[rgb].setValue(row, col, rgb);
19537
20149
  const cellInfo = this.getCellWithCoordByIndex(row, col, false);
19538
- (_this$_stylesCache$ba = this._stylesCache.backgroundPositions) === null || _this$_stylesCache$ba === void 0 || _this$_stylesCache$ba.setValue(row, col, cellInfo);
20150
+ (_this$_stylesCache$ba3 = this._stylesCache.backgroundPositions) === null || _this$_stylesCache$ba3 === void 0 || _this$_stylesCache$ba3.setValue(row, col, cellInfo);
19539
20151
  }
19540
20152
  }
19541
- _setFontStylesCache(row, col, cellData, style) {
20153
+ _setFontStylesCache(row, col, cellData, style, hasMergeData = true) {
19542
20154
  var _style$tr2;
19543
20155
  if (isNullCell(cellData)) return;
19544
20156
  let config = {
@@ -19550,6 +20162,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19550
20162
  else {
19551
20163
  const cacheItem = cacheValue;
19552
20164
  cacheItem.cellData = cellData;
20165
+ setRenderTextCache(cacheItem, cellData);
19553
20166
  this._stylesCache.fontMatrix.setValue(row, col, cacheValue);
19554
20167
  return;
19555
20168
  }
@@ -19593,8 +20206,10 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19593
20206
  style
19594
20207
  };
19595
20208
  }
19596
- this._calculateOverflowCell(row, col, config);
19597
- this._stylesCache.fontMatrix.setValue(row, col, config);
20209
+ const fontCacheItem = config;
20210
+ setRenderTextCache(fontCacheItem, cellData);
20211
+ this._calculateOverflowCell(row, col, fontCacheItem, hasMergeData);
20212
+ this._stylesCache.fontMatrix.setValue(row, col, fontCacheItem);
19598
20213
  }
19599
20214
  /**
19600
20215
  * Set border background and font to this._stylesCache cell by cell.
@@ -19603,19 +20218,37 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19603
20218
  * @param options {{ mergeRange: IRange; cacheItem: ICacheItem } | undefined}
19604
20219
  */
19605
20220
  _setStylesCacheForOneCell(row, col, options) {
20221
+ var _options$hasMergeData, _options$rowVisible, _options$hasMergeData2;
19606
20222
  if (row === -1 || col === -1) return;
19607
20223
  if (!options) options = { cacheItem: {
19608
20224
  bg: true,
19609
20225
  border: true
19610
20226
  } };
19611
- const { isMerged, isMergedMainCell, startRow, startColumn, endRow, endColumn } = this.worksheet.getCellInfoInMergeData(row, col);
19612
- if (isMerged) options.mergeRange = {
19613
- startRow,
19614
- startColumn,
19615
- endRow,
19616
- endColumn
19617
- };
19618
- if (this.worksheet.getColVisible(col) === false || this.worksheet.getRowVisible(row) === false) {
20227
+ const cacheItem = options.cacheItem;
20228
+ if (options.reuseExisting && cacheItem && !options.mergeRange) {
20229
+ const bgHandled = !cacheItem.bg || Tools.isDefine(this._handleBgMatrix.getValue(row, col));
20230
+ const borderHandled = !cacheItem.border || Tools.isDefine(this._handleBorderMatrix.getValue(row, col));
20231
+ if (bgHandled && borderHandled && this._stylesCache.fontMatrix.getValue(row, col)) return;
20232
+ }
20233
+ const hasMergeData = (_options$hasMergeData = options.hasMergeData) !== null && _options$hasMergeData !== void 0 ? _options$hasMergeData : true;
20234
+ let isMerged = false;
20235
+ let isMergedMainCell = false;
20236
+ if (hasMergeData) {
20237
+ const mergeInfo = this.worksheet.getCellInfoInMergeData(row, col);
20238
+ isMerged = mergeInfo.isMerged;
20239
+ isMergedMainCell = mergeInfo.isMergedMainCell;
20240
+ if (isMerged) {
20241
+ const { startRow, startColumn, endRow, endColumn } = mergeInfo;
20242
+ options.mergeRange = {
20243
+ startRow,
20244
+ startColumn,
20245
+ endRow,
20246
+ endColumn
20247
+ };
20248
+ }
20249
+ }
20250
+ const rowVisible = (_options$rowVisible = options.rowVisible) !== null && _options$rowVisible !== void 0 ? _options$rowVisible : this.worksheet.getRowVisible(row);
20251
+ if (this.worksheet.getColVisible(col) === false || rowVisible === false) {
19619
20252
  if (isMerged && !isMergedMainCell) return;
19620
20253
  else if (!isMergedMainCell) return;
19621
20254
  }
@@ -19627,7 +20260,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19627
20260
  this._setFontStylesCache(row, col, {
19628
20261
  ...cell,
19629
20262
  s: style
19630
- }, style);
20263
+ }, style, (_options$hasMergeData2 = options.hasMergeData) !== null && _options$hasMergeData2 !== void 0 ? _options$hasMergeData2 : true);
19631
20264
  }
19632
20265
  /**
19633
20266
  * pro/issues/344
@@ -19840,6 +20473,19 @@ function rotatedBoundingBox(width, height, angleDegrees) {
19840
20473
  rotatedHeight: Math.abs(width * Math.sin(angle)) + Math.abs(height * Math.cos(angle))
19841
20474
  };
19842
20475
  }
20476
+ function getResolvedRenderHorizontalAlign(fontCache, cellData) {
20477
+ if (fontCache.resolvedHorizontalAlign !== void 0) return fontCache.resolvedHorizontalAlign;
20478
+ const { horizontalAlign } = fontCache;
20479
+ if (horizontalAlign !== HorizontalAlign.UNSPECIFIED) return horizontalAlign;
20480
+ if (cellData.t === CellValueType.NUMBER || !Tools.isDefine(cellData.t) && typeof cellData.v === "number") return HorizontalAlign.RIGHT;
20481
+ if (cellData.t === CellValueType.BOOLEAN) return HorizontalAlign.CENTER;
20482
+ return horizontalAlign;
20483
+ }
20484
+ function needsFontRenderExtensionBounds(fontCache) {
20485
+ var _fontCache$cellData;
20486
+ const extension = (_fontCache$cellData = fontCache.cellData) === null || _fontCache$cellData === void 0 ? void 0 : _fontCache$cellData.fontRenderExtension;
20487
+ return Boolean((extension === null || extension === void 0 ? void 0 : extension.isSkip) || (extension === null || extension === void 0 ? void 0 : extension.leftOffset) || (extension === null || extension === void 0 ? void 0 : extension.rightOffset));
20488
+ }
19843
20489
  var Font = class extends SheetExtension {
19844
20490
  constructor() {
19845
20491
  super();
@@ -19870,7 +20516,7 @@ var Font = class extends SheetExtension {
19870
20516
  const { rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;
19871
20517
  if (!rowHeightAccumulation || !columnWidthAccumulation || columnTotalWidth === void 0 || rowTotalHeight === void 0 || !worksheet) return;
19872
20518
  const scale = this._getScale(parentScale);
19873
- const { viewRanges = [], checkOutOfViewBound } = moreBoundsInfo;
20519
+ const { fontRenderRanges, viewRanges = [], checkOutOfViewBound } = moreBoundsInfo;
19874
20520
  const lastRowIndex = spreadsheetSkeleton.getRowCount() - 1;
19875
20521
  const lastColIndex = spreadsheetSkeleton.getColumnCount() - 1;
19876
20522
  const expandedViewRanges = viewRanges.map((range) => clampRange({
@@ -19878,43 +20524,51 @@ var Font = class extends SheetExtension {
19878
20524
  startColumn: range.startColumn - 20,
19879
20525
  endColumn: range.endColumn + 20
19880
20526
  }, lastRowIndex, lastColIndex));
20527
+ const rangesToScan = (fontRenderRanges === null || fontRenderRanges === void 0 ? void 0 : fontRenderRanges.length) ? fontRenderRanges : expandedViewRanges;
19881
20528
  const renderFontContext = {
19882
20529
  ctx,
19883
20530
  scale,
19884
20531
  columnTotalWidth,
19885
20532
  rowTotalHeight,
19886
- viewRanges: expandedViewRanges,
20533
+ viewRanges: (fontRenderRanges === null || fontRenderRanges === void 0 ? void 0 : fontRenderRanges.length) ? viewRanges : expandedViewRanges,
19887
20534
  checkOutOfViewBound: checkOutOfViewBound || true,
19888
20535
  diffRanges,
19889
20536
  spreadsheetSkeleton
19890
20537
  };
19891
20538
  ctx.save();
20539
+ const hasMerge = spreadsheetSkeleton.worksheet.getMergeData().length > 0;
19892
20540
  const uniqueMergeRanges = [];
19893
- const mergeRangeIDSet = /* @__PURE__ */ new Set();
19894
- expandedViewRanges.forEach((range) => {
19895
- spreadsheetSkeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn).forEach((mergeRange) => {
19896
- const mergeRangeIndex = spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(mergeRange.startRow, mergeRange.startColumn);
20541
+ const mergeRangeIDSet = hasMerge ? /* @__PURE__ */ new Set() : null;
20542
+ const spanModel = hasMerge ? spreadsheetSkeleton.worksheet.getSpanModel() : null;
20543
+ rangesToScan.forEach((range) => {
20544
+ if (hasMerge && spanModel && mergeRangeIDSet) spreadsheetSkeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn).forEach((mergeRange) => {
20545
+ const mergeRangeIndex = spanModel.getMergeDataIndex(mergeRange.startRow, mergeRange.startColumn);
19897
20546
  if (!mergeRangeIDSet.has(mergeRangeIndex)) {
19898
20547
  mergeRangeIDSet.add(mergeRangeIndex);
19899
20548
  uniqueMergeRanges.push(mergeRange);
19900
20549
  }
19901
20550
  });
19902
- Range.foreach(range, (row, col) => {
19903
- if (spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(row, col) !== -1) return;
20551
+ const { startRow, endRow, startColumn, endColumn } = range;
20552
+ for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
20553
+ const fontCache = fontMatrix.getValue(row, col);
20554
+ if (!fontCache) continue;
20555
+ if (spanModel && spanModel.getMergeDataIndex(row, col) !== -1) continue;
19904
20556
  const cellInfo = spreadsheetSkeleton.getCellWithCoordByIndex(row, col, false);
19905
- if (!cellInfo) return;
20557
+ if (!cellInfo) continue;
19906
20558
  renderFontContext.cellInfo = cellInfo;
19907
- this._renderFontEachCell(renderFontContext, row, col, fontMatrix);
19908
- });
20559
+ this._renderFontEachCell(renderFontContext, row, col, fontMatrix, fontCache);
20560
+ }
19909
20561
  });
19910
20562
  uniqueMergeRanges.forEach((range) => {
20563
+ const fontCache = fontMatrix.getValue(range.startRow, range.startColumn);
20564
+ if (!fontCache) return;
19911
20565
  renderFontContext.cellInfo = spreadsheetSkeleton.getCellWithCoordByIndex(range.startRow, range.startColumn, false);
19912
- this._renderFontEachCell(renderFontContext, range.startRow, range.startColumn, fontMatrix);
20566
+ this._renderFontEachCell(renderFontContext, range.startRow, range.startColumn, fontMatrix, fontCache);
19913
20567
  });
19914
20568
  ctx.restore();
19915
20569
  }
19916
- _renderFontEachCell(renderFontCtx, row, col, fontMatrix) {
19917
- var _cellData$fontRenderE;
20570
+ _renderFontEachCell(renderFontCtx, row, col, fontMatrix, cacheValue) {
20571
+ var _fontCache$cellData2;
19918
20572
  const { ctx, viewRanges, diffRanges, spreadsheetSkeleton, cellInfo } = renderFontCtx;
19919
20573
  const { startY, endY, startX, endX } = cellInfo;
19920
20574
  const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
@@ -19929,7 +20583,7 @@ var Font = class extends SheetExtension {
19929
20583
  renderFontCtx.endX = mergeInfo.endX;
19930
20584
  renderFontCtx.endY = mergeInfo.endY;
19931
20585
  }
19932
- const fontCache = fontMatrix.getValue(row, col);
20586
+ const fontCache = cacheValue !== null && cacheValue !== void 0 ? cacheValue : fontMatrix.getValue(row, col);
19933
20587
  if (!fontCache) return true;
19934
20588
  renderFontCtx.fontCache = fontCache;
19935
20589
  const overflowRange = spreadsheetSkeleton.overflowCache.getValue(row, col);
@@ -19955,8 +20609,19 @@ var Font = class extends SheetExtension {
19955
20609
  }
19956
20610
  if (isAllColHidden) return true;
19957
20611
  }
19958
- const cellData = spreadsheetSkeleton.worksheet.getCell(row, col) || {};
19959
- if (cellData === null || cellData === void 0 || (_cellData$fontRenderE = cellData.fontRenderExtension) === null || _cellData$fontRenderE === void 0 ? void 0 : _cellData$fontRenderE.isSkip) return true;
20612
+ if ((_fontCache$cellData2 = fontCache.cellData) === null || _fontCache$cellData2 === void 0 ? void 0 : _fontCache$cellData2.fontRenderExtension) {
20613
+ var _cellData$fontRenderE;
20614
+ const cellData = spreadsheetSkeleton.worksheet.getCell(row, col) || {};
20615
+ if (cellData === null || cellData === void 0 || (_cellData$fontRenderE = cellData.fontRenderExtension) === null || _cellData$fontRenderE === void 0 ? void 0 : _cellData$fontRenderE.isSkip) return true;
20616
+ }
20617
+ if (this._renderPlainTextWithoutClip(ctx, renderFontCtx, fontCache)) {
20618
+ renderFontCtx.startX = 0;
20619
+ renderFontCtx.startY = 0;
20620
+ renderFontCtx.endX = 0;
20621
+ renderFontCtx.endY = 0;
20622
+ renderFontCtx.overflowRectangle = null;
20623
+ return false;
20624
+ }
19960
20625
  ctx.save();
19961
20626
  ctx.beginPath();
19962
20627
  renderFontCtx.overflowRectangle = overflowRange;
@@ -19964,7 +20629,6 @@ var Font = class extends SheetExtension {
19964
20629
  ctx.translate(renderFontCtx.startX + FIX_ONE_PIXEL_BLUR_OFFSET, renderFontCtx.startY + FIX_ONE_PIXEL_BLUR_OFFSET);
19965
20630
  if (fontCache.documentSkeleton) this._renderDocuments(ctx, row, col, renderFontCtx, spreadsheetSkeleton.overflowCache);
19966
20631
  else this._renderText(ctx, row, col, renderFontCtx, spreadsheetSkeleton.overflowCache);
19967
- ctx.closePath();
19968
20632
  ctx.restore();
19969
20633
  if (fontCache.documentSkeleton) {
19970
20634
  var _documentDataModel$ge;
@@ -19984,15 +20648,49 @@ var Font = class extends SheetExtension {
19984
20648
  renderFontCtx.overflowRectangle = null;
19985
20649
  return false;
19986
20650
  }
20651
+ _renderPlainTextWithoutClip(ctx, renderFontCtx, fontCache) {
20652
+ var _fontCache$style, _fontCache$style2, _fontCache$style$pd, _fontCache$style3, _padding$l, _padding$r, _padding$t, _padding$b, _fontCache$displayTex, _fontCache$style4;
20653
+ const { cellData, documentSkeleton, textFitsCurrentCell, vertexAngle = 0, centerAngle = 0, wrapStrategy } = fontCache;
20654
+ if (!textFitsCurrentCell) return false;
20655
+ if (documentSkeleton) return false;
20656
+ if (vertexAngle !== 0 || centerAngle !== 0) return false;
20657
+ if (wrapStrategy === WrapStrategy.WRAP) return false;
20658
+ if (needsFontRenderExtensionBounds(fontCache)) return false;
20659
+ if (((_fontCache$style = fontCache.style) === null || _fontCache$style === void 0 || (_fontCache$style = _fontCache$style.st) === null || _fontCache$style === void 0 ? void 0 : _fontCache$style.s) || ((_fontCache$style2 = fontCache.style) === null || _fontCache$style2 === void 0 || (_fontCache$style2 = _fontCache$style2.ul) === null || _fontCache$style2 === void 0 ? void 0 : _fontCache$style2.s)) return false;
20660
+ if ((cellData === null || cellData === void 0 ? void 0 : cellData.v) === void 0 || (cellData === null || cellData === void 0 ? void 0 : cellData.v) === null) return false;
20661
+ const padding = (_fontCache$style$pd = (_fontCache$style3 = fontCache.style) === null || _fontCache$style3 === void 0 ? void 0 : _fontCache$style3.pd) !== null && _fontCache$style$pd !== void 0 ? _fontCache$style$pd : DEFAULT_PADDING_DATA;
20662
+ const paddingLeft = (_padding$l = padding.l) !== null && _padding$l !== void 0 ? _padding$l : DEFAULT_PADDING_DATA.l;
20663
+ const paddingRight = (_padding$r = padding.r) !== null && _padding$r !== void 0 ? _padding$r : DEFAULT_PADDING_DATA.r;
20664
+ const paddingTop = (_padding$t = padding.t) !== null && _padding$t !== void 0 ? _padding$t : DEFAULT_PADDING_DATA.t;
20665
+ const paddingBottom = (_padding$b = padding.b) !== null && _padding$b !== void 0 ? _padding$b : DEFAULT_PADDING_DATA.b;
20666
+ const text = (_fontCache$displayTex = fontCache.displayText) !== null && _fontCache$displayTex !== void 0 ? _fontCache$displayTex : getDisplayValueFromCell(cellData);
20667
+ const { startX, startY, endX, endY } = renderFontCtx;
20668
+ const cellWidth = endX - startX - paddingLeft - paddingRight;
20669
+ const cellHeight = endY - startY - paddingTop - paddingBottom;
20670
+ const hAlign = getResolvedRenderHorizontalAlign(fontCache, cellData);
20671
+ Text.drawPlainWith(ctx, {
20672
+ text,
20673
+ fontStyle: fontCache.fontString,
20674
+ hAlign,
20675
+ vAlign: fontCache.verticalAlign,
20676
+ width: cellWidth,
20677
+ height: cellHeight,
20678
+ left: startX + FIX_ONE_PIXEL_BLUR_OFFSET + paddingLeft,
20679
+ top: startY + FIX_ONE_PIXEL_BLUR_OFFSET + paddingTop,
20680
+ color: (_fontCache$style4 = fontCache.style) === null || _fontCache$style4 === void 0 || (_fontCache$style4 = _fontCache$style4.cl) === null || _fontCache$style4 === void 0 ? void 0 : _fontCache$style4.rgb,
20681
+ cellValueType: cellData.t
20682
+ });
20683
+ return true;
20684
+ }
19987
20685
  _renderImages(ctx, fontsConfig, startX, startY, endX, endY) {
19988
- var _fontsConfig$style, _padding$l, _padding$r, _padding$t, _padding$b, _getSkeletonData;
20686
+ var _fontsConfig$style, _padding$l2, _padding$r2, _padding$t2, _padding$b2, _getSkeletonData;
19989
20687
  const { documentSkeleton, verticalAlign, horizontalAlign } = fontsConfig;
19990
20688
  const PADDING = 2;
19991
20689
  const padding = (_fontsConfig$style = fontsConfig.style) === null || _fontsConfig$style === void 0 ? void 0 : _fontsConfig$style.pd;
19992
- const paddingLeft = (_padding$l = padding === null || padding === void 0 ? void 0 : padding.l) !== null && _padding$l !== void 0 ? _padding$l : PADDING;
19993
- const paddingRight = (_padding$r = padding === null || padding === void 0 ? void 0 : padding.r) !== null && _padding$r !== void 0 ? _padding$r : PADDING;
19994
- const paddingTop = (_padding$t = padding === null || padding === void 0 ? void 0 : padding.t) !== null && _padding$t !== void 0 ? _padding$t : PADDING;
19995
- const paddingBottom = (_padding$b = padding === null || padding === void 0 ? void 0 : padding.b) !== null && _padding$b !== void 0 ? _padding$b : PADDING;
20690
+ const paddingLeft = (_padding$l2 = padding === null || padding === void 0 ? void 0 : padding.l) !== null && _padding$l2 !== void 0 ? _padding$l2 : PADDING;
20691
+ const paddingRight = (_padding$r2 = padding === null || padding === void 0 ? void 0 : padding.r) !== null && _padding$r2 !== void 0 ? _padding$r2 : PADDING;
20692
+ const paddingTop = (_padding$t2 = padding === null || padding === void 0 ? void 0 : padding.t) !== null && _padding$t2 !== void 0 ? _padding$t2 : PADDING;
20693
+ const paddingBottom = (_padding$b2 = padding === null || padding === void 0 ? void 0 : padding.b) !== null && _padding$b2 !== void 0 ? _padding$b2 : PADDING;
19996
20694
  const contentStartX = startX + paddingLeft;
19997
20695
  const contentEndX = endX - paddingRight;
19998
20696
  const contentStartY = startY + paddingTop;
@@ -20062,7 +20760,7 @@ var Font = class extends SheetExtension {
20062
20760
  * @param fontCache
20063
20761
  */
20064
20762
  _clipByRenderBounds(renderFontContext, row, col, padding = 0) {
20065
- var _fontCache$cellData$f, _fontCache$cellData, _fontCache$cellData$f2, _fontCache$cellData2;
20763
+ var _fontCache$cellData$f, _fontCache$cellData3, _fontCache$cellData$f2, _fontCache$cellData4;
20066
20764
  const { ctx, scale, overflowRectangle, fontCache } = renderFontContext;
20067
20765
  let { startX, endX, startY, endY } = renderFontContext;
20068
20766
  const { horizontalAlign = 0, vertexAngle = 0, centerAngle = 0 } = fontCache;
@@ -20071,8 +20769,8 @@ var Font = class extends SheetExtension {
20071
20769
  if (centerAngle === 90 && vertexAngle === 90) horizontalAlignOverFlow = HorizontalAlign.CENTER;
20072
20770
  else if (vertexAngle > 0 && vertexAngle !== 90 || vertexAngle === -90) horizontalAlignOverFlow = HorizontalAlign.RIGHT;
20073
20771
  }
20074
- const rightOffset = (_fontCache$cellData$f = fontCache === null || fontCache === void 0 || (_fontCache$cellData = fontCache.cellData) === null || _fontCache$cellData === void 0 || (_fontCache$cellData = _fontCache$cellData.fontRenderExtension) === null || _fontCache$cellData === void 0 ? void 0 : _fontCache$cellData.rightOffset) !== null && _fontCache$cellData$f !== void 0 ? _fontCache$cellData$f : 0;
20075
- const leftOffset = (_fontCache$cellData$f2 = fontCache === null || fontCache === void 0 || (_fontCache$cellData2 = fontCache.cellData) === null || _fontCache$cellData2 === void 0 || (_fontCache$cellData2 = _fontCache$cellData2.fontRenderExtension) === null || _fontCache$cellData2 === void 0 ? void 0 : _fontCache$cellData2.leftOffset) !== null && _fontCache$cellData$f2 !== void 0 ? _fontCache$cellData$f2 : 0;
20772
+ const rightOffset = (_fontCache$cellData$f = fontCache === null || fontCache === void 0 || (_fontCache$cellData3 = fontCache.cellData) === null || _fontCache$cellData3 === void 0 || (_fontCache$cellData3 = _fontCache$cellData3.fontRenderExtension) === null || _fontCache$cellData3 === void 0 ? void 0 : _fontCache$cellData3.rightOffset) !== null && _fontCache$cellData$f !== void 0 ? _fontCache$cellData$f : 0;
20773
+ const leftOffset = (_fontCache$cellData$f2 = fontCache === null || fontCache === void 0 || (_fontCache$cellData4 = fontCache.cellData) === null || _fontCache$cellData4 === void 0 || (_fontCache$cellData4 = _fontCache$cellData4.fontRenderExtension) === null || _fontCache$cellData4 === void 0 ? void 0 : _fontCache$cellData4.leftOffset) !== null && _fontCache$cellData$f2 !== void 0 ? _fontCache$cellData$f2 : 0;
20076
20774
  let isOverflow = true;
20077
20775
  if (vertexAngle === 0) {
20078
20776
  startX = startX + leftOffset;
@@ -20104,26 +20802,22 @@ var Font = class extends SheetExtension {
20104
20802
  renderFontContext.endY = endY;
20105
20803
  }
20106
20804
  _renderText(ctx, row, col, renderFontCtx, overflowCache) {
20107
- var _fontCache$style$pd, _fontCache$style, _padding$l2, _padding$r2, _padding$t2, _padding$b2, _fontCache$style2, _fontCache$style3, _fontCache$style4, _fontCache$style5;
20805
+ var _fontCache$style$pd2, _fontCache$style5, _padding$l3, _padding$r3, _padding$t3, _padding$b3, _fontCache$displayTex2, _fontCache$style6, _fontCache$style7, _fontCache$style8, _fontCache$style9;
20108
20806
  const { fontCache } = renderFontCtx;
20109
20807
  if (!fontCache) return;
20110
- const padding = (_fontCache$style$pd = (_fontCache$style = fontCache.style) === null || _fontCache$style === void 0 ? void 0 : _fontCache$style.pd) !== null && _fontCache$style$pd !== void 0 ? _fontCache$style$pd : DEFAULT_PADDING_DATA;
20111
- const paddingLeft = (_padding$l2 = padding.l) !== null && _padding$l2 !== void 0 ? _padding$l2 : DEFAULT_PADDING_DATA.l;
20112
- const paddingRight = (_padding$r2 = padding.r) !== null && _padding$r2 !== void 0 ? _padding$r2 : DEFAULT_PADDING_DATA.r;
20113
- const paddingTop = (_padding$t2 = padding.t) !== null && _padding$t2 !== void 0 ? _padding$t2 : DEFAULT_PADDING_DATA.t;
20114
- const paddingBottom = (_padding$b2 = padding.b) !== null && _padding$b2 !== void 0 ? _padding$b2 : DEFAULT_PADDING_DATA.b;
20808
+ const padding = (_fontCache$style$pd2 = (_fontCache$style5 = fontCache.style) === null || _fontCache$style5 === void 0 ? void 0 : _fontCache$style5.pd) !== null && _fontCache$style$pd2 !== void 0 ? _fontCache$style$pd2 : DEFAULT_PADDING_DATA;
20809
+ const paddingLeft = (_padding$l3 = padding.l) !== null && _padding$l3 !== void 0 ? _padding$l3 : DEFAULT_PADDING_DATA.l;
20810
+ const paddingRight = (_padding$r3 = padding.r) !== null && _padding$r3 !== void 0 ? _padding$r3 : DEFAULT_PADDING_DATA.r;
20811
+ const paddingTop = (_padding$t3 = padding.t) !== null && _padding$t3 !== void 0 ? _padding$t3 : DEFAULT_PADDING_DATA.t;
20812
+ const paddingBottom = (_padding$b3 = padding.b) !== null && _padding$b3 !== void 0 ? _padding$b3 : DEFAULT_PADDING_DATA.b;
20115
20813
  const { vertexAngle = 0, wrapStrategy, cellData } = fontCache;
20116
20814
  if ((cellData === null || cellData === void 0 ? void 0 : cellData.v) === void 0 || (cellData === null || cellData === void 0 ? void 0 : cellData.v) === null) return;
20117
- const text = getDisplayValueFromCell(cellData);
20815
+ const text = (_fontCache$displayTex2 = fontCache.displayText) !== null && _fontCache$displayTex2 !== void 0 ? _fontCache$displayTex2 : getDisplayValueFromCell(cellData);
20118
20816
  const { startX, startY, endX, endY } = renderFontCtx;
20119
20817
  const cellWidth = endX - startX - paddingLeft - paddingRight;
20120
20818
  const cellHeight = endY - startY - paddingTop - paddingBottom;
20121
- let hAlign = fontCache.horizontalAlign;
20122
- if (fontCache.horizontalAlign === HorizontalAlign.UNSPECIFIED) {
20123
- if (cellData.t === CellValueType.NUMBER || !Tools.isDefine(cellData.t) && typeof cellData.v === "number") hAlign = HorizontalAlign.RIGHT;
20124
- else if (cellData.t === CellValueType.BOOLEAN) hAlign = HorizontalAlign.CENTER;
20125
- }
20126
- Text.drawWith(ctx, {
20819
+ const hAlign = getResolvedRenderHorizontalAlign(fontCache, cellData);
20820
+ const textProps = {
20127
20821
  text,
20128
20822
  fontStyle: fontCache.fontString,
20129
20823
  warp: wrapStrategy === WrapStrategy.WRAP && vertexAngle === 0,
@@ -20133,12 +20827,17 @@ var Font = class extends SheetExtension {
20133
20827
  height: cellHeight,
20134
20828
  left: paddingLeft,
20135
20829
  top: paddingTop,
20136
- color: (_fontCache$style2 = fontCache.style) === null || _fontCache$style2 === void 0 || (_fontCache$style2 = _fontCache$style2.cl) === null || _fontCache$style2 === void 0 ? void 0 : _fontCache$style2.rgb,
20137
- strokeLine: Boolean((_fontCache$style3 = fontCache.style) === null || _fontCache$style3 === void 0 || (_fontCache$style3 = _fontCache$style3.st) === null || _fontCache$style3 === void 0 ? void 0 : _fontCache$style3.s),
20138
- underline: Boolean((_fontCache$style4 = fontCache.style) === null || _fontCache$style4 === void 0 || (_fontCache$style4 = _fontCache$style4.ul) === null || _fontCache$style4 === void 0 ? void 0 : _fontCache$style4.s),
20139
- underlineType: (_fontCache$style5 = fontCache.style) === null || _fontCache$style5 === void 0 || (_fontCache$style5 = _fontCache$style5.ul) === null || _fontCache$style5 === void 0 ? void 0 : _fontCache$style5.t,
20830
+ color: (_fontCache$style6 = fontCache.style) === null || _fontCache$style6 === void 0 || (_fontCache$style6 = _fontCache$style6.cl) === null || _fontCache$style6 === void 0 ? void 0 : _fontCache$style6.rgb,
20831
+ strokeLine: Boolean((_fontCache$style7 = fontCache.style) === null || _fontCache$style7 === void 0 || (_fontCache$style7 = _fontCache$style7.st) === null || _fontCache$style7 === void 0 ? void 0 : _fontCache$style7.s),
20832
+ underline: Boolean((_fontCache$style8 = fontCache.style) === null || _fontCache$style8 === void 0 || (_fontCache$style8 = _fontCache$style8.ul) === null || _fontCache$style8 === void 0 ? void 0 : _fontCache$style8.s),
20833
+ underlineType: (_fontCache$style9 = fontCache.style) === null || _fontCache$style9 === void 0 || (_fontCache$style9 = _fontCache$style9.ul) === null || _fontCache$style9 === void 0 ? void 0 : _fontCache$style9.t,
20140
20834
  cellValueType: cellData.t
20141
- });
20835
+ };
20836
+ if (!textProps.warp && !textProps.strokeLine && !textProps.underline) {
20837
+ Text.drawPlainWith(ctx, textProps);
20838
+ return;
20839
+ }
20840
+ Text.drawWith(ctx, textProps);
20142
20841
  }
20143
20842
  _renderDocuments(ctx, row, col, renderFontCtx, overflowCache) {
20144
20843
  const documents = this.getDocuments();
@@ -20208,6 +20907,15 @@ const stringifyRange = (range) => {
20208
20907
  const { startRow, endRow, startColumn, endColumn } = range;
20209
20908
  return `${startRow}-${endRow}-${startColumn}-${endColumn}`;
20210
20909
  };
20910
+ function drawTriangleMarker(ctx, color, x, y, x2, y2, x3, y3) {
20911
+ ctx.fillStyle = color;
20912
+ ctx.beginPath();
20913
+ ctx.moveTo(x, y);
20914
+ ctx.lineTo(x2, y2);
20915
+ ctx.lineTo(x3, y3);
20916
+ ctx.closePath();
20917
+ ctx.fill();
20918
+ }
20211
20919
  var Marker = class extends SheetExtension {
20212
20920
  constructor(..._args) {
20213
20921
  super(..._args);
@@ -20219,11 +20927,15 @@ var Marker = class extends SheetExtension {
20219
20927
  const { worksheet, rowColumnSegment } = skeleton;
20220
20928
  if (!worksheet) return;
20221
20929
  const mergeCellRendered = /* @__PURE__ */ new Set();
20222
- ((diffRanges === null || diffRanges === void 0 ? void 0 : diffRanges.length) ? diffRanges : [rowColumnSegment]).forEach((range) => {
20223
- Range.foreach(range, (row, col) => {
20930
+ const renderRanges = (diffRanges === null || diffRanges === void 0 ? void 0 : diffRanges.length) ? diffRanges : [rowColumnSegment];
20931
+ const hasMerge = worksheet.getMergeData().length > 0;
20932
+ renderRanges.forEach((range) => {
20933
+ const { startRow, endRow, startColumn, endColumn } = range;
20934
+ for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
20224
20935
  var _cellData$markers, _cellData$markers2, _cellData$markers3, _cellData$markers4;
20225
- if (!worksheet.getRowVisible(row) || !worksheet.getColVisible(col)) return;
20936
+ if (!worksheet.getRowVisible(row) || !worksheet.getColVisible(col)) continue;
20226
20937
  let cellData = worksheet.getCell(row, col);
20938
+ if (!hasMerge && !(cellData === null || cellData === void 0 ? void 0 : cellData.markers)) continue;
20227
20939
  const cellInfo = skeleton.getCellWithCoordByIndex(row, col, false);
20228
20940
  const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
20229
20941
  let { startY, endY, startX, endX } = cellInfo;
@@ -20240,74 +20952,38 @@ var Marker = class extends SheetExtension {
20240
20952
  };
20241
20953
  cellData = worksheet.getCell(mainCell.row, mainCell.col);
20242
20954
  }
20243
- if (!this.isRenderDiffRangesByRow(mergeInfo.startRow, mergeInfo.endRow, diffRanges)) return true;
20955
+ if (!this.isRenderDiffRangesByRow(mergeInfo.startRow, mergeInfo.endRow, diffRanges)) continue;
20244
20956
  if (cellInfo.isMerged || cellInfo.isMergedMainCell) {
20245
20957
  const rangeStr = stringifyRange(mergeInfo);
20246
- if (mergeCellRendered.has(rangeStr)) return;
20958
+ if (mergeCellRendered.has(rangeStr)) continue;
20247
20959
  mergeCellRendered.add(rangeStr);
20248
20960
  }
20249
- if (!cellData) return;
20961
+ if (!cellData) continue;
20250
20962
  if ((_cellData$markers = cellData.markers) === null || _cellData$markers === void 0 ? void 0 : _cellData$markers.tr) {
20251
- ctx.save();
20252
20963
  const marker = cellData.markers.tr;
20253
20964
  const x = endX;
20254
20965
  const y = startY;
20255
- ctx.fillStyle = marker.color;
20256
- ctx.moveTo(x, y);
20257
- ctx.beginPath();
20258
- ctx.lineTo(x - marker.size, y);
20259
- ctx.lineTo(x, y + marker.size);
20260
- ctx.lineTo(x, y);
20261
- ctx.closePath();
20262
- ctx.fill();
20263
- ctx.restore();
20966
+ drawTriangleMarker(ctx, marker.color, x, y, x - marker.size, y, x, y + marker.size);
20264
20967
  }
20265
20968
  if ((_cellData$markers2 = cellData.markers) === null || _cellData$markers2 === void 0 ? void 0 : _cellData$markers2.tl) {
20266
- ctx.save();
20267
20969
  const marker = cellData.markers.tl;
20268
20970
  const x = startX;
20269
20971
  const y = startY;
20270
- ctx.fillStyle = marker.color;
20271
- ctx.moveTo(x, y);
20272
- ctx.beginPath();
20273
- ctx.lineTo(x + marker.size, y);
20274
- ctx.lineTo(x, y + marker.size);
20275
- ctx.lineTo(x, y);
20276
- ctx.closePath();
20277
- ctx.fill();
20278
- ctx.restore();
20972
+ drawTriangleMarker(ctx, marker.color, x, y, x + marker.size, y, x, y + marker.size);
20279
20973
  }
20280
20974
  if ((_cellData$markers3 = cellData.markers) === null || _cellData$markers3 === void 0 ? void 0 : _cellData$markers3.br) {
20281
- ctx.save();
20282
20975
  const marker = cellData.markers.br;
20283
20976
  const x = endX;
20284
20977
  const y = endY;
20285
- ctx.fillStyle = marker.color;
20286
- ctx.moveTo(x, y);
20287
- ctx.beginPath();
20288
- ctx.lineTo(x - marker.size, y);
20289
- ctx.lineTo(x, y - marker.size);
20290
- ctx.lineTo(x, y);
20291
- ctx.closePath();
20292
- ctx.fill();
20293
- ctx.restore();
20978
+ drawTriangleMarker(ctx, marker.color, x, y, x - marker.size, y, x, y - marker.size);
20294
20979
  }
20295
20980
  if ((_cellData$markers4 = cellData.markers) === null || _cellData$markers4 === void 0 ? void 0 : _cellData$markers4.bl) {
20296
- ctx.save();
20297
20981
  const marker = cellData.markers.bl;
20298
20982
  const x = startX;
20299
20983
  const y = endY;
20300
- ctx.fillStyle = marker.color;
20301
- ctx.moveTo(x, y);
20302
- ctx.beginPath();
20303
- ctx.lineTo(x + marker.size, y);
20304
- ctx.lineTo(x, y - marker.size);
20305
- ctx.lineTo(x, y);
20306
- ctx.closePath();
20307
- ctx.fill();
20308
- ctx.restore();
20984
+ drawTriangleMarker(ctx, marker.color, x, y, x + marker.size, y, x, y - marker.size);
20309
20985
  }
20310
- });
20986
+ }
20311
20987
  });
20312
20988
  }
20313
20989
  };
@@ -22416,6 +23092,7 @@ const MIN_THUMB_SIZE = 17;
22416
23092
  const DEFAULT_TRACK_SIZE = 10;
22417
23093
  const DEFAULT_THUMB_MARGIN = 2;
22418
23094
  const HOVER_THUMB_MARGIN = 1;
23095
+ const BAR_DRAG_SCROLL_THROTTLE_MS = 32;
22419
23096
  var ScrollBar = class ScrollBar extends Disposable {
22420
23097
  constructor(view, props) {
22421
23098
  super();
@@ -22438,6 +23115,10 @@ var ScrollBar = class ScrollBar extends Disposable {
22438
23115
  _defineProperty(this, "_lastY", -1);
22439
23116
  _defineProperty(this, "_isHorizonMove", false);
22440
23117
  _defineProperty(this, "_isVerticalMove", false);
23118
+ _defineProperty(this, "_pendingBarDeltaX", 0);
23119
+ _defineProperty(this, "_pendingBarDeltaY", 0);
23120
+ _defineProperty(this, "_pendingBarScrollFrameId", null);
23121
+ _defineProperty(this, "_pendingBarScrollThrottleId", null);
22441
23122
  _defineProperty(this, "_horizonPointerMoveSub", void 0);
22442
23123
  _defineProperty(this, "_horizonPointerUpSub", void 0);
22443
23124
  _defineProperty(this, "_verticalPointerMoveSub", void 0);
@@ -22575,6 +23256,7 @@ var ScrollBar = class ScrollBar extends Disposable {
22575
23256
  dispose() {
22576
23257
  var _this$horizonScrollTr, _this$horizonThumbRec3, _this$verticalScrollT, _this$verticalThumbRe3, _this$placeholderBarR, _this$_horizonPointer, _this$_horizonPointer2, _this$_verticalPointe, _this$_verticalPointe2;
22577
23258
  super.dispose();
23259
+ this._flushPendingBarScroll();
22578
23260
  (_this$horizonScrollTr = this.horizonScrollTrack) === null || _this$horizonScrollTr === void 0 || _this$horizonScrollTr.dispose();
22579
23261
  (_this$horizonThumbRec3 = this.horizonThumbRect) === null || _this$horizonThumbRec3 === void 0 || _this$horizonThumbRec3.dispose();
22580
23262
  (_this$verticalScrollT = this.verticalScrollTrack) === null || _this$verticalScrollT === void 0 || _this$verticalScrollT.dispose();
@@ -22593,6 +23275,47 @@ var ScrollBar = class ScrollBar extends Disposable {
22593
23275
  this._mainScene = null;
22594
23276
  this._viewport.removeScrollBar();
22595
23277
  }
23278
+ _scheduleBarScrollDelta(delta) {
23279
+ var _delta$x, _delta$y;
23280
+ this._pendingBarDeltaX += (_delta$x = delta.x) !== null && _delta$x !== void 0 ? _delta$x : 0;
23281
+ this._pendingBarDeltaY += (_delta$y = delta.y) !== null && _delta$y !== void 0 ? _delta$y : 0;
23282
+ if (this._pendingBarScrollFrameId !== null || this._pendingBarScrollThrottleId !== null) return;
23283
+ this._requestPendingBarScrollFrame();
23284
+ }
23285
+ _requestPendingBarScrollFrame() {
23286
+ this._pendingBarScrollFrameId = requestAnimationFrame(() => {
23287
+ this._pendingBarScrollFrameId = null;
23288
+ this._applyPendingBarScroll({ isBarDragging: true });
23289
+ if (!this._isHorizonMove && !this._isVerticalMove) return;
23290
+ this._pendingBarScrollThrottleId = window.setTimeout(() => {
23291
+ this._pendingBarScrollThrottleId = null;
23292
+ if (this._pendingBarDeltaX !== 0 || this._pendingBarDeltaY !== 0) this._requestPendingBarScrollFrame();
23293
+ }, BAR_DRAG_SCROLL_THROTTLE_MS);
23294
+ });
23295
+ }
23296
+ _flushPendingBarScroll(isBarDragEnd = false) {
23297
+ if (this._pendingBarScrollFrameId !== null) {
23298
+ cancelAnimationFrame(this._pendingBarScrollFrameId);
23299
+ this._pendingBarScrollFrameId = null;
23300
+ }
23301
+ if (this._pendingBarScrollThrottleId !== null) {
23302
+ clearTimeout(this._pendingBarScrollThrottleId);
23303
+ this._pendingBarScrollThrottleId = null;
23304
+ }
23305
+ return this._applyPendingBarScroll({ isBarDragEnd });
23306
+ }
23307
+ _applyPendingBarScroll(options) {
23308
+ const x = this._pendingBarDeltaX;
23309
+ const y = this._pendingBarDeltaY;
23310
+ if (x === 0 && y === 0) return false;
23311
+ this._pendingBarDeltaX = 0;
23312
+ this._pendingBarDeltaY = 0;
23313
+ this._viewport.scrollByBarDeltaValue({
23314
+ ...x === 0 ? null : { x },
23315
+ ...y === 0 ? null : { y }
23316
+ }, true, options);
23317
+ return true;
23318
+ }
22596
23319
  render(ctx, left = 0, top = 0) {
22597
23320
  const { scrollX, scrollY } = this._viewport;
22598
23321
  ctx.save();
@@ -22797,12 +23520,14 @@ var ScrollBar = class ScrollBar extends Disposable {
22797
23520
  var _mainScene$getEngine;
22798
23521
  const e = evt;
22799
23522
  if (!this._isVerticalMove) return;
22800
- this._viewport.scrollByBarDeltaValue({ y: e.offsetY - this._lastY });
23523
+ this._scheduleBarScrollDelta({ y: e.offsetY - this._lastY });
22801
23524
  this._lastY = e.offsetY;
22802
23525
  (_mainScene$getEngine = mainScene.getEngine()) === null || _mainScene$getEngine === void 0 || _mainScene$getEngine.setCapture();
22803
23526
  });
22804
23527
  this._verticalPointerUpSub = mainScene.onPointerUp$.subscribeEvent((_evt, _state) => {
23528
+ if (!this._isVerticalMove) return;
22805
23529
  const srcElement = this.verticalThumbRect;
23530
+ if (!this._flushPendingBarScroll(true)) this._viewport.scrollByBarDeltaValue({ y: 0 }, true, { isBarDragEnd: true });
22806
23531
  this._isVerticalMove = false;
22807
23532
  mainScene.releaseCapturedObject();
22808
23533
  mainScene.enableObjectsEvent();
@@ -22871,12 +23596,14 @@ var ScrollBar = class ScrollBar extends Disposable {
22871
23596
  var _mainScene$getEngine2;
22872
23597
  const e = evt;
22873
23598
  if (!this._isHorizonMove) return;
22874
- this._viewport.scrollByBarDeltaValue({ x: e.offsetX - this._lastX });
23599
+ this._scheduleBarScrollDelta({ x: e.offsetX - this._lastX });
22875
23600
  this._lastX = e.offsetX;
22876
23601
  (_mainScene$getEngine2 = mainScene.getEngine()) === null || _mainScene$getEngine2 === void 0 || _mainScene$getEngine2.setCapture();
22877
23602
  });
22878
23603
  this._horizonPointerUpSub = mainScene.onPointerUp$.subscribeEvent((evt, state) => {
22879
23604
  var _this$horizonThumbRec11;
23605
+ if (!this._isHorizonMove) return;
23606
+ if (!this._flushPendingBarScroll(true)) this._viewport.scrollByBarDeltaValue({ x: 0 }, true, { isBarDragEnd: true });
22880
23607
  this._isHorizonMove = false;
22881
23608
  mainScene.releaseCapturedObject();
22882
23609
  mainScene.enableObjectsEvent();
@@ -23092,7 +23819,7 @@ var FontAndBaseLine = class extends docExtension {
23092
23819
  const { vertexAngle, centerAngle } = renderConfig !== null && renderConfig !== void 0 ? renderConfig : {};
23093
23820
  const VERTICAL_DEG = 90;
23094
23821
  const isVertical = vertexAngle === VERTICAL_DEG && centerAngle === VERTICAL_DEG;
23095
- if (isVertical && !hasCJK(content)) {
23822
+ if (isVertical && !cjk.hasCJK(content)) {
23096
23823
  ctx.save();
23097
23824
  ctx.translate(spanStartPoint.x + centerPoint.x, spanStartPoint.y + centerPoint.y);
23098
23825
  ctx.rotate(Math.PI / 2);
@@ -23614,7 +24341,7 @@ var Documents = class Documents extends DocComponent {
23614
24341
  ctx.restore();
23615
24342
  }
23616
24343
  _drawBorderBottom(ctx, page, line, left = 0, top = 0) {
23617
- var _line$borderBottom$pa, _line$borderBottom, _line$borderBottom$co, _line$borderBottom2;
24344
+ var _line$borderBottom$pa, _line$borderBottom, _border$width, _border$color$rgb;
23618
24345
  if (this._drawLiquid == null) return;
23619
24346
  let { x, y } = this._drawLiquid;
23620
24347
  const { pageWidth, marginLeft, marginRight, marginTop } = page;
@@ -23623,8 +24350,10 @@ var Documents = class Documents extends DocComponent {
23623
24350
  y -= line.paddingTop;
23624
24351
  y += marginTop + top + line.lineHeight + ((_line$borderBottom$pa = (_line$borderBottom = line.borderBottom) === null || _line$borderBottom === void 0 ? void 0 : _line$borderBottom.padding) !== null && _line$borderBottom$pa !== void 0 ? _line$borderBottom$pa : 0);
23625
24352
  ctx.save();
23626
- ctx.setLineWidthByPrecision(1);
23627
- ctx.strokeStyle = (_line$borderBottom$co = (_line$borderBottom2 = line.borderBottom) === null || _line$borderBottom2 === void 0 ? void 0 : _line$borderBottom2.color.rgb) !== null && _line$borderBottom$co !== void 0 ? _line$borderBottom$co : "#CDD0D8";
24353
+ const border = line.borderBottom;
24354
+ ctx.setLineWidthByPrecision(Math.max(0, (_border$width = border === null || border === void 0 ? void 0 : border.width) !== null && _border$width !== void 0 ? _border$width : 1));
24355
+ ctx.strokeStyle = (_border$color$rgb = border === null || border === void 0 ? void 0 : border.color.rgb) !== null && _border$color$rgb !== void 0 ? _border$color$rgb : "#CDD0D8";
24356
+ setDocsBorderDash(ctx, border === null || border === void 0 ? void 0 : border.dashStyle);
23628
24357
  drawLineByBorderType(ctx, "b", 0, {
23629
24358
  startX: x,
23630
24359
  startY: y,
@@ -23786,21 +24515,21 @@ var Documents = class Documents extends DocComponent {
23786
24515
  return DEFAULT_BORDER_COLOR;
23787
24516
  }
23788
24517
  _isDrawableTableCellBorder(border) {
23789
- var _border$width$v, _border$width, _border$color$rgb, _border$color;
24518
+ var _border$width$v, _border$width2, _border$color$rgb2, _border$color;
23790
24519
  if (!border) return false;
23791
- const lineWidth = (_border$width$v = (_border$width = border.width) === null || _border$width === void 0 ? void 0 : _border$width.v) !== null && _border$width$v !== void 0 ? _border$width$v : 1;
23792
- const color = (_border$color$rgb = (_border$color = border.color) === null || _border$color === void 0 ? void 0 : _border$color.rgb) !== null && _border$color$rgb !== void 0 ? _border$color$rgb : DEFAULT_BORDER_COLOR.color.rgb;
24520
+ const lineWidth = (_border$width$v = (_border$width2 = border.width) === null || _border$width2 === void 0 ? void 0 : _border$width2.v) !== null && _border$width$v !== void 0 ? _border$width$v : 1;
24521
+ const color = (_border$color$rgb2 = (_border$color = border.color) === null || _border$color === void 0 ? void 0 : _border$color.rgb) !== null && _border$color$rgb2 !== void 0 ? _border$color$rgb2 : DEFAULT_BORDER_COLOR.color.rgb;
23793
24522
  return lineWidth > 0 && color !== "transparent";
23794
24523
  }
23795
24524
  _drawTableCellBorder(ctx, border, type, position) {
23796
- var _border$width$v2, _border$width2, _border$color$rgb2, _border$color2;
24525
+ var _border$width$v2, _border$width3, _border$color$rgb3, _border$color2;
23797
24526
  if (!border) return;
23798
- const lineWidth = (_border$width$v2 = (_border$width2 = border.width) === null || _border$width2 === void 0 ? void 0 : _border$width2.v) !== null && _border$width$v2 !== void 0 ? _border$width$v2 : 1;
23799
- const color = (_border$color$rgb2 = (_border$color2 = border.color) === null || _border$color2 === void 0 ? void 0 : _border$color2.rgb) !== null && _border$color$rgb2 !== void 0 ? _border$color$rgb2 : DEFAULT_BORDER_COLOR.color.rgb;
24527
+ const lineWidth = (_border$width$v2 = (_border$width3 = border.width) === null || _border$width3 === void 0 ? void 0 : _border$width3.v) !== null && _border$width$v2 !== void 0 ? _border$width$v2 : 1;
24528
+ const color = (_border$color$rgb3 = (_border$color2 = border.color) === null || _border$color2 === void 0 ? void 0 : _border$color2.rgb) !== null && _border$color$rgb3 !== void 0 ? _border$color$rgb3 : DEFAULT_BORDER_COLOR.color.rgb;
23800
24529
  if (lineWidth <= 0 || color === "transparent") return;
23801
24530
  ctx.save();
23802
24531
  ctx.setLineWidthByPrecision(lineWidth);
23803
- setTableCellBorderDash(ctx, border.dashStyle);
24532
+ setDocsBorderDash(ctx, border.dashStyle);
23804
24533
  ctx.strokeStyle = color;
23805
24534
  drawLineByBorderType(ctx, type, 0, position);
23806
24535
  ctx.restore();
@@ -23809,7 +24538,15 @@ var Documents = class Documents extends DocComponent {
23809
24538
  if (this._drawLiquid == null) return;
23810
24539
  const { sections, skeTables } = page;
23811
24540
  const { y: originY } = this._drawLiquid;
23812
- if (skeTables.size > 0) this._drawTable(ctx, page, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
24541
+ if (skeTables.size > 0) {
24542
+ const tablePage = {
24543
+ ...page,
24544
+ marginLeft: parentPage.marginLeft,
24545
+ marginRight: parentPage.marginRight,
24546
+ marginTop: isHeader ? page.marginTop : page.marginTop + alignOffsetNoAngle.y
24547
+ };
24548
+ this._drawTable(ctx, tablePage, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
24549
+ }
23813
24550
  for (const section of sections) {
23814
24551
  const { columns } = section;
23815
24552
  this._drawLiquid.translateSave();
@@ -23922,7 +24659,7 @@ var Documents = class Documents extends DocComponent {
23922
24659
  });
23923
24660
  }
23924
24661
  };
23925
- function setTableCellBorderDash(ctx, dashStyle) {
24662
+ function setDocsBorderDash(ctx, dashStyle) {
23926
24663
  if (dashStyle === DashStyleType.DOT) {
23927
24664
  ctx.setLineDash([2]);
23928
24665
  return;
@@ -23968,6 +24705,85 @@ function rectByPrecisionBounds(ctx, x, y, width, height) {
23968
24705
  //#endregion
23969
24706
  //#region src/components/sheets/spreadsheet.ts
23970
24707
  const OBJECT_KEY = "__SHEET_EXTENSION_FONT_DOCUMENT_INSTANCE__";
24708
+ function pushSparseCellRange(ranges, row, col) {
24709
+ const last = ranges[ranges.length - 1];
24710
+ if (last && last.startRow === row && last.endRow === row && last.endColumn + 1 === col) {
24711
+ last.endColumn = col;
24712
+ return;
24713
+ }
24714
+ ranges.push({
24715
+ startRow: row,
24716
+ endRow: row,
24717
+ startColumn: col,
24718
+ endColumn: col
24719
+ });
24720
+ }
24721
+ function scanSparseExtensionFeatures(spreadsheetSkeleton, ranges) {
24722
+ const { worksheet } = spreadsheetSkeleton;
24723
+ if (!worksheet || !ranges.length || worksheet.getMergeData().length > 0) return null;
24724
+ const flags = {
24725
+ hasCustomRender: false,
24726
+ hasMarkers: false,
24727
+ hasSelectionProtection: false,
24728
+ customRenderRanges: [],
24729
+ markerRanges: [],
24730
+ selectionProtectionRanges: []
24731
+ };
24732
+ for (const range of ranges) for (let row = range.startRow; row <= range.endRow; row++) {
24733
+ if (!worksheet.getRowVisible(row)) continue;
24734
+ for (let col = range.startColumn; col <= range.endColumn; col++) {
24735
+ var _spreadsheetSkeleton$, _cell$customRender, _cell$selectionProtec;
24736
+ if (!worksheet.getColVisible(col)) continue;
24737
+ const cachedCell = (_spreadsheetSkeleton$ = spreadsheetSkeleton.stylesCache.fontMatrix.getValue(row, col)) === null || _spreadsheetSkeleton$ === void 0 ? void 0 : _spreadsheetSkeleton$.cellData;
24738
+ const cell = cachedCell !== null && cachedCell !== void 0 ? cachedCell : worksheet.getCell(row, col);
24739
+ if (!cell) continue;
24740
+ if ((_cell$customRender = cell.customRender) === null || _cell$customRender === void 0 ? void 0 : _cell$customRender.length) {
24741
+ flags.hasCustomRender = true;
24742
+ pushSparseCellRange(flags.customRenderRanges, row, col);
24743
+ }
24744
+ if (cell.markers) {
24745
+ flags.hasMarkers = true;
24746
+ pushSparseCellRange(flags.markerRanges, row, col);
24747
+ }
24748
+ if ((_cell$selectionProtec = cell.selectionProtection) === null || _cell$selectionProtec === void 0 ? void 0 : _cell$selectionProtec.length) {
24749
+ flags.hasSelectionProtection = true;
24750
+ pushSparseCellRange(flags.selectionProtectionRanges, row, col);
24751
+ }
24752
+ }
24753
+ }
24754
+ return flags;
24755
+ }
24756
+ function shouldSkipSparseExtension(uKey, flags) {
24757
+ if (!flags) return false;
24758
+ switch (uKey) {
24759
+ case "DefaultCustomExtension": return !flags.hasCustomRender;
24760
+ case "DefaultMarkerExtension": return !flags.hasMarkers;
24761
+ case "RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY":
24762
+ case "RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY": return !flags.hasSelectionProtection;
24763
+ default: return false;
24764
+ }
24765
+ }
24766
+ function hasSparseExtension(extensions) {
24767
+ return extensions.some((extension) => {
24768
+ switch (extension.uKey) {
24769
+ case "DefaultCustomExtension":
24770
+ case "DefaultMarkerExtension":
24771
+ case "RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY":
24772
+ case "RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY": return true;
24773
+ default: return false;
24774
+ }
24775
+ });
24776
+ }
24777
+ function getSparseExtensionDiffRanges(uKey, flags, diffRanges) {
24778
+ if (!flags) return diffRanges;
24779
+ switch (uKey) {
24780
+ case "DefaultCustomExtension": return flags.customRenderRanges;
24781
+ case "DefaultMarkerExtension": return flags.markerRanges;
24782
+ case "RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY":
24783
+ case "RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY": return flags.selectionProtectionRanges;
24784
+ default: return diffRanges;
24785
+ }
24786
+ }
23971
24787
  var Spreadsheet = class extends SheetComponent {
23972
24788
  constructor(oKey, spreadsheetSkeleton, _allowCache = true) {
23973
24789
  super(oKey, spreadsheetSkeleton);
@@ -24022,7 +24838,8 @@ var Spreadsheet = class extends SheetComponent {
24022
24838
  var _viewportInfo$diffBou;
24023
24839
  const spreadsheetSkeleton = this.getSkeleton();
24024
24840
  if (!spreadsheetSkeleton) return;
24025
- this._drawAuxiliary(ctx);
24841
+ const hasMergeData = spreadsheetSkeleton.worksheet.getMergeData().length > 0;
24842
+ this._drawAuxiliary(ctx, hasMergeData);
24026
24843
  const parentScale = this.getParentScale();
24027
24844
  const diffRanges = this._refreshIncrementalState && viewportInfo.diffBounds ? (_viewportInfo$diffBou = viewportInfo.diffBounds) === null || _viewportInfo$diffBou === void 0 ? void 0 : _viewportInfo$diffBou.map((bound) => spreadsheetSkeleton.getRangeByViewBound(bound)) : [];
24028
24845
  const cacheRange = spreadsheetSkeleton.getCacheRangeByViewport(viewportInfo, this.isPrinting);
@@ -24033,14 +24850,19 @@ var Spreadsheet = class extends SheetComponent {
24033
24850
  endColumn: cacheRange.endColumn
24034
24851
  })) : viewRanges;
24035
24852
  const extensions = this.getExtensionsByOrder();
24853
+ const sparseExtensionFeatures = !hasMergeData && hasSparseExtension(extensions) ? scanSparseExtensionFeatures(spreadsheetSkeleton, viewRanges) : null;
24036
24854
  const scene = this.getScene();
24037
24855
  for (const extension of extensions) {
24856
+ if (shouldSkipSparseExtension(extension.uKey, sparseExtensionFeatures)) continue;
24038
24857
  const extensionViewRanges = extension === this._fontExtension || extension === this._borderExtension ? overflowSafeViewRanges : viewRanges;
24858
+ const extensionDiffRanges = getSparseExtensionDiffRanges(extension.uKey, sparseExtensionFeatures, diffRanges);
24039
24859
  const timeKey = `${SHEET_EXTENSION_PREFIX}${extension.uKey}`;
24040
24860
  const st = Tools.now();
24041
- extension.draw(ctx, parentScale, spreadsheetSkeleton, diffRanges, {
24861
+ extension.draw(ctx, parentScale, spreadsheetSkeleton, extensionDiffRanges, {
24042
24862
  viewRanges: extensionViewRanges,
24043
24863
  checkOutOfViewBound: true,
24864
+ fontRenderRanges: extension === this._fontExtension ? spreadsheetSkeleton.incrementalFontRenderRanges : void 0,
24865
+ hasMergeData,
24044
24866
  viewportKey: viewportInfo.viewportKey,
24045
24867
  viewBound: viewportInfo.cacheBound,
24046
24868
  diffBounds: viewportInfo.diffBounds
@@ -24138,7 +24960,7 @@ var Spreadsheet = class extends SheetComponent {
24138
24960
  this._dirtyBounds = dirtyBounds;
24139
24961
  }
24140
24962
  renderByViewports(mainCtx, viewportInfo, spreadsheetSkeleton) {
24141
- const { diffBounds, diffX, diffY, viewPortPosition, cacheCanvas, leftOrigin, topOrigin, bufferEdgeX, bufferEdgeY, isDirty: isViewportDirty, isForceDirty: isViewportForceDirty } = viewportInfo;
24963
+ const { diffBounds, diffX, diffY, viewPortPosition, cacheCanvas, leftOrigin, topOrigin, bufferEdgeX, bufferEdgeY, isDirty: isViewportDirty, isForceDirty: isViewportForceDirty, shouldCacheUpdate } = viewportInfo;
24142
24964
  const { rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = spreadsheetSkeleton;
24143
24965
  const { a: scaleX = 1, d: scaleY = 1 } = mainCtx.getTransform();
24144
24966
  const bufferEdgeSizeX = bufferEdgeX * scaleX / window.devicePixelRatio;
@@ -24147,8 +24969,10 @@ var Spreadsheet = class extends SheetComponent {
24147
24969
  cacheCtx.save();
24148
24970
  const isForceDirty = isViewportForceDirty || this.isForceDirty();
24149
24971
  const isDirty = isViewportDirty || this.isDirty();
24150
- const isScrollJumpOutsideCache = Math.abs(diffX) * scaleX >= cacheCanvas.getWidth() || Math.abs(diffY) * scaleY >= cacheCanvas.getHeight();
24151
- const shouldRefreshCache = isDirty || isForceDirty || isScrollJumpOutsideCache;
24972
+ const cachePixelRatio = cacheCanvas.getPixelRatio();
24973
+ const isScrollJumpOutsideCache = Math.abs(diffX) * scaleX >= cacheCanvas.getWidth() * cachePixelRatio || Math.abs(diffY) * scaleY >= cacheCanvas.getHeight() * cachePixelRatio;
24974
+ const hasMergeData = spreadsheetSkeleton.worksheet.getMergeData().length > 0;
24975
+ const shouldRefreshCache = isDirty || isForceDirty || isScrollJumpOutsideCache || hasMergeData && (diffX !== 0 || diffY !== 0) || shouldCacheUpdate && diffX !== 0;
24152
24976
  if (diffBounds.length === 0 || diffX === 0 && diffY === 0 || shouldRefreshCache) {
24153
24977
  if (shouldRefreshCache) {
24154
24978
  this.addRenderTagToScene("scrolling", false);
@@ -24242,6 +25066,8 @@ var Spreadsheet = class extends SheetComponent {
24242
25066
  }
24243
25067
  const spreadsheetSkeleton = this.getSkeleton();
24244
25068
  if (!spreadsheetSkeleton) return;
25069
+ const { viewportKey } = viewportInfo;
25070
+ if (sheetHeaderViewportKeys.includes(viewportKey)) return this;
24245
25071
  spreadsheetSkeleton.setStylesCache(viewportInfo);
24246
25072
  const segment = spreadsheetSkeleton.rowColumnSegment;
24247
25073
  if (!segment) return;
@@ -24250,10 +25076,9 @@ var Spreadsheet = class extends SheetComponent {
24250
25076
  const { rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = spreadsheetSkeleton;
24251
25077
  mainCtx.translateWithPrecision(rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop);
24252
25078
  (_this$getScene = this.getScene()) === null || _this$getScene === void 0 || _this$getScene.updateTransformerZero(rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop);
24253
- const { viewportKey } = viewportInfo;
24254
25079
  if (sheetContentViewportKeys.includes(viewportKey)) if (viewportInfo && viewportInfo.cacheCanvas) this.renderByViewports(mainCtx, viewportInfo, spreadsheetSkeleton);
24255
25080
  else this._draw(mainCtx, viewportInfo);
24256
- else if (sheetHeaderViewportKeys.includes(viewportKey)) {} else if (viewportInfo && viewportInfo.cacheCanvas) this.renderByViewports(mainCtx, viewportInfo, spreadsheetSkeleton);
25081
+ else if (viewportInfo && viewportInfo.cacheCanvas) this.renderByViewports(mainCtx, viewportInfo, spreadsheetSkeleton);
24257
25082
  else this._draw(mainCtx, viewportInfo);
24258
25083
  mainCtx.restore();
24259
25084
  return this;
@@ -24321,7 +25146,7 @@ var Spreadsheet = class extends SheetComponent {
24321
25146
  * draw gridlines
24322
25147
  * @param ctx
24323
25148
  */
24324
- _drawAuxiliary(ctx) {
25149
+ _drawAuxiliary(ctx, hasMergeData = true) {
24325
25150
  var _ref;
24326
25151
  const spreadsheetSkeleton = this.getSkeleton();
24327
25152
  if (spreadsheetSkeleton == null) return;
@@ -24363,22 +25188,24 @@ var Spreadsheet = class extends SheetComponent {
24363
25188
  const mergeVisibleRanges = [];
24364
25189
  let mergeVisibleRangeStartRow = startRow;
24365
25190
  for (let r = rowStart; r <= rowEnd; r++) {
24366
- if (worksheet.getRowVisible(r) === false) {
24367
- if (mergeVisibleRangeStartRow < r) {
24368
- mergeVisibleRanges.push({
24369
- startRow: mergeVisibleRangeStartRow,
24370
- endRow: r - 1,
24371
- startColumn,
24372
- endColumn
24373
- });
24374
- mergeVisibleRangeStartRow = r + 1;
24375
- } else if (mergeVisibleRangeStartRow === r) mergeVisibleRangeStartRow = r + 1;
24376
- } else if (r === endRow && mergeVisibleRangeStartRow <= r) mergeVisibleRanges.push({
24377
- startRow: mergeVisibleRangeStartRow,
24378
- endRow: r,
24379
- startColumn,
24380
- endColumn
24381
- });
25191
+ if (hasMergeData) {
25192
+ if (worksheet.getRowVisible(r) === false) {
25193
+ if (mergeVisibleRangeStartRow < r) {
25194
+ mergeVisibleRanges.push({
25195
+ startRow: mergeVisibleRangeStartRow,
25196
+ endRow: r - 1,
25197
+ startColumn,
25198
+ endColumn
25199
+ });
25200
+ mergeVisibleRangeStartRow = r + 1;
25201
+ } else if (mergeVisibleRangeStartRow === r) mergeVisibleRangeStartRow = r + 1;
25202
+ } else if (r === endRow && mergeVisibleRangeStartRow <= r) mergeVisibleRanges.push({
25203
+ startRow: mergeVisibleRangeStartRow,
25204
+ endRow: r,
25205
+ startColumn,
25206
+ endColumn
25207
+ });
25208
+ }
24382
25209
  if (r < 0 || r > rowHeightAccumulationLength - 1) continue;
24383
25210
  const rowEndPosition = rowHeightAccumulation[r];
24384
25211
  ctx.beginPath();
@@ -24397,7 +25224,7 @@ var Spreadsheet = class extends SheetComponent {
24397
25224
  ctx.stroke();
24398
25225
  }
24399
25226
  const mergeCellRanges = [];
24400
- for (const mergeVisibleRange of mergeVisibleRanges) {
25227
+ if (hasMergeData) for (const mergeVisibleRange of mergeVisibleRanges) {
24401
25228
  const mergeRangeInVisible = spreadsheetSkeleton.getCurrentRowColumnSegmentMergeData(mergeVisibleRange);
24402
25229
  mergeCellRanges.push(...mergeRangeInVisible);
24403
25230
  }
@@ -25336,6 +26163,164 @@ var DocBackground = class DocBackground extends DocComponent {
25336
26163
  }
25337
26164
  };
25338
26165
 
26166
+ //#endregion
26167
+ //#region src/components/docs/layout/doc-no-wrap-measure.ts
26168
+ function splitDocumentNoWrapMeasureLines(text) {
26169
+ return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
26170
+ }
26171
+ function isDocumentNoWrapMeasureTrailingWhitespace(char) {
26172
+ return char === " " || char === " " || char === "\xA0";
26173
+ }
26174
+ function getDocumentNoWrapMeasureTrailingWhitespaceStart(text) {
26175
+ let index = text.length;
26176
+ while (index > 0 && isDocumentNoWrapMeasureTrailingWhitespace(text[index - 1])) index--;
26177
+ return index;
26178
+ }
26179
+ function isDocumentNoWrapMeasureCJKText(char) {
26180
+ return /[\u2E80-\u9FFF\uF900-\uFAFF]/u.test(char);
26181
+ }
26182
+ function isDocumentNoWrapMeasureLatinText(char) {
26183
+ return /[a-z\d]/i.test(char);
26184
+ }
26185
+ function measureDocumentNoWrapTextByStyle(text, textStyle) {
26186
+ if (!text) return 0;
26187
+ return FontCache.getMeasureText(text, getFontStyleString(textStyle).fontCache).width;
26188
+ }
26189
+ function measureDocumentNoWrapCJKLatinSpacing(segment, textStyle, previous) {
26190
+ let spacing = 0;
26191
+ for (const char of Array.from(segment)) {
26192
+ const isCJK = isDocumentNoWrapMeasureCJKText(char);
26193
+ const cjkWidth = isCJK ? measureDocumentNoWrapTextByStyle(char, textStyle) : 0;
26194
+ if (isCJK && isDocumentNoWrapMeasureLatinText(previous.char)) spacing += cjkWidth / 4;
26195
+ if (isDocumentNoWrapMeasureLatinText(char) && isDocumentNoWrapMeasureCJKText(previous.char)) spacing += previous.cjkWidth / 4;
26196
+ previous.char = char;
26197
+ previous.cjkWidth = cjkWidth;
26198
+ }
26199
+ return spacing;
26200
+ }
26201
+ function measureDocumentNoWrapLineByStyle(text, textStyle) {
26202
+ const visibleText = text.slice(0, getDocumentNoWrapMeasureTrailingWhitespaceStart(text));
26203
+ return measureDocumentNoWrapTextByStyle(visibleText, textStyle) + measureDocumentNoWrapCJKLatinSpacing(visibleText, textStyle, {
26204
+ char: "",
26205
+ cjkWidth: 0
26206
+ });
26207
+ }
26208
+ function measureDocumentNoWrapRunsWidth(dataStream, textRuns, fallbackTextStyle) {
26209
+ let currentLineWidth = 0;
26210
+ let maxLineWidth = 0;
26211
+ let pendingTrailingWhitespaceWidth = 0;
26212
+ const previous = {
26213
+ char: "",
26214
+ cjkWidth: 0
26215
+ };
26216
+ const appendSegment = (segment, textStyle) => {
26217
+ if (!segment) return;
26218
+ const trailingStart = getDocumentNoWrapMeasureTrailingWhitespaceStart(segment);
26219
+ const visibleSegment = segment.slice(0, trailingStart);
26220
+ const trailingWhitespace = segment.slice(trailingStart);
26221
+ if (visibleSegment) {
26222
+ currentLineWidth += pendingTrailingWhitespaceWidth;
26223
+ pendingTrailingWhitespaceWidth = 0;
26224
+ currentLineWidth += measureDocumentNoWrapTextByStyle(visibleSegment, textStyle);
26225
+ currentLineWidth += measureDocumentNoWrapCJKLatinSpacing(visibleSegment, textStyle, previous);
26226
+ }
26227
+ if (trailingWhitespace) {
26228
+ pendingTrailingWhitespaceWidth += measureDocumentNoWrapTextByStyle(trailingWhitespace, textStyle);
26229
+ measureDocumentNoWrapCJKLatinSpacing(trailingWhitespace, textStyle, previous);
26230
+ }
26231
+ };
26232
+ const finishLine = () => {
26233
+ maxLineWidth = Math.max(maxLineWidth, currentLineWidth);
26234
+ currentLineWidth = 0;
26235
+ pendingTrailingWhitespaceWidth = 0;
26236
+ previous.char = "";
26237
+ previous.cjkWidth = 0;
26238
+ };
26239
+ const appendRange = (text, textStyle) => {
26240
+ splitDocumentNoWrapMeasureLines(text).forEach((segment, index) => {
26241
+ if (index > 0) finishLine();
26242
+ appendSegment(segment, textStyle);
26243
+ });
26244
+ };
26245
+ let cursor = 0;
26246
+ [...textRuns].sort((a, b) => a.st - b.st).forEach((run) => {
26247
+ const start = Math.max(0, run.st);
26248
+ const end = Math.max(start, run.ed);
26249
+ if (start > cursor) appendRange(dataStream.slice(cursor, start), fallbackTextStyle);
26250
+ const effectiveStart = Math.max(start, cursor);
26251
+ if (end > effectiveStart) appendRange(dataStream.slice(effectiveStart, end), run.ts);
26252
+ cursor = Math.max(cursor, end);
26253
+ });
26254
+ if (cursor < dataStream.length) appendRange(dataStream.slice(cursor), fallbackTextStyle);
26255
+ return Math.max(maxLineWidth, currentLineWidth);
26256
+ }
26257
+ function measureDocumentNoWrapTextRangeWidth(documentData, start, end) {
26258
+ var _body$dataStream, _body$textRuns, _documentData$documen2;
26259
+ const body = documentData.body;
26260
+ const dataStream = (_body$dataStream = body === null || body === void 0 ? void 0 : body.dataStream) !== null && _body$dataStream !== void 0 ? _body$dataStream : "";
26261
+ const rangeStart = Math.max(0, Math.min(dataStream.length, start));
26262
+ const rangeEnd = Math.max(rangeStart, Math.min(dataStream.length, end));
26263
+ const rangeText = dataStream.slice(rangeStart, rangeEnd);
26264
+ const textRuns = ((_body$textRuns = body === null || body === void 0 ? void 0 : body.textRuns) !== null && _body$textRuns !== void 0 ? _body$textRuns : []).map((run) => {
26265
+ const runStart = Math.max(rangeStart, run.st);
26266
+ const runEnd = Math.min(rangeEnd, run.ed);
26267
+ if (runEnd <= runStart) return null;
26268
+ return {
26269
+ ...run,
26270
+ st: runStart - rangeStart,
26271
+ ed: runEnd - rangeStart
26272
+ };
26273
+ }).filter((run) => run !== null);
26274
+ if (textRuns.length) {
26275
+ var _documentData$documen;
26276
+ return measureDocumentNoWrapRunsWidth(rangeText, textRuns, (_documentData$documen = documentData.documentStyle) === null || _documentData$documen === void 0 ? void 0 : _documentData$documen.textStyle);
26277
+ }
26278
+ return measureDocumentNoWrapLineByStyle(rangeText, (_documentData$documen2 = documentData.documentStyle) === null || _documentData$documen2 === void 0 ? void 0 : _documentData$documen2.textStyle);
26279
+ }
26280
+ /**
26281
+ * Measures the widest no-wrap line using the same text-width policy that docs
26282
+ * layout relies on for lightweight shape/text-box autofit flows.
26283
+ *
26284
+ * This is intentionally not a full document layout replacement: callers that
26285
+ * need line breaking, pagination, floating objects, or final line metrics should
26286
+ * use `DocumentSkeleton`. This helper exists for consumers that must size a
26287
+ * no-wrap host before committing a full layout pass. Keep docs-specific glyph
26288
+ * width adjustments here so feature packages do not duplicate paragraph shaping
26289
+ * details such as CJK-Latin spacing.
26290
+ */
26291
+ function measureDocumentNoWrapTextWidth(documentData) {
26292
+ var _body$dataStream2, _documentData$documen4;
26293
+ const body = documentData === null || documentData === void 0 ? void 0 : documentData.body;
26294
+ const dataStream = (_body$dataStream2 = body === null || body === void 0 ? void 0 : body.dataStream) !== null && _body$dataStream2 !== void 0 ? _body$dataStream2 : "";
26295
+ const textRuns = body === null || body === void 0 ? void 0 : body.textRuns;
26296
+ if (textRuns === null || textRuns === void 0 ? void 0 : textRuns.length) {
26297
+ var _documentData$documen3;
26298
+ return measureDocumentNoWrapRunsWidth(dataStream, textRuns, documentData === null || documentData === void 0 || (_documentData$documen3 = documentData.documentStyle) === null || _documentData$documen3 === void 0 ? void 0 : _documentData$documen3.textStyle);
26299
+ }
26300
+ const fallbackTextStyle = documentData === null || documentData === void 0 || (_documentData$documen4 = documentData.documentStyle) === null || _documentData$documen4 === void 0 ? void 0 : _documentData$documen4.textStyle;
26301
+ return Math.max(0, ...splitDocumentNoWrapMeasureLines(dataStream).map((line) => measureDocumentNoWrapLineByStyle(line, fallbackTextStyle)));
26302
+ }
26303
+ /**
26304
+ * Measures the widest segment that docs line breaking keeps together. This is
26305
+ * useful when a host may wrap normally but still needs enough width to avoid
26306
+ * clipping an individual word, CJK glyph, or punctuation segment.
26307
+ */
26308
+ function measureDocumentUnbreakableTextWidth(documentData) {
26309
+ var _documentData$body$da, _documentData$body;
26310
+ const dataStream = (_documentData$body$da = documentData === null || documentData === void 0 || (_documentData$body = documentData.body) === null || _documentData$body === void 0 ? void 0 : _documentData$body.dataStream) !== null && _documentData$body$da !== void 0 ? _documentData$body$da : "";
26311
+ if (!documentData || !dataStream) return 0;
26312
+ const breaker = new LineBreaker(dataStream);
26313
+ let start = 0;
26314
+ let maxWidth = 0;
26315
+ let breakPoint = breaker.nextBreakPoint();
26316
+ while (breakPoint) {
26317
+ maxWidth = Math.max(maxWidth, measureDocumentNoWrapTextRangeWidth(documentData, start, breakPoint.position));
26318
+ start = breakPoint.position;
26319
+ breakPoint = breaker.nextBreakPoint();
26320
+ }
26321
+ return maxWidth;
26322
+ }
26323
+
25339
26324
  //#endregion
25340
26325
  //#region src/custom/custom-object.ts
25341
26326
  var CustomObject = class extends BaseObject {
@@ -26530,7 +27515,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
26530
27515
  //#endregion
26531
27516
  //#region package.json
26532
27517
  var name = "@univerjs/engine-render";
26533
- var version = "1.0.0-alpha.1";
27518
+ var version = "1.0.0-alpha.3";
26534
27519
 
26535
27520
  //#endregion
26536
27521
  //#region src/config/config.ts
@@ -27883,11 +28868,13 @@ var Transformer = class extends Disposable {
27883
28868
  });
27884
28869
  }
27885
28870
  _getOutlinePosition(width, height, borderSpacing, borderStrokeWidth) {
28871
+ const offset = borderSpacing + borderStrokeWidth;
28872
+ const strokeOffset = borderStrokeWidth / 2;
27886
28873
  return {
27887
- left: borderSpacing - borderStrokeWidth,
27888
- top: -borderSpacing - this.borderStrokeWidth,
27889
- width: width + borderSpacing * 2,
27890
- height: height + borderSpacing * 2
28874
+ left: -offset - strokeOffset,
28875
+ top: -offset - strokeOffset,
28876
+ width: width + offset * 2,
28877
+ height: height + offset * 2
27891
28878
  };
27892
28879
  }
27893
28880
  _getRotateAnchorCursor(type) {
@@ -27961,7 +28948,7 @@ var Transformer = class extends Disposable {
27961
28948
  top += -borderSpacing - borderStrokeWidth;
27962
28949
  break;
27963
28950
  case "__SpreadsheetTransformerResizeLM__":
27964
- left += borderSpacing - borderStrokeWidth;
28951
+ left += -borderSpacing - borderStrokeWidth;
27965
28952
  top += height / 2 - longEdge / 2;
27966
28953
  break;
27967
28954
  case "__SpreadsheetTransformerResizeRM__":
@@ -27969,7 +28956,7 @@ var Transformer = class extends Disposable {
27969
28956
  top += height / 2 - longEdge / 2;
27970
28957
  break;
27971
28958
  case "__SpreadsheetTransformerResizeLB__":
27972
- left += -this.borderSpacing - borderStrokeWidth;
28959
+ left += -borderSpacing - borderStrokeWidth;
27973
28960
  top += height + borderSpacing - borderStrokeWidth - longEdge;
27974
28961
  break;
27975
28962
  case "__SpreadsheetTransformerResizeCB__":
@@ -28009,28 +28996,28 @@ var Transformer = class extends Disposable {
28009
28996
  top += -borderSpacing - borderStrokeWidth;
28010
28997
  break;
28011
28998
  case "__SpreadsheetTransformerResizeRT__":
28012
- left += width + borderSpacing - borderStrokeWidth;
28999
+ left += width + borderSpacing + borderStrokeWidth;
28013
29000
  top += -borderSpacing - borderStrokeWidth;
28014
29001
  break;
28015
29002
  case "__SpreadsheetTransformerResizeLM__":
28016
- left += borderSpacing - borderStrokeWidth;
29003
+ left += -borderSpacing - borderStrokeWidth;
28017
29004
  top += height / 2;
28018
29005
  break;
28019
29006
  case "__SpreadsheetTransformerResizeRM__":
28020
- left += width + borderSpacing - borderStrokeWidth;
29007
+ left += width + borderSpacing + borderStrokeWidth;
28021
29008
  top += height / 2;
28022
29009
  break;
28023
29010
  case "__SpreadsheetTransformerResizeLB__":
28024
- left += -this.borderSpacing - borderStrokeWidth;
28025
- top += height + borderSpacing - borderStrokeWidth;
29011
+ left += -borderSpacing - borderStrokeWidth;
29012
+ top += height + borderSpacing + borderStrokeWidth;
28026
29013
  break;
28027
29014
  case "__SpreadsheetTransformerResizeCB__":
28028
29015
  left += width / 2;
28029
- top += height + borderSpacing - borderStrokeWidth;
29016
+ top += height + borderSpacing + borderStrokeWidth;
28030
29017
  break;
28031
29018
  case "__SpreadsheetTransformerResizeRB__":
28032
- left += width + borderSpacing - borderStrokeWidth;
28033
- top += height + borderSpacing - borderStrokeWidth;
29019
+ left += width + borderSpacing + borderStrokeWidth;
29020
+ top += height + borderSpacing + borderStrokeWidth;
28034
29021
  break;
28035
29022
  }
28036
29023
  return {
@@ -28069,8 +29056,8 @@ var Transformer = class extends Disposable {
28069
29056
  width: anchorProps.width,
28070
29057
  height: anchorProps.height,
28071
29058
  radius: anchorProps.radius,
28072
- left: left + (anchorSize - anchorProps.width) / 2,
28073
- top: top + (anchorSize - anchorProps.height) / 2,
29059
+ left: left + (anchorSize - anchorProps.width) / 2 - anchorStrokeWidth / 2,
29060
+ top: top + (anchorSize - anchorProps.height) / 2 - anchorStrokeWidth / 2,
28074
29061
  shadowColor: anchorShadowColor,
28075
29062
  shadowBlur: anchorShadowBlur,
28076
29063
  shadowOffsetX: anchorShadowOffsetX,
@@ -29384,14 +30371,17 @@ let RenderUnit = class RenderUnit extends Disposable {
29384
30371
  return this._renderContext.components;
29385
30372
  }
29386
30373
  constructor(init, parentInjector) {
29387
- var _init$createUnitOptio;
30374
+ var _init$createUnitOptio, _init$createUnitOptio2, _init$createUnitOptio3;
29388
30375
  super();
29389
30376
  _defineProperty(this, "isRenderUnit", true);
29390
30377
  _defineProperty(this, "_activated$", new BehaviorSubject(true));
29391
30378
  _defineProperty(this, "activated$", this._activated$.pipe(distinctUntilChanged()));
29392
30379
  _defineProperty(this, "_injector", void 0);
29393
30380
  _defineProperty(this, "_renderContext", void 0);
29394
- this._injector = parentInjector.createChild();
30381
+ _defineProperty(this, "_dependencyService", void 0);
30382
+ const renderParentInjector = (_init$createUnitOptio = (_init$createUnitOptio2 = init.createUnitOptions) === null || _init$createUnitOptio2 === void 0 ? void 0 : _init$createUnitOptio2.renderParentInjector) !== null && _init$createUnitOptio !== void 0 ? _init$createUnitOptio : parentInjector;
30383
+ this._injector = renderParentInjector.createChild();
30384
+ this._dependencyService = new RenderUnitDependencyService(this._injector, () => this._renderContext);
29395
30385
  this._renderContext = {
29396
30386
  unit: init.unit,
29397
30387
  unitId: init.unit.getUnitId(),
@@ -29405,13 +30395,14 @@ let RenderUnit = class RenderUnit extends Disposable {
29405
30395
  activate: () => this._activated$.next(true),
29406
30396
  deactivate: () => this._activated$.next(false)
29407
30397
  };
29408
- if (((_init$createUnitOptio = init.createUnitOptions) === null || _init$createUnitOptio === void 0 ? void 0 : _init$createUnitOptio.makeCurrent) === false) this.deactivate();
30398
+ if (((_init$createUnitOptio3 = init.createUnitOptions) === null || _init$createUnitOptio3 === void 0 ? void 0 : _init$createUnitOptio3.makeCurrent) === false) this.deactivate();
29409
30399
  }
29410
30400
  dispose() {
29411
- this._injector.dispose();
29412
- super.dispose();
30401
+ if (this._disposed) return;
29413
30402
  this._activated$.next(false);
29414
30403
  this._activated$.complete();
30404
+ super.dispose();
30405
+ this._injector.dispose();
29415
30406
  this._renderContext.unit = null;
29416
30407
  this._renderContext.components.clear();
29417
30408
  }
@@ -29422,7 +30413,10 @@ let RenderUnit = class RenderUnit extends Disposable {
29422
30413
  * Get a dependency from the RenderUnit's injector.
29423
30414
  */
29424
30415
  with(dependency) {
29425
- return this._injector.get(dependency);
30416
+ return this._dependencyService.resolve(dependency);
30417
+ }
30418
+ getInjector() {
30419
+ return this._injector;
29426
30420
  }
29427
30421
  /**
29428
30422
  * Add render dependencies to the RenderUnit's injector. Note that the dependencies would be initialized immediately
@@ -29432,16 +30426,8 @@ let RenderUnit = class RenderUnit extends Disposable {
29432
30426
  this._initDependencies(dependencies);
29433
30427
  }
29434
30428
  _initDependencies(dependencies) {
29435
- const j = this._injector;
29436
- dependencies.forEach((dep) => {
29437
- const [identifier, implOrNull] = Array.isArray(dep) ? dep : [dep, null];
29438
- if (!implOrNull) j.add([identifier, { useFactory: () => j.createInstance(identifier, this._renderContext) }]);
29439
- else if (isClassDependencyItem(implOrNull)) j.add([identifier, { useFactory: () => j.createInstance(implOrNull.useClass, this._renderContext) }]);
29440
- else throw new Error("[RenderUnit]: render dependency could only be an class!");
29441
- });
29442
- dependencies.forEach((dep) => {
29443
- const [identifier] = Array.isArray(dep) ? dep : [dep, null];
29444
- j.get(identifier);
30429
+ this._dependencyService.register(dependencies).forEach((record) => {
30430
+ this._dependencyService.resolveRecord(record);
29445
30431
  });
29446
30432
  }
29447
30433
  getRenderContext() {
@@ -29455,6 +30441,86 @@ let RenderUnit = class RenderUnit extends Disposable {
29455
30441
  }
29456
30442
  };
29457
30443
  RenderUnit = __decorate([__decorateParam(1, Inject(Injector))], RenderUnit);
30444
+ var RenderUnitDependencyService = class {
30445
+ constructor(_injector, _getRenderContext) {
30446
+ this._injector = _injector;
30447
+ this._getRenderContext = _getRenderContext;
30448
+ _defineProperty(this, "_records", /* @__PURE__ */ new Map());
30449
+ _defineProperty(this, "_resolved", /* @__PURE__ */ new Map());
30450
+ _defineProperty(this, "_resolving", /* @__PURE__ */ new Set());
30451
+ }
30452
+ register(dependencies) {
30453
+ const records = [];
30454
+ const seen = /* @__PURE__ */ new Set();
30455
+ dependencies.forEach((dependency) => {
30456
+ const parsed = this._parseDependency(dependency);
30457
+ const key = getRenderDependencyIdentifierKey$1(parsed.identifier);
30458
+ const existing = this._records.get(key);
30459
+ const record = existing !== null && existing !== void 0 ? existing : this._addRecord(key, parsed.identifier, parsed.create);
30460
+ if (seen.has(record.key)) return;
30461
+ seen.add(record.key);
30462
+ records.push(record);
30463
+ });
30464
+ return records;
30465
+ }
30466
+ resolve(dependency) {
30467
+ const key = getRenderDependencyIdentifierKey$1(dependency);
30468
+ if (this._resolved.has(key)) return this._resolved.get(key);
30469
+ if (this._resolving.has(key)) return;
30470
+ const record = this._records.get(key);
30471
+ if (record) return this.resolveRecord(record);
30472
+ return this._injector.get(dependency, LookUp.SELF);
30473
+ }
30474
+ resolveRecord(record) {
30475
+ if (this._resolved.has(record.key)) return this._resolved.get(record.key);
30476
+ if (this._resolving.has(record.key)) return;
30477
+ this._resolving.add(record.key);
30478
+ try {
30479
+ return this._injector.get(record.identifier, LookUp.SELF);
30480
+ } finally {
30481
+ this._resolving.delete(record.key);
30482
+ }
30483
+ }
30484
+ _addRecord(key, identifier, create) {
30485
+ const record = {
30486
+ key,
30487
+ identifier,
30488
+ create
30489
+ };
30490
+ this._records.set(key, record);
30491
+ this._injector.add([identifier, { useFactory: () => this._create(record) }]);
30492
+ return record;
30493
+ }
30494
+ _create(record) {
30495
+ if (this._resolved.has(record.key)) return this._resolved.get(record.key);
30496
+ const alreadyResolving = this._resolving.has(record.key);
30497
+ if (!alreadyResolving) this._resolving.add(record.key);
30498
+ try {
30499
+ const instance = record.create();
30500
+ this._resolved.set(record.key, instance);
30501
+ return instance;
30502
+ } finally {
30503
+ if (!alreadyResolving) this._resolving.delete(record.key);
30504
+ }
30505
+ }
30506
+ _parseDependency(dependency) {
30507
+ const [identifier, implOrNull] = Array.isArray(dependency) ? dependency : [dependency, null];
30508
+ if (!implOrNull) return {
30509
+ identifier,
30510
+ create: () => this._injector.createInstance(identifier, this._getRenderContext())
30511
+ };
30512
+ if (isClassDependencyItem(implOrNull)) return {
30513
+ identifier,
30514
+ create: () => this._injector.createInstance(implOrNull.useClass, this._getRenderContext())
30515
+ };
30516
+ throw new Error("[RenderUnit]: render dependency could only be an class!");
30517
+ }
30518
+ };
30519
+ function getRenderDependencyIdentifierKey$1(identifier) {
30520
+ const decoratorName = identifier === null || identifier === void 0 ? void 0 : identifier.decoratorName;
30521
+ if (typeof decoratorName === "string" && decoratorName) return `identifier:${decoratorName}`;
30522
+ return identifier;
30523
+ }
29458
30524
 
29459
30525
  //#endregion
29460
30526
  //#region src/render-manager/render-manager.service.ts
@@ -29495,10 +30561,11 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29495
30561
  registerRenderModules(type, deps) {
29496
30562
  if (!this._renderDependencies.has(type)) this._renderDependencies.set(type, []);
29497
30563
  const dependencies = this._renderDependencies.get(type);
29498
- dependencies.push(...deps);
29499
- for (const [_, render] of this._renderMap) if (render.type === type) this._tryAddRenderDependencies(render, deps);
30564
+ const registeredDeps = deps.filter((dep) => !hasRenderDependency(dependencies, dep));
30565
+ dependencies.push(...registeredDeps);
30566
+ for (const [_, render] of this._renderMap) if (render.type === type) this._tryAddRenderDependencies(render, registeredDeps);
29500
30567
  return toDisposable(() => {
29501
- deps.forEach((dep) => remove(dependencies, dep));
30568
+ registeredDeps.forEach((dep) => remove(dependencies, dep));
29502
30569
  });
29503
30570
  }
29504
30571
  /**
@@ -29509,6 +30576,7 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29509
30576
  registerRenderModule(type, depCtor) {
29510
30577
  if (!this._renderDependencies.has(type)) this._renderDependencies.set(type, []);
29511
30578
  const dependencies = this._renderDependencies.get(type);
30579
+ if (hasRenderDependency(dependencies, depCtor)) return toDisposable(() => {});
29512
30580
  dependencies.push(depCtor);
29513
30581
  for (const [_, render] of this._renderMap) if (render.type === type) this._tryAddRenderDependencies(render, [depCtor]);
29514
30582
  return toDisposable(() => remove(dependencies, depCtor));
@@ -29541,7 +30609,9 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29541
30609
  * @returns renderUnit:IRender
29542
30610
  */
29543
30611
  createRender(unitId, createUnitOptions) {
29544
- const renderer = this._createRender(unitId, this._injector.createInstance(Engine, unitId, void 0), true, createUnitOptions);
30612
+ var _createUnitOptions$re;
30613
+ const parentInjector = (_createUnitOptions$re = createUnitOptions === null || createUnitOptions === void 0 ? void 0 : createUnitOptions.renderParentInjector) !== null && _createUnitOptions$re !== void 0 ? _createUnitOptions$re : this._injector;
30614
+ const renderer = this._createRender(unitId, parentInjector.createInstance(Engine, unitId, void 0), (createUnitOptions === null || createUnitOptions === void 0 ? void 0 : createUnitOptions.embeddedRender) !== true, createUnitOptions, parentInjector);
29545
30615
  this._renderCreated$.next(renderer);
29546
30616
  return renderer;
29547
30617
  }
@@ -29565,7 +30635,7 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29565
30635
  * @param isMainScene
29566
30636
  * @returns renderUnit:IRender
29567
30637
  */
29568
- _createRender(unitId, engine, isMainScene = true, createUnitOptions) {
30638
+ _createRender(unitId, engine, isMainScene = true, createUnitOptions, parentInjector = this._injector) {
29569
30639
  const existItem = this.getRenderById(unitId);
29570
30640
  let shouldDestroyEngine = true;
29571
30641
  if (existItem != null) {
@@ -29582,7 +30652,7 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29582
30652
  if (unit) {
29583
30653
  const type = this._univerInstanceService.getUnitType(unitId);
29584
30654
  const ctorOfDeps = this._getRenderDepsByType(type);
29585
- renderUnit = this._injector.createInstance(RenderUnit, {
30655
+ renderUnit = parentInjector.createInstance(RenderUnit, {
29586
30656
  unit,
29587
30657
  engine,
29588
30658
  scene,
@@ -29590,7 +30660,16 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29590
30660
  createUnitOptions
29591
30661
  });
29592
30662
  this._addRenderUnit(unitId, renderUnit);
29593
- this._tryAddRenderDependencies(renderUnit, ctorOfDeps);
30663
+ try {
30664
+ this._tryAddRenderDependencies(renderUnit, ctorOfDeps);
30665
+ } catch (error) {
30666
+ try {
30667
+ this._disposeItem(renderUnit);
30668
+ } finally {
30669
+ this._renderMap.delete(unitId);
30670
+ }
30671
+ throw error;
30672
+ }
29594
30673
  } else {
29595
30674
  renderUnit = {
29596
30675
  isThumbNail: true,
@@ -29653,6 +30732,18 @@ RenderManagerService = __decorate([
29653
30732
  __decorateParam(1, IUniverInstanceService),
29654
30733
  __decorateParam(2, Inject(ThemeService))
29655
30734
  ], RenderManagerService);
30735
+ function hasRenderDependency(dependencies, dep) {
30736
+ const key = getRenderDependencyIdentifierKey(getRenderDependencyIdentifier(dep));
30737
+ return dependencies.some((registered) => getRenderDependencyIdentifierKey(getRenderDependencyIdentifier(registered)) === key);
30738
+ }
30739
+ function getRenderDependencyIdentifier(dep) {
30740
+ return Array.isArray(dep) ? dep[0] : dep;
30741
+ }
30742
+ function getRenderDependencyIdentifierKey(identifier) {
30743
+ const decoratorName = identifier.decoratorName;
30744
+ if (typeof decoratorName === "string" && decoratorName) return `identifier:${decoratorName}`;
30745
+ return identifier;
30746
+ }
29656
30747
  const IRenderManagerService = createIdentifier("engine-render.render-manager.service");
29657
30748
  function isDisposable(thing) {
29658
30749
  return !!thing && typeof thing.dispose === "function";
@@ -30081,13 +31172,13 @@ var Viewport = class {
30081
31172
  * @param delta
30082
31173
  * @returns isLimited
30083
31174
  */
30084
- scrollByBarDeltaValue(delta, isTrigger = true) {
31175
+ scrollByBarDeltaValue(delta, isTrigger = true, options) {
30085
31176
  const x = this.scrollX + (delta.x || 0);
30086
31177
  const y = this.scrollY + (delta.y || 0);
30087
31178
  return this._scrollToBarPosCore({
30088
31179
  x,
30089
31180
  y
30090
- }, isTrigger);
31181
+ }, isTrigger, options);
30091
31182
  }
30092
31183
  /**
30093
31184
  * Viewport scroll to certain position.
@@ -30625,7 +31716,7 @@ var Viewport = class {
30625
31716
  * @param rawScrollXY Partial<IViewportScrollPosition>
30626
31717
  * @param isTrigger
30627
31718
  */
30628
- _scrollToBarPosCore(rawScrollXY, isTrigger = true) {
31719
+ _scrollToBarPosCore(rawScrollXY, isTrigger = true, options) {
30629
31720
  var _this$_scrollBar6, _this$_scrollBar7, _this$_scrollBar8, _this$_scrollBar9, _this$_scrollBar10;
30630
31721
  if (this._scrollBar == null) return;
30631
31722
  let scrollX = rawScrollXY.x;
@@ -30646,7 +31737,9 @@ var Viewport = class {
30646
31737
  rawScrollY: rawScrollXY.y,
30647
31738
  limitX: (_this$_scrollBar6 = this._scrollBar) === null || _this$_scrollBar6 === void 0 ? void 0 : _this$_scrollBar6.limitX,
30648
31739
  limitY: (_this$_scrollBar7 = this._scrollBar) === null || _this$_scrollBar7 === void 0 ? void 0 : _this$_scrollBar7.limitY,
30649
- isTrigger
31740
+ isTrigger,
31741
+ isBarDragging: options === null || options === void 0 ? void 0 : options.isBarDragging,
31742
+ isBarDragEnd: options === null || options === void 0 ? void 0 : options.isBarDragEnd
30650
31743
  };
30651
31744
  (_this$_scrollBar8 = this._scrollBar) === null || _this$_scrollBar8 === void 0 || _this$_scrollBar8.makeDirty(true);
30652
31745
  this.onScrollAfter$.emitEvent(scrollSubParam);
@@ -30659,7 +31752,9 @@ var Viewport = class {
30659
31752
  viewportScrollY: this.viewportScrollY,
30660
31753
  limitX: (_this$_scrollBar9 = this._scrollBar) === null || _this$_scrollBar9 === void 0 ? void 0 : _this$_scrollBar9.limitX,
30661
31754
  limitY: (_this$_scrollBar10 = this._scrollBar) === null || _this$_scrollBar10 === void 0 ? void 0 : _this$_scrollBar10.limitY,
30662
- isTrigger
31755
+ isTrigger,
31756
+ isBarDragging: options === null || options === void 0 ? void 0 : options.isBarDragging,
31757
+ isBarDragEnd: options === null || options === void 0 ? void 0 : options.isBarDragEnd
30663
31758
  });
30664
31759
  return afterLimit;
30665
31760
  }
@@ -30775,13 +31870,11 @@ var Viewport = class {
30775
31870
  left: Math.max(prevBound.left, currBound.left),
30776
31871
  right: Math.min(prevBound.right, currBound.right)
30777
31872
  });
30778
- const expandX = this.bufferEdgeX;
30779
- const expandY = this.bufferEdgeY;
30780
31873
  for (const bound of additionalAreas) {
30781
- bound.left = bound.left - expandX;
30782
- bound.right = bound.right + expandX;
30783
- bound.top = bound.top - expandY;
30784
- bound.bottom = bound.bottom + expandY;
31874
+ bound.left = bound.left - this.bufferEdgeX;
31875
+ bound.right = bound.right + this.bufferEdgeX;
31876
+ bound.top = bound.top - this.bufferEdgeY;
31877
+ bound.bottom = bound.bottom + this.bufferEdgeY;
30785
31878
  }
30786
31879
  return additionalAreas;
30787
31880
  }
@@ -30808,4 +31901,4 @@ var Viewport = class {
30808
31901
  };
30809
31902
 
30810
31903
  //#endregion
30811
- 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 };
31904
+ 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, cjk, clampRange, clearLineByBorderType, compareDocumentSkeletonNestedPagePathOrder, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, createCanvasElement, createImageElement, degToRad, documentSkeletonLineIterator, documentSkeletonTableIterator, drawDiagonalLineByBorderType, drawLineByBorderType, expandRangeIfIntersects, fixLineWidthByScale, generateRandomKey, getCellByIndexWithMergeInfo, getCellPositionByIndex, getCharSpaceApply, getColor, getCurrentScrollXY, getCurrentTypeOfRenderer, getDPI, getDevicePixelRatio, getDocsCustomBlockRenderViewport, 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, 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, measureDocumentNoWrapTextRangeWidth, measureDocumentNoWrapTextWidth, measureDocumentUnbreakableTextWidth, mergeInfoOffset, parseDataStreamToTree, pixelToPt, precisionTo, ptToMM, ptToPixel, ptToPx, pxToInch, pxToNum, pxToPt, radToDeg, renderImageWatermark, renderTextWatermark, renderUserInfoWatermark, renderWatermark, requestNewFrame, setDocsCustomBlockRenderViewportProvider, setDocsTableRenderViewportProvider, setLineType, sheetContentViewportKeys, sheetHeaderViewportKeys, startWithEmoji, toPx, transformObjectOutOfGroup, withCurrentTypeOfRenderer };