@univerjs/engine-render 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (29) hide show
  1. package/lib/cjs/index.js +1446 -355
  2. package/lib/es/index.js +1440 -330
  3. package/lib/types/basics/cjk-regexp.d.ts +61 -0
  4. package/lib/types/basics/draw.d.ts +4 -4
  5. package/lib/types/basics/i-document-skeleton-cached.d.ts +10 -0
  6. package/lib/types/basics/index.d.ts +2 -0
  7. package/lib/types/basics/interfaces.d.ts +3 -1
  8. package/lib/types/basics/tools.d.ts +0 -3
  9. package/lib/types/components/docs/custom-block-render-viewport.d.ts +37 -0
  10. package/lib/types/components/docs/doc-component.d.ts +3 -0
  11. package/lib/types/components/docs/extensions/font-and-base-line.d.ts +1 -0
  12. package/lib/types/components/docs/layout/block/paragraph/layout-ruler.d.ts +3 -1
  13. package/lib/types/components/docs/layout/doc-no-wrap-measure.d.ts +35 -0
  14. package/lib/types/components/docs/layout/tools.d.ts +1 -0
  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 +4 -0
  20. package/lib/types/components/sheets/sheet.render-skeleton.d.ts +19 -11
  21. package/lib/types/drawing-group.d.ts +8 -0
  22. package/lib/types/index.d.ts +4 -0
  23. package/lib/types/render-manager/render-manager.service.d.ts +1 -1
  24. package/lib/types/render-manager/render-unit.d.ts +3 -0
  25. package/lib/types/shape/scroll-bar.d.ts +8 -0
  26. package/lib/types/shape/text.d.ts +4 -0
  27. package/lib/types/viewport.d.ts +7 -1
  28. package/lib/umd/index.js +5 -2
  29. 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";
@@ -299,7 +298,7 @@ function getFontStyleString(textStyle) {
299
298
  let bold = FontStyleType.BOLD;
300
299
  if (textStyle.bl === 0 || textStyle.bl === void 0) bold = FontStyleType.NORMAL;
301
300
  let originFontSize = defaultFontSize;
302
- if (textStyle.fs) originFontSize = Math.ceil(textStyle.fs);
301
+ if (textStyle.fs) originFontSize = textStyle.fs;
303
302
  let fontSize = originFontSize;
304
303
  const fontFamilyResult = normalizeFontFamily(textStyle.ff, defaultFont);
305
304
  const { va: baselineOffset } = textStyle;
@@ -323,18 +322,6 @@ function normalizeFontFamily(fontFamily, defaultFont) {
323
322
  return family.includes(" ") ? `"${family}"` : family;
324
323
  }).filter(Boolean).join(", ");
325
324
  }
326
- const CJK_LETTER_REG = cjk.letters().toRegExp();
327
- function hasCJKText(text) {
328
- return CJK_LETTER_REG.test(text);
329
- }
330
- const CJK_ALL_REG = cjk.all().toRegExp();
331
- function hasCJK(text) {
332
- return CJK_ALL_REG.test(text);
333
- }
334
- const CJK_PUNCTUATION_REG = cjk.punctuations().toRegExp();
335
- function hasCJKPunctuation(text) {
336
- return CJK_PUNCTUATION_REG.test(text);
337
- }
338
325
  function hasAllLatin(text) {
339
326
  if (!/[\u0000-\u024F]/gi.exec(text)) return false;
340
327
  return true;
@@ -923,6 +910,220 @@ _defineProperty(FontCache, "_context", void 0);
923
910
  _defineProperty(FontCache, "_fontDataMap", /* @__PURE__ */ new Map());
924
911
  _defineProperty(FontCache, "_globalFontMeasureCache", /* @__PURE__ */ new Map());
925
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
+
926
1127
  //#endregion
927
1128
  //#region src/basics/i-document-skeleton-cached.ts
928
1129
  let DocumentSkeletonPageType = /* @__PURE__ */ function(DocumentSkeletonPageType) {
@@ -4833,6 +5034,13 @@ var SheetExtension = class extends ComponentExtension {
4833
5034
  super(..._args);
4834
5035
  _defineProperty(this, "type", 0);
4835
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
+ }
4836
5044
  isRenderDiffRangesByCell(rangeP, diffRanges) {
4837
5045
  if (diffRanges == null || diffRanges.length === 0) return true;
4838
5046
  for (const range of diffRanges) {
@@ -4919,6 +5127,11 @@ const UNIQUE_KEY$10 = "DefaultBackgroundExtension";
4919
5127
  */
4920
5128
  const DOC_EXTENSION_Z_INDEX$3 = 21;
4921
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
+ }
4922
5135
  var Background = class extends SheetExtension {
4923
5136
  constructor(..._args) {
4924
5137
  super(..._args);
@@ -4930,7 +5143,7 @@ var Background = class extends SheetExtension {
4930
5143
  var _this$parent;
4931
5144
  return ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.isPrinting) ? this.PRINTING_Z_INDEX : this.Z_INDEX;
4932
5145
  }
4933
- draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges, { viewRanges, checkOutOfViewBound }) {
5146
+ draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges, { viewRanges, checkOutOfViewBound, hasMergeData = true }) {
4934
5147
  const { stylesCache, worksheet, rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;
4935
5148
  const { background: bgMatrixCacheByColor, backgroundPositions } = stylesCache;
4936
5149
  if (!worksheet || !bgMatrixCacheByColor) return;
@@ -4948,15 +5161,19 @@ var Background = class extends SheetExtension {
4948
5161
  spreadsheetSkeleton
4949
5162
  };
4950
5163
  const mergeRanges = [];
4951
- viewRanges.forEach((range) => {
5164
+ if (hasMergeData) viewRanges.forEach((range) => {
4952
5165
  const intersectMergeRangesInViewRanges = spreadsheetSkeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn);
4953
5166
  mergeRanges.push(...intersectMergeRangesInViewRanges);
4954
5167
  });
4955
5168
  const renderBGCore = (rgb) => {
4956
5169
  const bgColorMatrix = bgMatrixCacheByColor[rgb];
5170
+ const renderRanges = diffRanges && diffRanges.length > 0 ? diffRanges : viewRanges;
4957
5171
  const rangeForEachFn = (row, col, bgConfigParam) => {
4958
- if (spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(row, col) !== -1) return;
4959
- 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);
4960
5177
  if (!cellInfo) return;
4961
5178
  if (bgConfigParam || bgColorMatrix.getValue(row, col)) {
4962
5179
  renderBGContext.cellInfo = cellInfo;
@@ -4972,12 +5189,16 @@ var Background = class extends SheetExtension {
4972
5189
  renderBGContext.backgroundPaths = backgroundPaths;
4973
5190
  ctx.beginPath();
4974
5191
  const matrixSize = bgColorMatrix.getSizeOf();
4975
- if (viewRanges.reduce((sum, range) => {
4976
- return sum + (range.endRow - range.startRow) * (range.endColumn - range.startColumn);
4977
- }, 0) < matrixSize) viewRanges.forEach((range) => {
4978
- Range.foreach(range, rangeForEachFn);
4979
- });
4980
- 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
+ }
4981
5202
  ctx.fill(backgroundPaths);
4982
5203
  ctx.closePath();
4983
5204
  };
@@ -5006,12 +5227,12 @@ var Background = class extends SheetExtension {
5006
5227
  for (let index = 0; index < rgbList.length; index++) {
5007
5228
  const rgb = rgbList[index];
5008
5229
  renderBGCore(rgb);
5009
- renderBGForMergedCells(rgb);
5230
+ if (hasMergeData) renderBGForMergedCells(rgb);
5010
5231
  }
5011
5232
  ctx.restore();
5012
5233
  }
5013
5234
  renderBGByCell(bgContext, row, col) {
5014
- const { spreadsheetSkeleton, backgroundPaths, scaleX, scaleY, viewRanges, diffRanges, cellInfo } = bgContext;
5235
+ const { spreadsheetSkeleton, backgroundPaths, scaleX, scaleY, viewRanges, diffRanges, cellInfo, skipRenderRangeCheck } = bgContext;
5015
5236
  let { startY, endY, startX, endX } = cellInfo;
5016
5237
  const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
5017
5238
  const renderRange = diffRanges && diffRanges.length > 0 ? diffRanges : viewRanges;
@@ -5019,7 +5240,7 @@ var Background = class extends SheetExtension {
5019
5240
  endY = mergeInfo.endY;
5020
5241
  startX = mergeInfo.startX;
5021
5242
  endX = mergeInfo.endX;
5022
- if (!isMerged && !isMergedMainCell && !inViewRanges(renderRange, row, col)) return true;
5243
+ if (!skipRenderRangeCheck && !isMerged && !isMergedMainCell && !inViewRanges(renderRange, row, col)) return true;
5023
5244
  if (!isMerged && !isMergedMainCell) {
5024
5245
  if (!spreadsheetSkeleton.worksheet.getRowVisible(row)) return true;
5025
5246
  if (!spreadsheetSkeleton.worksheet.getColVisible(col)) return true;
@@ -11787,11 +12008,12 @@ var Text = class Text extends Shape {
11787
12008
  this.skeleton = new DocSimpleSkeleton(props.text, props.fontStyle, Boolean(props.warp), props.width, props.height);
11788
12009
  }
11789
12010
  static drawWith(ctx, props, _skeleton) {
11790
- var _props$color;
12011
+ var _cachedLayout$lines, _cachedLayout$totalHe, _props$color;
11791
12012
  const { text, fontStyle, warp, hAlign, vAlign, width, height, left = 0, top = 0, cellValueType } = props;
11792
- const skeleton = _skeleton !== null && _skeleton !== void 0 ? _skeleton : new DocSimpleSkeleton(text, fontStyle, Boolean(warp), width, vAlign === VerticalAlign.TOP ? height : Infinity);
11793
- const lines = skeleton.calculate();
11794
- 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();
11795
12017
  let lineTop = top + (vAlign === VerticalAlign.TOP ? 0 : vAlign === VerticalAlign.MIDDLE ? (height - totalHeight) / 2 : height - totalHeight);
11796
12018
  ctx.save();
11797
12019
  ctx.font = fontStyle;
@@ -11842,6 +12064,46 @@ var Text = class Text extends Shape {
11842
12064
  ctx.restore();
11843
12065
  return totalHeight;
11844
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
+ }
11845
12107
  /**
11846
12108
  * Draw text decoration lines (underline, strikethrough, etc.)
11847
12109
  */
@@ -11974,6 +12236,8 @@ var Text = class Text extends Shape {
11974
12236
  };
11975
12237
  }
11976
12238
  };
12239
+ _defineProperty(Text, "_MAX_LAYOUT_CACHE_SIZE", 5e3);
12240
+ _defineProperty(Text, "_layoutCache", /* @__PURE__ */ new Map());
11977
12241
 
11978
12242
  //#endregion
11979
12243
  //#region src/components/docs/document-compatibility.ts
@@ -12689,6 +12953,34 @@ var DocumentViewModel = class DocumentViewModel {
12689
12953
  }
12690
12954
  };
12691
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
+
12692
12984
  //#endregion
12693
12985
  //#region src/components/docs/layout/model/glyph.ts
12694
12986
  function isSpace(char) {
@@ -12699,7 +12991,7 @@ function isSpace(char) {
12699
12991
  ].includes(char);
12700
12992
  }
12701
12993
  function isJustifiable(content) {
12702
- return isSpace(content) || hasCJKText(content) || isCjkLeftAlignedPunctuation(content) || isCjkRightAlignedPunctuation(content) || isCjkCenterAlignedPunctuation(content);
12994
+ return isSpace(content) || cjk.hasCJKText(content) || isCjkLeftAlignedPunctuation(content) || isCjkRightAlignedPunctuation(content) || isCjkCenterAlignedPunctuation(content);
12703
12995
  }
12704
12996
  function baseAdjustability(content, width) {
12705
12997
  if (isSpace(content)) return {
@@ -12828,7 +13120,7 @@ function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, gly
12828
13120
  const { width: contentWidth = 0 } = bBox;
12829
13121
  let width = glyphWidth !== null && glyphWidth !== void 0 ? glyphWidth : contentWidth;
12830
13122
  if (validationGrid(gridType, snapToGrid)) {
12831
- width = contentWidth + (hasCJK(content) ? charSpace : charSpace / 2);
13123
+ width = contentWidth + (cjk.hasCJK(content) ? charSpace : charSpace / 2);
12832
13124
  if (gridType === GridType.SNAP_TO_CHARS) xOffset = (width - contentWidth) / 2;
12833
13125
  }
12834
13126
  if (glyphInfo && glyphInfo.kerning !== 0 && glyphInfo.font) {
@@ -13724,6 +14016,12 @@ function isBeyondDivideWidth(width, divideWidth) {
13724
14016
  const tolerance = Math.min(MAX_LINE_WIDTH_TOLERANCE, Math.max(MIN_LINE_WIDTH_TOLERANCE, divideWidth * RELATIVE_LINE_WIDTH_TOLERANCE));
13725
14017
  return width - divideWidth > tolerance;
13726
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
+ }
13727
14025
  function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal") {
13728
14026
  if (isParagraphFirstShapedText) if (paragraphConfig.bulletSkeleton) {
13729
14027
  var _paragraphProperties$;
@@ -13800,12 +14098,11 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13800
14098
  const divideInfo = getLastNotFullDivideInfo(getLastPage(pages));
13801
14099
  if (divideInfo) {
13802
14100
  var _divide$glyphGroup;
13803
- const width = __getGlyphGroupWidth(glyphGroup);
13804
14101
  const { divide, isLast } = divideInfo;
13805
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];
13806
14103
  const preOffsetLeft = ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.width) || 0) + ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.left) || 0);
13807
14104
  const { hyphenationZone } = sectionBreakConfig;
13808
- if (isBeyondDivideWidth(preOffsetLeft + width, divide.width)) {
14105
+ if (isGlyphGroupBeyondDivideWidth(glyphGroup, preOffsetLeft, divide.width)) {
13809
14106
  if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0 && glyphGroup.length > 0 && glyphGroup[0].streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) {
13810
14107
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13811
14108
  updateDivideInfo(divide, { breakType: breakPointType });
@@ -13828,7 +14125,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13828
14125
  const sliceGlyphGroup = [];
13829
14126
  while (glyphGroup.length) {
13830
14127
  sliceGlyphGroup.push(glyphGroup.shift());
13831
- if (isBeyondDivideWidth(__getGlyphGroupWidth(sliceGlyphGroup), divide.width)) {
14128
+ if (isGlyphGroupBeyondDivideWidth(sliceGlyphGroup, 0, divide.width)) {
13832
14129
  if (sliceGlyphGroup.length > 1) glyphGroup.unshift(sliceGlyphGroup.pop());
13833
14130
  break;
13834
14131
  }
@@ -13879,7 +14176,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13879
14176
  if (anchorDrawings.length > 0) {
13880
14177
  var _paragraphConfig$para, _paragraphConfig$pDra;
13881
14178
  const paragraphAnchorLeft = __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, (_paragraphConfig$para = paragraphConfig.paragraphStyle) === null || _paragraphConfig$para === void 0 ? void 0 : _paragraphConfig$para.indentStart);
13882
- const drawings = __getDrawingPosition(currentLine.top, currentLine.lineHeight, currentLine.parent, true, (_paragraphConfig$pDra = paragraphConfig.pDrawingAnchor) === null || _paragraphConfig$pDra === void 0 || (_paragraphConfig$pDra = _paragraphConfig$pDra.get(paragraphConfig.paragraphIndex)) === null || _paragraphConfig$pDra === void 0 ? void 0 : _paragraphConfig$pDra.top, anchorDrawings, paragraphAnchorLeft);
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);
13883
14180
  __updateDrawingPosition(currentLine.parent, drawings);
13884
14181
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13885
14182
  updateDivideInfo(divide, { breakType: breakPointType });
@@ -13979,6 +14276,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13979
14276
  }
13980
14277
  }
13981
14278
  let deferredInlineGroupAnchorDrawings = [];
14279
+ let deferredTopBottomAnchorDrawings = [];
13982
14280
  if (paragraphNonInlineSkeDrawings != null && paragraphNonInlineSkeDrawings.size > 0) {
13983
14281
  var _pDrawingAnchor$get;
13984
14282
  let targetDrawings = [...paragraphNonInlineSkeDrawings.values()].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom !== ObjectRelativeFromV.LINE);
@@ -13986,13 +14284,17 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13986
14284
  deferredInlineGroupAnchorDrawings = targetDrawings.filter((drawing) => glyphGroupCustomBlockIds.has(drawing.drawingId) && drawing.drawingOrigin.docTransform.positionV.relativeFrom === ObjectRelativeFromV.LINE);
13987
14285
  targetDrawings = targetDrawings.filter((drawing) => !deferredInlineGroupAnchorDrawings.includes(drawing));
13988
14286
  }
13989
- __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);
13990
14290
  }
13991
14291
  if (skeTablesInParagraph != null && skeTablesInParagraph.length > 0) {
13992
14292
  var _pDrawingAnchor$get2;
13993
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);
13994
14294
  }
13995
- 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);
13996
14298
  if (lineHeight + newLineTop - section.height > LINE_LAYOUT_OVERFLOW_TOLERANCE && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
13997
14299
  setColumnFullState(column, true);
13998
14300
  _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
@@ -14026,16 +14328,21 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
14026
14328
  }, column.width, lineIndex, isParagraphFirstShapedText, paragraphConfig, lastPage, headerPage, footerPage);
14027
14329
  column.lines.push(newLine);
14028
14330
  newLine.parent = column;
14029
- 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
+ }
14030
14337
  _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
14031
14338
  if (deferredInlineGroupAnchorDrawings.length > 0) {
14032
14339
  var _pDrawingAnchor$get3;
14033
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);
14034
14341
  }
14035
14342
  }
14036
- 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) {
14037
14344
  if (targetDrawings.length === 0) return;
14038
- const drawings = __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
14345
+ const drawings = __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
14039
14346
  if (drawings == null || drawings.size === 0) return;
14040
14347
  const floatObjects = [...drawings.values()].filter((drawing) => {
14041
14348
  const layoutType = drawing.drawingOrigin.layoutType;
@@ -14057,7 +14364,7 @@ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDra
14057
14364
  };
14058
14365
  });
14059
14366
  if (!skipRelayoutCheck) _reLayoutCheck(ctx, floatObjects, column, paragraphIndex);
14060
- __updateDrawingPosition(column, drawings);
14367
+ __updateDrawingPosition(column, drawings, overwriteTopBottomPosition);
14061
14368
  }
14062
14369
  function __updateWrapTablePosition(ctx, table, lineTop, lineHeight, column, paragraphIndex, drawingAnchorTop) {
14063
14370
  const wrapTablePosition = __getWrapTablePosition(table, column, lineTop, lineHeight, drawingAnchorTop);
@@ -14168,6 +14475,15 @@ function _getCustomBlockIdsInLine(line) {
14168
14475
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) customBlockIds.push(glyph.drawingId);
14169
14476
  return customBlockIds;
14170
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
+ }
14171
14487
  function __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings) {
14172
14488
  return __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings).length > 0;
14173
14489
  }
@@ -14371,7 +14687,8 @@ function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitc
14371
14687
  }
14372
14688
  const usesDocumentGrid = spacingRule === SpacingRule.AUTO && snapToGrid === BooleanNumber.TRUE && gridType !== GridType.DEFAULT;
14373
14689
  if (spacingRule === SpacingRule.AUTO) {
14374
- 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;
14375
14692
  const padding = (lineSpacingApply - glyphLineHeight) / 2;
14376
14693
  return {
14377
14694
  paddingTop: padding,
@@ -14399,7 +14716,7 @@ function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitc
14399
14716
  lineSpacingApply: exactLineSpacingApply
14400
14717
  };
14401
14718
  }
14402
- function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnchorTop, paragraphNonInlineSkeDrawings) {
14719
+ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId = "", blockAnchorTop, paragraphNonInlineSkeDrawings) {
14403
14720
  var _line$parent, _section$top;
14404
14721
  const column = line.parent;
14405
14722
  const section = column === null || column === void 0 ? void 0 : column.parent;
@@ -14411,6 +14728,7 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14411
14728
  const sectionTop = (_section$top = section === null || section === void 0 ? void 0 : section.top) !== null && _section$top !== void 0 ? _section$top : 0;
14412
14729
  const lineTop = sectionTop + top;
14413
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;
14414
14732
  const { drawingId } = glyph;
14415
14733
  if (drawingId == null) continue;
14416
14734
  const drawing = paragraphInlineSkeDrawings === null || paragraphInlineSkeDrawings === void 0 ? void 0 : paragraphInlineSkeDrawings.get(drawingId);
@@ -14420,7 +14738,19 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14420
14738
  const { size, angle } = docTransform;
14421
14739
  const { width = 0, height = 0 } = size;
14422
14740
  const glyphHeight = glyph.bBox.bd + glyph.bBox.ba;
14423
- 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;
14424
14754
  if (glyph.width > divide.width) {
14425
14755
  var _paragraphNonInlineSk;
14426
14756
  for (const positionedDrawing of (_paragraphNonInlineSk = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.values()) !== null && _paragraphNonInlineSk !== void 0 ? _paragraphNonInlineSk : []) {
@@ -14430,17 +14760,25 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14430
14760
  const lineBottom = lineTop + lineHeight;
14431
14761
  if (positionedDrawing.aTop >= lineBottom || positionedBottom <= lineTop) continue;
14432
14762
  const positionedRight = positionedDrawing.aLeft + positionedDrawing.width;
14433
- const drawingRight = drawing.aLeft + width;
14763
+ const drawingRight = drawing.aLeft + drawingWidth;
14434
14764
  if (positionedDrawing.aLeft < drawingRight && positionedRight > drawing.aLeft) {
14435
14765
  var _positionedOrigin$dis;
14436
14766
  drawing.aLeft = Math.max(drawing.aLeft, positionedDrawing.aLeft + positionedDrawing.width + ((_positionedOrigin$dis = positionedOrigin.distR) !== null && _positionedOrigin$dis !== void 0 ? _positionedOrigin$dis : 0));
14437
14767
  }
14438
14768
  }
14439
14769
  }
14440
- drawing.aTop = lineTop + lineHeight - .5 * glyphHeight - .5 * height - marginBottom;
14441
- drawing.width = width;
14442
- drawing.height = height;
14770
+ drawing.width = drawingWidth;
14771
+ drawing.height = drawingHeight;
14772
+ drawing.aTop = lineTop + lineHeight - .5 * glyphHeight - .5 * drawingHeight - marginBottom;
14443
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;
14444
14782
  drawing.isPageBreak = isPageBreak;
14445
14783
  drawing.lineTop = lineTop;
14446
14784
  drawing.columnLeft = column.left;
@@ -14450,7 +14788,7 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14450
14788
  }
14451
14789
  page.skeDrawings = new Map([...page.skeDrawings, ...drawings]);
14452
14790
  }
14453
- function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = [], blockAnchorLeft = 0) {
14791
+ function __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = [], blockAnchorLeft = 0, normalizeTraditionalColumnAnchor = true) {
14454
14792
  var _column$parent3;
14455
14793
  const page = (_column$parent3 = column.parent) === null || _column$parent3 === void 0 ? void 0 : _column$parent3.parent;
14456
14794
  if (page == null || needPositionDrawings.length === 0) return;
@@ -14458,22 +14796,42 @@ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShape
14458
14796
  const isPageBreak = __checkPageBreak(column);
14459
14797
  if (isPageBreak && !isParagraphFirstShapedText) return;
14460
14798
  for (const drawing of needPositionDrawings) {
14461
- var _getPositionHorizon2, _getPositionVertical2;
14799
+ var _ctx$dataModel$getUni, _ctx$dataModel$getUni2, _ctx$dataModel, _viewport$width2, _viewport$height2, _getPositionHorizon2, _getPositionVertical2;
14462
14800
  const { drawingOrigin } = drawing;
14463
14801
  if (!drawingOrigin) continue;
14464
14802
  const { docTransform } = drawingOrigin;
14465
14803
  const { positionH, positionV, size, angle } = docTransform;
14466
- const { width = 0, height = 0 } = size;
14467
- 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;
14468
14817
  if (positionH.relativeFrom === ObjectRelativeFromH.COLUMN && blockAnchorLeft > 0) {
14469
14818
  const renderedColumnOrigin = isPageBreak ? 0 : column.left || page.marginLeft;
14470
14819
  aLeft += blockAnchorLeft - renderedColumnOrigin;
14820
+ if (normalizeTraditionalColumnAnchor && ctx.dataModel.documentStyle.documentFlavor === DocumentFlavor.TRADITIONAL && positionV.relativeFrom === ObjectRelativeFromV.PARAGRAPH) aLeft -= page.marginLeft;
14471
14821
  }
14472
14822
  drawing.aLeft = aLeft;
14473
- drawing.aTop = (_getPositionVertical2 = getPositionVertical(positionV, page, lineTop, lineHeight, height, blockAnchorTop, isPageBreak)) !== null && _getPositionVertical2 !== void 0 ? _getPositionVertical2 : 0;
14474
- drawing.width = width;
14475
- 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;
14476
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;
14477
14835
  drawing.initialState = true;
14478
14836
  drawing.columnLeft = column.left;
14479
14837
  drawing.lineTop = lineTop;
@@ -14484,16 +14842,18 @@ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShape
14484
14842
  }
14485
14843
  return drawings;
14486
14844
  }
14487
- function __updateDrawingPosition(column, drawings) {
14845
+ function __updateDrawingPosition(column, drawings, overwriteTopBottomPosition = false) {
14488
14846
  var _column$parent4;
14489
14847
  const page = (_column$parent4 = column.parent) === null || _column$parent4 === void 0 ? void 0 : _column$parent4.parent;
14490
14848
  if (drawings == null || drawings.size === 0 || page == null) return;
14491
14849
  for (const drawing of drawings.values()) {
14492
14850
  const originDrawing = page.skeDrawings.get(drawing.drawingId);
14493
- 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 {
14494
14853
  const lowerDrawing = originDrawing.aTop > drawing.aTop ? originDrawing : drawing;
14495
14854
  page.skeDrawings.set(drawing.drawingId, lowerDrawing);
14496
- } else page.skeDrawings.set(drawing.drawingId, drawing);
14855
+ }
14856
+ else page.skeDrawings.set(drawing.drawingId, drawing);
14497
14857
  else page.skeDrawings.set(drawing.drawingId, drawing);
14498
14858
  }
14499
14859
  }
@@ -14822,7 +15182,10 @@ function updateInlineDrawingCoordsAndBorder(ctx, pages) {
14822
15182
  const affectInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphInlineSkeDrawings;
14823
15183
  const affectNonInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphNonInlineSkeDrawings;
14824
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);
14825
- 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
+ }
14826
15189
  const paragraphStyle = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphStyle;
14827
15190
  const paragraphBackgroundColor = paragraphStyle === null || paragraphStyle === void 0 || (_paragraphStyle$shadi = paragraphStyle.shading) === null || _paragraphStyle$shadi === void 0 ? void 0 : _paragraphStyle$shadi.backgroundColor;
14828
15191
  if (paragraphBackgroundColor) line.backgroundColor = paragraphBackgroundColor;
@@ -15317,6 +15680,12 @@ function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig
15317
15680
  if (!hasAddonStyle && originTextRun) fontCreateConfigCache.setValue(st, ed, result);
15318
15681
  return result;
15319
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
+ }
15320
15689
  function getNullSkeleton() {
15321
15690
  return {
15322
15691
  pages: [],
@@ -15333,6 +15702,7 @@ function setPageParent(pages, parent) {
15333
15702
  for (const page of pages) page.parent = parent;
15334
15703
  }
15335
15704
  const DEFAULT_SECTION_BREAK = {
15705
+ sectionId: "section_render_default",
15336
15706
  columnProperties: [],
15337
15707
  columnSeparatorType: ColumnSeparatorType.NONE,
15338
15708
  sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,
@@ -15380,6 +15750,11 @@ function prepareSectionBreakConfig(ctx, nodeIndex) {
15380
15750
  let { documentStyle } = dataModel;
15381
15751
  const { documentFlavor } = documentStyle;
15382
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
+ };
15383
15758
  if (documentFlavor === DocumentFlavor.MODERN) {
15384
15759
  var _documentStyle$pageSi, _documentStyle$pageSi2;
15385
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;
@@ -15396,7 +15771,7 @@ function prepareSectionBreakConfig(ctx, nodeIndex) {
15396
15771
  vertexAngle: 0,
15397
15772
  wrapStrategy: WrapStrategy.UNSPECIFIED
15398
15773
  } } = documentStyle;
15399
- 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;
15400
15775
  const sectionNodeNext = viewModel.getChildren()[nodeIndex + 1];
15401
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;
15402
15777
  const headerIds = {
@@ -15412,6 +15787,7 @@ function prepareSectionBreakConfig(ctx, nodeIndex) {
15412
15787
  if (pageSize.width === null) pageSize.width = Number.POSITIVE_INFINITY;
15413
15788
  if (pageSize.height === null) pageSize.height = Number.POSITIVE_INFINITY;
15414
15789
  return {
15790
+ sectionId,
15415
15791
  charSpace,
15416
15792
  linePitch,
15417
15793
  gridType,
@@ -15484,13 +15860,14 @@ function getHeaderFooterMaxHeight(pageHeight) {
15484
15860
  }
15485
15861
  function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, pageNumber = 1, breakType = 0) {
15486
15862
  const page = _getNullPage();
15487
- const { pageNumberStart = 1, pageSize = {
15863
+ const { sectionId, pageNumberStart = 1, pageSize = {
15488
15864
  width: Number.POSITIVE_INFINITY,
15489
15865
  height: Number.POSITIVE_INFINITY
15490
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;
15491
15867
  const { skeHeaders, skeFooters } = skeletonResourceReference;
15492
15868
  const { width: pageWidth = Number.POSITIVE_INFINITY, height: pageHeight = Number.POSITIVE_INFINITY } = pageSize;
15493
15869
  page.pageNumber = pageNumber;
15870
+ page.sectionId = sectionId;
15494
15871
  page.pageNumberStart = pageNumberStart;
15495
15872
  page.renderConfig = renderConfig;
15496
15873
  page.marginLeft = marginLeft;
@@ -15585,10 +15962,11 @@ function _getNullPage(type = 0, segmentId = "") {
15585
15962
  }
15586
15963
  function _createSkeletonHeaderFooter(ctx, headerOrFooterViewModel, sectionBreakConfig, skeletonResourceReference, segmentId, isHeader = true, areaPage, count = 0) {
15587
15964
  var _sectionBreakConfig$d;
15588
- 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;
15589
15966
  const pageWidth = (pageSize === null || pageSize === void 0 ? void 0 : pageSize.width) || Number.POSITIVE_INFINITY;
15590
15967
  const pageHeight = (pageSize === null || pageSize === void 0 ? void 0 : pageSize.height) || Number.POSITIVE_INFINITY;
15591
15968
  const headerFooterConfig = {
15969
+ sectionId,
15592
15970
  lists,
15593
15971
  footerTreeMap,
15594
15972
  headerTreeMap,
@@ -15625,7 +16003,7 @@ function _createSkeletonHeaderFooter(ctx, headerOrFooterViewModel, sectionBreakC
15625
16003
  }
15626
16004
  function createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY) {
15627
16005
  var _ref, _cellConfig$margin, _cellConfig$columnSpa;
15628
- const { lists, footerTreeMap, headerTreeMap, localeService, drawings } = sectionBreakConfig;
16006
+ const { sectionId, lists, footerTreeMap, headerTreeMap, localeService, drawings } = sectionBreakConfig;
15629
16007
  const { skeletonResourceReference } = ctx;
15630
16008
  const { cellMargin, tableRows, tableColumns, tableId } = tableConfig;
15631
16009
  const cellConfig = tableRows[row].tableCells[col];
@@ -15647,6 +16025,7 @@ function createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, avai
15647
16025
  }
15648
16026
  const pageHeight = maxCellPageHeight;
15649
16027
  const cellSectionBreakConfig = {
16028
+ sectionId,
15650
16029
  lists,
15651
16030
  footerTreeMap,
15652
16031
  headerTreeMap,
@@ -15807,7 +16186,7 @@ function getDivideStretchability(divide) {
15807
16186
  function getJustifiables(divide) {
15808
16187
  const justifiables = divide.glyphGroup.filter((glyph) => glyph.isJustifiable).length;
15809
16188
  const lastGlyph = divide.glyphGroup[divide.glyphGroup.length - 1];
15810
- if (hasCJK(lastGlyph.content)) return justifiables - 1;
16189
+ if (cjk.hasCJK(lastGlyph.content)) return justifiables - 1;
15811
16190
  return justifiables;
15812
16191
  }
15813
16192
  function adjustGlyphsInDivide(divide, justificationRatio, extraJustification) {
@@ -15912,7 +16291,7 @@ function horizontalAlignHandler(line, horizontalAlign, allowOverflowHorizontalOf
15912
16291
  function restoreLastCJKGlyphWidth(line) {
15913
16292
  for (const divide of line.divides) {
15914
16293
  const lastGlyph = divide.glyphGroup[divide.glyphGroup.length - 1];
15915
- 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) {
15916
16295
  const shrinkAmount = lastGlyph.width - lastGlyph.xOffset - lastGlyph.bBox.width;
15917
16296
  lastGlyph.width -= shrinkAmount;
15918
16297
  lastGlyph.adjustability.shrinkability[1] = 0;
@@ -16185,22 +16564,66 @@ function _isDocxColumnBreakVisuallyBlankColumn(column) {
16185
16564
  function _hasOnlyCustomBlockGlyphs(glyphs) {
16186
16565
  return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK);
16187
16566
  }
16188
- function _mergeAdjacentCustomBlockShapedTexts(shapedTextList) {
16567
+ function _mergeAdjacentCustomBlockShapedTexts(shapedTextList, customBlockDrawings) {
16189
16568
  const mergedShapedTextList = [];
16190
- for (const shapedText of shapedTextList) {
16191
- const lastShapedText = mergedShapedTextList[mergedShapedTextList.length - 1];
16192
- if (lastShapedText && _hasOnlyCustomBlockGlyphs(lastShapedText.glyphs) && _hasOnlyCustomBlockGlyphs(shapedText.glyphs)) {
16193
- lastShapedText.text += shapedText.text;
16194
- lastShapedText.glyphs.push(...shapedText.glyphs);
16195
- lastShapedText.breakPointType = shapedText.breakPointType;
16196
- 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
+ });
16197
16583
  }
16198
- 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({
16199
16595
  ...shapedText,
16200
- glyphs: [...shapedText.glyphs]
16596
+ text: pendingText,
16597
+ glyphs: pendingGlyphs
16201
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;
16202
16616
  }
16203
- 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;
16204
16627
  }
16205
16628
  function _getListLevelAncestors(bullet, listLevel) {
16206
16629
  if (!bullet || !listLevel) return;
@@ -16246,26 +16669,17 @@ function _hasNextAdjacentLayoutBlockRange(blockRanges, blockRange) {
16246
16669
  const nextBlockRange = _getNextAdjacentBlockRange(blockRanges, blockRange);
16247
16670
  return nextBlockRange != null && BLOCK_LAYOUT_OUTER_SPACING_MAP.has(nextBlockRange.blockType) && nextBlockRange.startIndex === blockRange.endIndex + 1;
16248
16671
  }
16249
- function _applyDefaultLayoutParagraphStyle(style, hasBlockRange) {
16250
- if (style.lineSpacing == null) style.lineSpacing = DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING;
16251
- if (hasBlockRange) return;
16252
- if (style.spaceAbove == null) style.spaceAbove = { v: DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE };
16253
- if (style.spaceBelow == null) style.spaceBelow = { v: DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW };
16254
- }
16255
- function _applyBlockRangeLayoutParagraphStyle(body, paragraph, paragraphStyle, shouldApplyDocumentDefaults) {
16672
+ function _applyBlockRangeLayoutParagraphStyle(body, paragraph, paragraphStyle, documentStyle, useLegacyModernDefaults) {
16256
16673
  var _body$paragraphs, _BLOCK_LAYOUT_OUTER_S;
16257
- const style = Tools.deepClone(paragraphStyle);
16258
16674
  const blockRanges = body === null || body === void 0 ? void 0 : body.blockRanges;
16259
- if (!(blockRanges === null || blockRanges === void 0 ? void 0 : blockRanges.length)) {
16260
- if (shouldApplyDocumentDefaults) _applyDefaultLayoutParagraphStyle(style, false);
16261
- return style;
16262
- }
16675
+ if (!(blockRanges === null || blockRanges === void 0 ? void 0 : blockRanges.length)) return resolveDocumentParagraphStyle(documentStyle, paragraphStyle, { useLegacyModernDefaults });
16263
16676
  const blockRange = blockRanges.find((range) => BLOCK_LAYOUT_OUTER_SPACING_MAP.has(range.blockType) && paragraph.startIndex > range.startIndex && paragraph.startIndex < range.endIndex);
16264
- if (!blockRange) {
16265
- if (shouldApplyDocumentDefaults) _applyDefaultLayoutParagraphStyle(style, false);
16266
- return style;
16267
- }
16268
- _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;
16269
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);
16270
16684
  const firstParagraph = blockParagraphs[0];
16271
16685
  const lastParagraph = blockParagraphs[blockParagraphs.length - 1];
@@ -16314,7 +16728,7 @@ function _getNextPageNumber(lastPage) {
16314
16728
  return lastPage.pageNumber + 1;
16315
16729
  }
16316
16730
  function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, sectionBreakConfig, tableSkeleton) {
16317
- var _sectionBreakConfig$d, _viewModel$getSnapsho, _viewModel$getBody2, _viewModel$getBody3;
16731
+ var _viewModel$getSnapsho, _sectionBreakConfig$d, _viewModel$getBody2, _viewModel$getBody3;
16318
16732
  const { skeletonResourceReference } = ctx;
16319
16733
  const { lists, drawings = {}, localeService } = sectionBreakConfig;
16320
16734
  const { endIndex, blocks = [], children } = paragraphNode;
@@ -16324,7 +16738,8 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
16324
16738
  paragraphId: "para_render_fallback"
16325
16739
  };
16326
16740
  const { paragraphStyle = {}, bullet } = paragraph;
16327
- 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);
16328
16743
  const shouldApplyDocumentDefaults = documentCompatibilityPolicy.applyDocumentDefaultParagraphStyle;
16329
16744
  const useWordStyleLineHeight = documentCompatibilityPolicy.useWordStyleLineHeight;
16330
16745
  const { skeHeaders, skeFooters, skeListLevel, drawingAnchor } = skeletonResourceReference;
@@ -16340,7 +16755,7 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
16340
16755
  const paragraphConfig = {
16341
16756
  paragraphIndex: endIndex,
16342
16757
  documentCompatibilityPolicy,
16343
- 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),
16344
16759
  docxFallbackAnchorLeft: _getFollowingIndentedParagraphAnchorLeft(viewModel, paragraph, paragraphNode, drawings, isTraditionalDocumentCompatibility(documentCompatibilityPolicy)),
16345
16760
  useWordStyleLineHeight,
16346
16761
  paragraphNonInlineSkeDrawings,
@@ -16383,7 +16798,7 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
16383
16798
  let allPages = [curPage];
16384
16799
  let isParagraphFirstShapedText = true;
16385
16800
  let shapedTextOffset = 0;
16386
- for (const [_index, { text, glyphs, breakPointType }] of _mergeAdjacentCustomBlockShapedTexts(shapedTextList).entries()) {
16801
+ for (const [_index, { text, glyphs, breakPointType }] of _mergeAdjacentCustomBlockShapedTexts(shapedTextList, paragraphNonInlineSkeDrawingsByBlockId).entries()) {
16387
16802
  const textStartIndex = paragraphNode.startIndex + shapedTextOffset;
16388
16803
  const textGlyphCount = _glyphCount(glyphs);
16389
16804
  const textEndIndex = textStartIndex + textGlyphCount;
@@ -16900,7 +17315,8 @@ function otherHandler(index, charArray, viewModel, paragraphNode, sectionBreakCo
16900
17315
  const char = (_src$match = src.match(/^[\s\S]/gu)) === null || _src$match === void 0 ? void 0 : _src$match[0];
16901
17316
  if (char == null) break;
16902
17317
  if (hasSpace(char) || startWithEmoji(charArray.substring(step))) break;
16903
- 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));
16904
17320
  glyphGroup.push(glyph);
16905
17321
  src = src.substring(char.length);
16906
17322
  step += char.length;
@@ -16976,7 +17392,7 @@ function punctuationSpaceAdjustment(shapedGlyphs) {
16976
17392
  const nextGlyph = shapedGlyphs[i + 1];
16977
17393
  const { width, content } = curGlyph;
16978
17394
  const delta = width / 2;
16979
- 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) {
16980
17396
  const leftDelta = Math.min(curGlyph.adjustability.shrinkability[1], delta);
16981
17397
  glyphShrinkRight(curGlyph, leftDelta);
16982
17398
  glyphShrinkLeft(nextGlyph, delta - leftDelta);
@@ -16992,11 +17408,11 @@ function addCJKLatinSpacing(shapedTextList) {
16992
17408
  const curGlyph = shapedGlyphs[i];
16993
17409
  const nextGlyph = i < len - 1 ? shapedGlyphs[i + 1] : null;
16994
17410
  const { width } = curGlyph;
16995
- if (hasCJKText(curGlyph.content) && nextGlyph && LATIN_REG.test(nextGlyph.content)) {
17411
+ if (cjk.hasCJKText(curGlyph.content) && nextGlyph && LATIN_REG.test(nextGlyph.content)) {
16996
17412
  curGlyph.width += width / 4;
16997
17413
  curGlyph.adjustability.shrinkability[1] += width / 8;
16998
17414
  }
16999
- if (hasCJKText(curGlyph.content) && prevGlyph && LATIN_REG.test(prevGlyph.content)) {
17415
+ if (cjk.hasCJKText(curGlyph.content) && prevGlyph && LATIN_REG.test(prevGlyph.content)) {
17000
17416
  curGlyph.width += width / 4;
17001
17417
  curGlyph.xOffset += width / 4;
17002
17418
  curGlyph.adjustability.shrinkability[0] += width / 8;
@@ -17058,7 +17474,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
17058
17474
  const newSpan = createSkeletonLetterGlyph(char, config);
17059
17475
  shapedGlyphs.push(newSpan);
17060
17476
  } else {
17061
- const newSpan = createSkeletonLetterGlyph(char, config, void 0, glyphInfo);
17477
+ const newSpan = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphWidth(start, viewModel, paragraphNode, config), glyphInfo);
17062
17478
  shapedGlyphs.push(newSpan);
17063
17479
  }
17064
17480
  }
@@ -17077,24 +17493,29 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
17077
17493
  const { blockId } = customBlock;
17078
17494
  const drawingOrigin = drawings[blockId];
17079
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;
17080
17497
  const { angle } = drawingOrigin.docTransform;
17081
17498
  const { width = 0, height = 0 } = drawingOrigin.docTransform.size;
17082
17499
  const boundingBox = getBoundingBox(angle, 0, width, 0, height);
17083
- 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);
17084
17505
  } else if (drawingOrigin != null) newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
17085
17506
  }
17086
17507
  if (newGlyph == null) newGlyph = createSkeletonLetterGlyph(char, config);
17087
17508
  shapedGlyphs.push(newGlyph);
17088
17509
  i += char.length;
17089
17510
  src = src.substring(char.length);
17090
- } else if (/\s/.test(char) || hasCJK(char)) {
17511
+ } else if (/\s/.test(char) || cjk.hasCJK(char)) {
17091
17512
  const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
17092
17513
  let newGlyph = null;
17093
17514
  if (char === DataStreamTreeTokenType.TAB) newGlyph = createSkeletonTabGlyph(config, getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid));
17094
17515
  else if (char === DataStreamTreeTokenType.PARAGRAPH) {
17095
17516
  var _sectionBreakConfig$r;
17096
17517
  if (((_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.zeroWidthParagraphBreak) === BooleanNumber.TRUE) newGlyph = createSkeletonLetterGlyph(char, config, 0);
17097
- else newGlyph = createSkeletonLetterGlyph(char, config);
17518
+ else newGlyph = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphWidth(i, viewModel, paragraphNode, config));
17098
17519
  } else newGlyph = createSkeletonLetterGlyph(char, config);
17099
17520
  shapedGlyphs.push(newGlyph);
17100
17521
  i += char.length;
@@ -17241,6 +17662,7 @@ function createColumnContentPage(ctx, viewModel, columnNode, sectionBreakConfig,
17241
17662
  const page = createSkeletonPage(ctx, columnSectionBreakConfig, ctx.skeletonResourceReference);
17242
17663
  page.type = 3;
17243
17664
  for (const paragraphNode of getColumnParagraphNodes(columnNode)) dealWidthParagraph(ctx, viewModel, paragraphNode, page, columnSectionBreakConfig);
17665
+ updateInlineDrawingCoordsAndBorder(ctx, [page]);
17244
17666
  updateBlockIndex([page], columnNode.startIndex, (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy());
17245
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);
17246
17668
  return page;
@@ -18682,7 +19104,10 @@ function createDocumentModelWithStyle(content, textStyle, config = {}) {
18682
19104
  paragraphId: createParagraphId(/* @__PURE__ */ new Set()),
18683
19105
  paragraphStyle: { horizontalAlign }
18684
19106
  }],
18685
- sectionBreaks: [{ startIndex: contentLength + 1 }]
19107
+ sectionBreaks: [{
19108
+ sectionId: createSectionId(/* @__PURE__ */ new Set()),
19109
+ startIndex: contentLength + 1
19110
+ }]
18686
19111
  },
18687
19112
  documentStyle: {
18688
19113
  pageSize: {
@@ -18766,6 +19191,59 @@ const DEFAULT_PADDING_DATA = {
18766
19191
  r: 2
18767
19192
  };
18768
19193
  const RENDER_RAW_FORMULA_KEY = "RENDER_RAW_FORMULA";
19194
+ function getShrinkToFitScale(contentWidth, availableWidth, fontSize) {
19195
+ if (contentWidth <= availableWidth || contentWidth <= 0 || availableWidth <= 0 || fontSize <= 0) return 1;
19196
+ return Math.max(1 / fontSize, availableWidth / contentWidth);
19197
+ }
19198
+ function scaleDocumentDataForShrinkToFit(documentData, scale, fallbackFontSize) {
19199
+ var _scaled$documentStyle, _defaultTextStyle$fs, _scaled$body;
19200
+ const scaled = Tools.deepClone(documentData);
19201
+ const defaultTextStyle = (_scaled$documentStyle = scaled.documentStyle.textStyle) !== null && _scaled$documentStyle !== void 0 ? _scaled$documentStyle : {};
19202
+ const defaultFontSize = (_defaultTextStyle$fs = defaultTextStyle.fs) !== null && _defaultTextStyle$fs !== void 0 ? _defaultTextStyle$fs : fallbackFontSize;
19203
+ scaled.documentStyle.textStyle = {
19204
+ ...defaultTextStyle,
19205
+ fs: defaultFontSize * scale
19206
+ };
19207
+ (_scaled$body = scaled.body) === null || _scaled$body === void 0 || (_scaled$body = _scaled$body.textRuns) === null || _scaled$body === void 0 || _scaled$body.forEach((textRun) => {
19208
+ var _textRun$ts, _textStyle$fs;
19209
+ const textStyle = (_textRun$ts = textRun.ts) !== null && _textRun$ts !== void 0 ? _textRun$ts : {};
19210
+ textRun.ts = {
19211
+ ...textStyle,
19212
+ fs: ((_textStyle$fs = textStyle.fs) !== null && _textStyle$fs !== void 0 ? _textStyle$fs : defaultFontSize) * scale
19213
+ };
19214
+ });
19215
+ return scaled;
19216
+ }
19217
+ function getResolvedRenderHorizontalAlign$1(horizontalAlign, cellData) {
19218
+ if (horizontalAlign !== HorizontalAlign.UNSPECIFIED) return horizontalAlign;
19219
+ 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;
19220
+ if ((cellData === null || cellData === void 0 ? void 0 : cellData.t) === CellValueType.BOOLEAN) return HorizontalAlign.CENTER;
19221
+ return horizontalAlign;
19222
+ }
19223
+ function setRenderTextCache(cacheItem, cellData) {
19224
+ var _cacheItem$horizontal;
19225
+ if (cacheItem.documentSkeleton) {
19226
+ cacheItem.displayText = void 0;
19227
+ cacheItem.resolvedHorizontalAlign = void 0;
19228
+ return;
19229
+ }
19230
+ cacheItem.displayText = getDisplayValueFromCell(cellData);
19231
+ cacheItem.resolvedHorizontalAlign = getResolvedRenderHorizontalAlign$1((_cacheItem$horizontal = cacheItem.horizontalAlign) !== null && _cacheItem$horizontal !== void 0 ? _cacheItem$horizontal : HorizontalAlign.UNSPECIFIED, cellData);
19232
+ }
19233
+ function pushRowRange(ranges, row, startColumn, endColumn) {
19234
+ if (endColumn < startColumn) return;
19235
+ const last = ranges[ranges.length - 1];
19236
+ if (last && last.startRow === row && last.endRow === row && last.endColumn + 1 === startColumn) {
19237
+ last.endColumn = endColumn;
19238
+ return;
19239
+ }
19240
+ ranges.push({
19241
+ startRow: row,
19242
+ endRow: row,
19243
+ startColumn,
19244
+ endColumn
19245
+ });
19246
+ }
18769
19247
  const CACHE_COUNT = 100;
18770
19248
  let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18771
19249
  constructor(worksheet, _styles, _localeService, _contextService, _configService, _injector) {
@@ -18779,6 +19257,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18779
19257
  _defineProperty(this, "_cacheRangeMap", /* @__PURE__ */ new Map());
18780
19258
  _defineProperty(this, "_visibleRangeMap", /* @__PURE__ */ new Map());
18781
19259
  _defineProperty(this, "_overflowCache", new ObjectMatrix());
19260
+ _defineProperty(this, "_incrementalFontRenderRanges", []);
18782
19261
  _defineProperty(this, "_stylesCache", {
18783
19262
  background: {},
18784
19263
  backgroundPositions: new ObjectMatrix(),
@@ -18836,6 +19315,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18836
19315
  get overflowCache() {
18837
19316
  return this._overflowCache;
18838
19317
  }
19318
+ get incrementalFontRenderRanges() {
19319
+ return this._incrementalFontRenderRanges;
19320
+ }
18839
19321
  get showGridlines() {
18840
19322
  return this._showGridlines;
18841
19323
  }
@@ -18921,7 +19403,31 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18921
19403
  this.updateVisibleRange(vpInfo);
18922
19404
  const rowColumnSegment = this._drawingRange;
18923
19405
  const columnWidthAccumulation = this.columnWidthAccumulation;
18924
- 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];
19406
+ 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);
19407
+ const hasMergeData = this.worksheet.getMergeData().length > 0;
19408
+ const isScrolling = !!vpInfo && (!!vpInfo.diffX || !!vpInfo.diffY);
19409
+ const shouldRefreshCacheForScroll = isIncrementalScroll && (hasMergeData && isScrolling || !!vpInfo.shouldCacheUpdate && !!vpInfo.diffX);
19410
+ const shouldUseIncrementalStyleRange = isIncrementalScroll && !shouldRefreshCacheForScroll;
19411
+ 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];
19412
+ const visibleCellOptions = hasMergeData ? null : {
19413
+ cacheItem: {
19414
+ bg: true,
19415
+ border: true
19416
+ },
19417
+ reuseExisting: shouldUseIncrementalStyleRange,
19418
+ hasMergeData,
19419
+ rowVisible: true
19420
+ };
19421
+ const overflowCellOptions = hasMergeData ? null : {
19422
+ cacheItem: {
19423
+ bg: false,
19424
+ border: false
19425
+ },
19426
+ reuseExisting: shouldUseIncrementalStyleRange,
19427
+ hasMergeData,
19428
+ rowVisible: true
19429
+ };
19430
+ this._incrementalFontRenderRanges = [];
18925
19431
  for (const styleRange of styleRanges) {
18926
19432
  const { startRow: visibleStartRow, endRow: visibleEndRow, startColumn: visibleStartColumn, endColumn: visibleEndColumn } = styleRange;
18927
19433
  if (visibleEndColumn === -1 || visibleEndRow === -1) continue;
@@ -18946,26 +19452,57 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18946
19452
  startColumn: visibleStartColumn,
18947
19453
  endColumn: visibleEndColumn
18948
19454
  });
18949
- for (let c = visibleStartColumn; c <= visibleEndColumn; c++) this._setStylesCacheForOneCell(r, c, { cacheItem: {
18950
- bg: true,
18951
- border: true
18952
- } });
18953
- for (let c = expandStartCol; c < visibleEndColumn; c++) this._setStylesCacheForOneCell(r, c, { cacheItem: {
18954
- bg: false,
18955
- border: false
18956
- } });
19455
+ for (let c = visibleStartColumn; c <= visibleEndColumn; c++) this._setStylesCacheForOneCell(r, c, visibleCellOptions !== null && visibleCellOptions !== void 0 ? visibleCellOptions : {
19456
+ cacheItem: {
19457
+ bg: true,
19458
+ border: true
19459
+ },
19460
+ reuseExisting: shouldUseIncrementalStyleRange,
19461
+ hasMergeData,
19462
+ rowVisible: true
19463
+ });
19464
+ if (shouldUseIncrementalStyleRange) pushRowRange(this._incrementalFontRenderRanges, r, visibleStartColumn, visibleEndColumn);
19465
+ for (let c = visibleStartColumn - 1; c >= expandStartCol; c--) {
19466
+ this._setStylesCacheForOneCell(r, c, overflowCellOptions !== null && overflowCellOptions !== void 0 ? overflowCellOptions : {
19467
+ cacheItem: {
19468
+ bg: false,
19469
+ border: false
19470
+ },
19471
+ reuseExisting: shouldUseIncrementalStyleRange,
19472
+ hasMergeData,
19473
+ rowVisible: true
19474
+ });
19475
+ if (shouldUseIncrementalStyleRange) pushRowRange(this._incrementalFontRenderRanges, r, c, c);
19476
+ if (!isCellCoverable(this.worksheet.getCell(r, c)) || hasMergeData && this.intersectMergeRange(r, c)) break;
19477
+ }
18957
19478
  if (visibleEndColumn === 0) continue;
18958
- for (let c = visibleEndColumn + 1; c < expandEndCol; c++) this._setStylesCacheForOneCell(r, c, { cacheItem: {
18959
- bg: false,
18960
- border: false
18961
- } });
19479
+ for (let c = visibleEndColumn + 1; c <= expandEndCol; c++) {
19480
+ this._setStylesCacheForOneCell(r, c, overflowCellOptions !== null && overflowCellOptions !== void 0 ? overflowCellOptions : {
19481
+ cacheItem: {
19482
+ bg: false,
19483
+ border: false
19484
+ },
19485
+ reuseExisting: shouldUseIncrementalStyleRange,
19486
+ hasMergeData,
19487
+ rowVisible: true
19488
+ });
19489
+ if (shouldUseIncrementalStyleRange) pushRowRange(this._incrementalFontRenderRanges, r, c, c);
19490
+ if (!isCellCoverable(this.worksheet.getCell(r, c)) || hasMergeData && this.intersectMergeRange(r, c)) break;
19491
+ }
18962
19492
  }
18963
19493
  const mergeRanges = [];
18964
19494
  for (const mergeVisibleRange of mergeVisibleRanges) {
18965
19495
  const mergeRangeInVisible = this.getCurrentRowColumnSegmentMergeData(mergeVisibleRange);
18966
19496
  mergeRanges.push(...mergeRangeInVisible);
18967
19497
  }
18968
- for (const mergeRange of mergeRanges) this._setStylesCacheForOneCell(mergeRange.startRow, mergeRange.startColumn, { mergeRange });
19498
+ for (const mergeRange of mergeRanges) {
19499
+ this._setStylesCacheForOneCell(mergeRange.startRow, mergeRange.startColumn, {
19500
+ mergeRange,
19501
+ reuseExisting: shouldUseIncrementalStyleRange,
19502
+ hasMergeData
19503
+ });
19504
+ if (shouldUseIncrementalStyleRange) pushRowRange(this._incrementalFontRenderRanges, mergeRange.startRow, mergeRange.startColumn, mergeRange.startColumn);
19505
+ }
18969
19506
  }
18970
19507
  return this;
18971
19508
  }
@@ -19250,6 +19787,22 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19250
19787
  endColumn
19251
19788
  };
19252
19789
  }
19790
+ _isOverflowBlockedByAdjacentCell(row, column, horizontalAlign, hasMergeData = true) {
19791
+ const leftBlocked = () => this._isOverflowSideBlocked(row, column, -1, hasMergeData);
19792
+ const rightBlocked = () => this._isOverflowSideBlocked(row, column, 1, hasMergeData);
19793
+ if (horizontalAlign === HorizontalAlign.CENTER) return leftBlocked() && rightBlocked();
19794
+ if (horizontalAlign === HorizontalAlign.RIGHT) return leftBlocked();
19795
+ return rightBlocked();
19796
+ }
19797
+ _isOverflowSideBlocked(row, column, direction, hasMergeData = true) {
19798
+ var _this$_stylesCache$fo;
19799
+ const adjacentColumn = column + direction;
19800
+ if (adjacentColumn < 0 || adjacentColumn >= this.getColumnCount()) return true;
19801
+ const rawAdjacentCell = this._cellData.getValue(row, adjacentColumn);
19802
+ if (rawAdjacentCell && !isCellCoverable(rawAdjacentCell)) return true;
19803
+ const cachedAdjacentCell = (_this$_stylesCache$fo = this._stylesCache.fontMatrix.getValue(row, adjacentColumn)) === null || _this$_stylesCache$fo === void 0 ? void 0 : _this$_stylesCache$fo.cellData;
19804
+ return !isCellCoverable(cachedAdjacentCell !== null && cachedAdjacentCell !== void 0 ? cachedAdjacentCell : this.worksheet.getCell(row, adjacentColumn)) || hasMergeData && this.intersectMergeRange(row, adjacentColumn);
19805
+ }
19253
19806
  /**
19254
19807
  * Get cell by pos(offsetX, offsetY).
19255
19808
  * @deprecated Please use `getCellWithCoordByOffset` instead.
@@ -19419,7 +19972,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19419
19972
  * the text content of this cell can be drawn to both sides, not limited by the cell's width.
19420
19973
  * Overflow on the left or right is aligned according to the text's horizontal alignment.
19421
19974
  */
19422
- _calculateOverflowCell(row, column, docsConfig) {
19975
+ _calculateOverflowCell(row, column, docsConfig, hasMergeData = true) {
19423
19976
  const { documentSkeleton, vertexAngle = 0, centerAngle = 0, horizontalAlign, wrapStrategy } = docsConfig;
19424
19977
  const { t: cellValueType = CellValueType.STRING } = this._cellData.getValue(row, column) || {};
19425
19978
  let horizontalAlignPos = horizontalAlign;
@@ -19435,7 +19988,13 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19435
19988
  * Numerical and Boolean values are not displayed with overflow.
19436
19989
  */
19437
19990
  if ((wrapStrategy === WrapStrategy.OVERFLOW || wrapStrategy === WrapStrategy.UNSPECIFIED) && cellValueType !== CellValueType.NUMBER && cellValueType !== CellValueType.BOOLEAN && horizontalAlign !== HorizontalAlign.JUSTIFIED) {
19438
- if (this.intersectMergeRange(row, column)) return true;
19991
+ var _docsConfig$cellData$, _docsConfig$cellData, _docsConfig$cellData2;
19992
+ docsConfig.textFitsCurrentCell = false;
19993
+ if (hasMergeData && this.intersectMergeRange(row, column)) return true;
19994
+ const columnStart = this.columnWidthAccumulation[column - 1] || 0;
19995
+ const currentColumnWidth = (this.columnWidthAccumulation[column] || columnStart) - columnStart;
19996
+ 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;
19997
+ if ((Boolean(documentSkeleton) || `${rawText !== null && rawText !== void 0 ? rawText : ""}`.length * 4 > currentColumnWidth) && this._isOverflowBlockedByAdjacentCell(row, column, horizontalAlignPos, hasMergeData)) return true;
19439
19998
  let contentSize;
19440
19999
  if (documentSkeleton) contentSize = getDocsSkeletonPageSize(documentSkeleton, vertexAngle);
19441
20000
  else {
@@ -19455,11 +20014,15 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19455
20014
  height: cellHeight
19456
20015
  };
19457
20016
  }
20017
+ if (contentSize.width < currentColumnWidth) {
20018
+ docsConfig.textFitsCurrentCell = true;
20019
+ return true;
20020
+ }
19458
20021
  const { startColumn, endColumn } = this.getOverflowPosition(contentSize, horizontalAlignPos, row, column, this.getColumnCount());
19459
20022
  if (startColumn === endColumn) return true;
19460
20023
  this.appendToOverflowCache(row, column, startColumn, endColumn);
19461
20024
  } else if (wrapStrategy === WrapStrategy.WRAP && vertexAngle !== 0) {
19462
- if (this.intersectMergeRange(row, column)) return true;
20025
+ if (hasMergeData && this.intersectMergeRange(row, column)) return true;
19463
20026
  const { startY, endY } = this.getCellWithCoordByIndex(row, column);
19464
20027
  const cellHeight = endY - startY;
19465
20028
  documentSkeleton.getViewModel().getDataModel().updateDocumentDataPageSize(cellHeight);
@@ -19491,16 +20054,18 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19491
20054
  const startRow = searchArray(rowHeightAccumulation, Math.round(viewBound.top) - this.columnHeaderHeightAndMarginTop);
19492
20055
  const endY = Math.round(viewBound.bottom) - this.columnHeaderHeightAndMarginTop;
19493
20056
  let endRow = searchArray(rowHeightAccumulation, endY);
19494
- if (endRow < lenOfRowData && rowHeightAccumulation[endRow - 1] === endY) endRow -= 1;
20057
+ const isEndYOnBoundary = endRow < lenOfRowData && rowHeightAccumulation[endRow - 1] === endY;
20058
+ if (isEndYOnBoundary) endRow -= 1;
19495
20059
  const startColumn = searchArray(columnWidthAccumulation, Math.round(viewBound.left) - this.rowHeaderWidthAndMarginLeft);
19496
20060
  const endX = Math.round(viewBound.right) - this.rowHeaderWidthAndMarginLeft;
19497
20061
  let endColumn = searchArray(columnWidthAccumulation, endX);
19498
- if (endColumn < lenOfColData && columnWidthAccumulation[endColumn - 1] === endX) endColumn -= 1;
20062
+ const isEndXOnBoundary = endColumn < lenOfColData && columnWidthAccumulation[endColumn - 1] === endX;
20063
+ if (isEndXOnBoundary) endColumn -= 1;
19499
20064
  if (isPrinting) return {
19500
20065
  startRow,
19501
- endRow: endRow === lenOfRowData - 1 ? endRow : endRow - 1,
20066
+ endRow: endRow === lenOfRowData - 1 || isEndYOnBoundary ? endRow : endRow - 1,
19502
20067
  startColumn,
19503
- endColumn: endColumn === lenOfColData - 1 ? endColumn : endColumn - 1
20068
+ endColumn: endColumn === lenOfColData - 1 || isEndXOnBoundary ? endColumn : endColumn - 1
19504
20069
  };
19505
20070
  return {
19506
20071
  startRow,
@@ -19551,7 +20116,15 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19551
20116
  for (let i = 0; i < ranges.length; i++) {
19552
20117
  const range = ranges[i];
19553
20118
  Range.foreach(range, (row, col) => {
20119
+ var _this$_stylesCache$bo, _this$_stylesCache$ba, _this$_stylesCache$ba2;
19554
20120
  this._stylesCache.fontMatrix.realDeleteValue(row, col);
20121
+ (_this$_stylesCache$bo = this._stylesCache.border) === null || _this$_stylesCache$bo === void 0 || _this$_stylesCache$bo.realDeleteValue(row, col);
20122
+ (_this$_stylesCache$ba = this._stylesCache.backgroundPositions) === null || _this$_stylesCache$ba === void 0 || _this$_stylesCache$ba.realDeleteValue(row, col);
20123
+ this._handleBgMatrix.realDeleteValue(row, col);
20124
+ this._handleBorderMatrix.realDeleteValue(row, col);
20125
+ Object.values((_this$_stylesCache$ba2 = this._stylesCache.background) !== null && _this$_stylesCache$ba2 !== void 0 ? _this$_stylesCache$ba2 : {}).forEach((backgroundMatrix) => {
20126
+ backgroundMatrix.realDeleteValue(row, col);
20127
+ });
19555
20128
  });
19556
20129
  }
19557
20130
  this.makeDirty(true);
@@ -19592,15 +20165,38 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19592
20165
  }).bg) return;
19593
20166
  this._handleBgMatrix.setValue(row, col, true);
19594
20167
  if (style && style.bg && style.bg.rgb) {
19595
- var _this$_stylesCache$ba;
20168
+ var _this$_stylesCache$ba3;
19596
20169
  const rgb = style.bg.rgb;
19597
20170
  if (!this._stylesCache.background[rgb]) this._stylesCache.background[rgb] = new ObjectMatrix();
19598
20171
  this._stylesCache.background[rgb].setValue(row, col, rgb);
19599
20172
  const cellInfo = this.getCellWithCoordByIndex(row, col, false);
19600
- (_this$_stylesCache$ba = this._stylesCache.backgroundPositions) === null || _this$_stylesCache$ba === void 0 || _this$_stylesCache$ba.setValue(row, col, cellInfo);
19601
- }
20173
+ (_this$_stylesCache$ba3 = this._stylesCache.backgroundPositions) === null || _this$_stylesCache$ba3 === void 0 || _this$_stylesCache$ba3.setValue(row, col, cellInfo);
20174
+ }
20175
+ }
20176
+ _applyShrinkToFit(row, col, fontCache, style) {
20177
+ var _style$pd5, _fontCache$cellData, _padding$l, _padding$r, _extension$leftOffset, _extension$rightOffse, _style$fs, _getDocsSkeletonPageS3, _fontCache$displayTex;
20178
+ if (style.stf !== BooleanNumber.TRUE) return;
20179
+ const cellInfo = this.getCellWithCoordByIndex(row, col, false);
20180
+ const startX = cellInfo.isMergedMainCell ? cellInfo.mergeInfo.startX : cellInfo.startX;
20181
+ const endX = cellInfo.isMergedMainCell ? cellInfo.mergeInfo.endX : cellInfo.endX;
20182
+ const padding = (_style$pd5 = style.pd) !== null && _style$pd5 !== void 0 ? _style$pd5 : DEFAULT_PADDING_DATA;
20183
+ const extension = (_fontCache$cellData = fontCache.cellData) === null || _fontCache$cellData === void 0 ? void 0 : _fontCache$cellData.fontRenderExtension;
20184
+ const availableWidth = endX - startX - ((_padding$l = padding.l) !== null && _padding$l !== void 0 ? _padding$l : DEFAULT_PADDING_DATA.l) - ((_padding$r = padding.r) !== null && _padding$r !== void 0 ? _padding$r : DEFAULT_PADDING_DATA.r) - ((_extension$leftOffset = extension === null || extension === void 0 ? void 0 : extension.leftOffset) !== null && _extension$leftOffset !== void 0 ? _extension$leftOffset : 0) - ((_extension$rightOffse = extension === null || extension === void 0 ? void 0 : extension.rightOffset) !== null && _extension$rightOffse !== void 0 ? _extension$rightOffse : 0);
20185
+ const fallbackFontSize = (_style$fs = style.fs) !== null && _style$fs !== void 0 ? _style$fs : DEFAULT_STYLES.fs;
20186
+ const scale = getShrinkToFitScale(fontCache.documentSkeleton ? ((_getDocsSkeletonPageS3 = getDocsSkeletonPageSize(fontCache.documentSkeleton, fontCache.vertexAngle)) !== null && _getDocsSkeletonPageS3 !== void 0 ? _getDocsSkeletonPageS3 : { width: 0 }).width : FontCache.getMeasureText((_fontCache$displayTex = fontCache.displayText) !== null && _fontCache$displayTex !== void 0 ? _fontCache$displayTex : getDisplayValueFromCell(fontCache.cellData), fontCache.fontString).width, availableWidth, fallbackFontSize);
20187
+ if (scale >= 1) return;
20188
+ fontCache.shrinkScale = scale;
20189
+ if (fontCache.documentSkeleton) {
20190
+ const documentModel = new DocumentDataModel(scaleDocumentDataForShrinkToFit(fontCache.documentSkeleton.getViewModel().getDataModel().getSnapshot(), scale, fallbackFontSize));
20191
+ const documentSkeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), this._localeService);
20192
+ documentSkeleton.calculate();
20193
+ fontCache.documentSkeleton = documentSkeleton;
20194
+ } else fontCache.fontString = getFontStyleString({
20195
+ ...style,
20196
+ fs: fallbackFontSize * scale
20197
+ }).fontCache;
19602
20198
  }
19603
- _setFontStylesCache(row, col, cellData, style) {
20199
+ _setFontStylesCache(row, col, cellData, style, hasMergeData = true) {
19604
20200
  var _style$tr2;
19605
20201
  if (isNullCell(cellData)) return;
19606
20202
  let config = {
@@ -19612,6 +20208,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19612
20208
  else {
19613
20209
  const cacheItem = cacheValue;
19614
20210
  cacheItem.cellData = cellData;
20211
+ setRenderTextCache(cacheItem, cellData);
19615
20212
  this._stylesCache.fontMatrix.setValue(row, col, cacheValue);
19616
20213
  return;
19617
20214
  }
@@ -19655,8 +20252,11 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19655
20252
  style
19656
20253
  };
19657
20254
  }
19658
- this._calculateOverflowCell(row, col, config);
19659
- this._stylesCache.fontMatrix.setValue(row, col, config);
20255
+ const fontCacheItem = config;
20256
+ setRenderTextCache(fontCacheItem, cellData);
20257
+ this._applyShrinkToFit(row, col, fontCacheItem, style);
20258
+ this._calculateOverflowCell(row, col, fontCacheItem, hasMergeData);
20259
+ this._stylesCache.fontMatrix.setValue(row, col, fontCacheItem);
19660
20260
  }
19661
20261
  /**
19662
20262
  * Set border background and font to this._stylesCache cell by cell.
@@ -19665,19 +20265,37 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19665
20265
  * @param options {{ mergeRange: IRange; cacheItem: ICacheItem } | undefined}
19666
20266
  */
19667
20267
  _setStylesCacheForOneCell(row, col, options) {
20268
+ var _options$hasMergeData, _options$rowVisible, _options$hasMergeData2;
19668
20269
  if (row === -1 || col === -1) return;
19669
20270
  if (!options) options = { cacheItem: {
19670
20271
  bg: true,
19671
20272
  border: true
19672
20273
  } };
19673
- const { isMerged, isMergedMainCell, startRow, startColumn, endRow, endColumn } = this.worksheet.getCellInfoInMergeData(row, col);
19674
- if (isMerged) options.mergeRange = {
19675
- startRow,
19676
- startColumn,
19677
- endRow,
19678
- endColumn
19679
- };
19680
- if (this.worksheet.getColVisible(col) === false || this.worksheet.getRowVisible(row) === false) {
20274
+ const cacheItem = options.cacheItem;
20275
+ if (options.reuseExisting && cacheItem && !options.mergeRange) {
20276
+ const bgHandled = !cacheItem.bg || Tools.isDefine(this._handleBgMatrix.getValue(row, col));
20277
+ const borderHandled = !cacheItem.border || Tools.isDefine(this._handleBorderMatrix.getValue(row, col));
20278
+ if (bgHandled && borderHandled && this._stylesCache.fontMatrix.getValue(row, col)) return;
20279
+ }
20280
+ const hasMergeData = (_options$hasMergeData = options.hasMergeData) !== null && _options$hasMergeData !== void 0 ? _options$hasMergeData : true;
20281
+ let isMerged = false;
20282
+ let isMergedMainCell = false;
20283
+ if (hasMergeData) {
20284
+ const mergeInfo = this.worksheet.getCellInfoInMergeData(row, col);
20285
+ isMerged = mergeInfo.isMerged;
20286
+ isMergedMainCell = mergeInfo.isMergedMainCell;
20287
+ if (isMerged) {
20288
+ const { startRow, startColumn, endRow, endColumn } = mergeInfo;
20289
+ options.mergeRange = {
20290
+ startRow,
20291
+ startColumn,
20292
+ endRow,
20293
+ endColumn
20294
+ };
20295
+ }
20296
+ }
20297
+ const rowVisible = (_options$rowVisible = options.rowVisible) !== null && _options$rowVisible !== void 0 ? _options$rowVisible : this.worksheet.getRowVisible(row);
20298
+ if (this.worksheet.getColVisible(col) === false || rowVisible === false) {
19681
20299
  if (isMerged && !isMergedMainCell) return;
19682
20300
  else if (!isMergedMainCell) return;
19683
20301
  }
@@ -19689,7 +20307,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
19689
20307
  this._setFontStylesCache(row, col, {
19690
20308
  ...cell,
19691
20309
  s: style
19692
- }, style);
20310
+ }, style, (_options$hasMergeData2 = options.hasMergeData) !== null && _options$hasMergeData2 !== void 0 ? _options$hasMergeData2 : true);
19693
20311
  }
19694
20312
  /**
19695
20313
  * pro/issues/344
@@ -19902,6 +20520,19 @@ function rotatedBoundingBox(width, height, angleDegrees) {
19902
20520
  rotatedHeight: Math.abs(width * Math.sin(angle)) + Math.abs(height * Math.cos(angle))
19903
20521
  };
19904
20522
  }
20523
+ function getResolvedRenderHorizontalAlign(fontCache, cellData) {
20524
+ if (fontCache.resolvedHorizontalAlign !== void 0) return fontCache.resolvedHorizontalAlign;
20525
+ const { horizontalAlign } = fontCache;
20526
+ if (horizontalAlign !== HorizontalAlign.UNSPECIFIED) return horizontalAlign;
20527
+ if (cellData.t === CellValueType.NUMBER || !Tools.isDefine(cellData.t) && typeof cellData.v === "number") return HorizontalAlign.RIGHT;
20528
+ if (cellData.t === CellValueType.BOOLEAN) return HorizontalAlign.CENTER;
20529
+ return horizontalAlign;
20530
+ }
20531
+ function needsFontRenderExtensionBounds(fontCache) {
20532
+ var _fontCache$cellData;
20533
+ const extension = (_fontCache$cellData = fontCache.cellData) === null || _fontCache$cellData === void 0 ? void 0 : _fontCache$cellData.fontRenderExtension;
20534
+ 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));
20535
+ }
19905
20536
  var Font = class extends SheetExtension {
19906
20537
  constructor() {
19907
20538
  super();
@@ -19932,7 +20563,7 @@ var Font = class extends SheetExtension {
19932
20563
  const { rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;
19933
20564
  if (!rowHeightAccumulation || !columnWidthAccumulation || columnTotalWidth === void 0 || rowTotalHeight === void 0 || !worksheet) return;
19934
20565
  const scale = this._getScale(parentScale);
19935
- const { viewRanges = [], checkOutOfViewBound } = moreBoundsInfo;
20566
+ const { fontRenderRanges, viewRanges = [], checkOutOfViewBound } = moreBoundsInfo;
19936
20567
  const lastRowIndex = spreadsheetSkeleton.getRowCount() - 1;
19937
20568
  const lastColIndex = spreadsheetSkeleton.getColumnCount() - 1;
19938
20569
  const expandedViewRanges = viewRanges.map((range) => clampRange({
@@ -19940,43 +20571,51 @@ var Font = class extends SheetExtension {
19940
20571
  startColumn: range.startColumn - 20,
19941
20572
  endColumn: range.endColumn + 20
19942
20573
  }, lastRowIndex, lastColIndex));
20574
+ const rangesToScan = (fontRenderRanges === null || fontRenderRanges === void 0 ? void 0 : fontRenderRanges.length) ? fontRenderRanges : expandedViewRanges;
19943
20575
  const renderFontContext = {
19944
20576
  ctx,
19945
20577
  scale,
19946
20578
  columnTotalWidth,
19947
20579
  rowTotalHeight,
19948
- viewRanges: expandedViewRanges,
20580
+ viewRanges: (fontRenderRanges === null || fontRenderRanges === void 0 ? void 0 : fontRenderRanges.length) ? viewRanges : expandedViewRanges,
19949
20581
  checkOutOfViewBound: checkOutOfViewBound || true,
19950
20582
  diffRanges,
19951
20583
  spreadsheetSkeleton
19952
20584
  };
19953
20585
  ctx.save();
20586
+ const hasMerge = spreadsheetSkeleton.worksheet.getMergeData().length > 0;
19954
20587
  const uniqueMergeRanges = [];
19955
- const mergeRangeIDSet = /* @__PURE__ */ new Set();
19956
- expandedViewRanges.forEach((range) => {
19957
- spreadsheetSkeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn).forEach((mergeRange) => {
19958
- const mergeRangeIndex = spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(mergeRange.startRow, mergeRange.startColumn);
20588
+ const mergeRangeIDSet = hasMerge ? /* @__PURE__ */ new Set() : null;
20589
+ const spanModel = hasMerge ? spreadsheetSkeleton.worksheet.getSpanModel() : null;
20590
+ rangesToScan.forEach((range) => {
20591
+ if (hasMerge && spanModel && mergeRangeIDSet) spreadsheetSkeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn).forEach((mergeRange) => {
20592
+ const mergeRangeIndex = spanModel.getMergeDataIndex(mergeRange.startRow, mergeRange.startColumn);
19959
20593
  if (!mergeRangeIDSet.has(mergeRangeIndex)) {
19960
20594
  mergeRangeIDSet.add(mergeRangeIndex);
19961
20595
  uniqueMergeRanges.push(mergeRange);
19962
20596
  }
19963
20597
  });
19964
- Range.foreach(range, (row, col) => {
19965
- if (spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(row, col) !== -1) return;
20598
+ const { startRow, endRow, startColumn, endColumn } = range;
20599
+ for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
20600
+ const fontCache = fontMatrix.getValue(row, col);
20601
+ if (!fontCache) continue;
20602
+ if (spanModel && spanModel.getMergeDataIndex(row, col) !== -1) continue;
19966
20603
  const cellInfo = spreadsheetSkeleton.getCellWithCoordByIndex(row, col, false);
19967
- if (!cellInfo) return;
20604
+ if (!cellInfo) continue;
19968
20605
  renderFontContext.cellInfo = cellInfo;
19969
- this._renderFontEachCell(renderFontContext, row, col, fontMatrix);
19970
- });
20606
+ this._renderFontEachCell(renderFontContext, row, col, fontMatrix, fontCache);
20607
+ }
19971
20608
  });
19972
20609
  uniqueMergeRanges.forEach((range) => {
20610
+ const fontCache = fontMatrix.getValue(range.startRow, range.startColumn);
20611
+ if (!fontCache) return;
19973
20612
  renderFontContext.cellInfo = spreadsheetSkeleton.getCellWithCoordByIndex(range.startRow, range.startColumn, false);
19974
- this._renderFontEachCell(renderFontContext, range.startRow, range.startColumn, fontMatrix);
20613
+ this._renderFontEachCell(renderFontContext, range.startRow, range.startColumn, fontMatrix, fontCache);
19975
20614
  });
19976
20615
  ctx.restore();
19977
20616
  }
19978
- _renderFontEachCell(renderFontCtx, row, col, fontMatrix) {
19979
- var _cellData$fontRenderE;
20617
+ _renderFontEachCell(renderFontCtx, row, col, fontMatrix, cacheValue) {
20618
+ var _fontCache$cellData2;
19980
20619
  const { ctx, viewRanges, diffRanges, spreadsheetSkeleton, cellInfo } = renderFontCtx;
19981
20620
  const { startY, endY, startX, endX } = cellInfo;
19982
20621
  const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
@@ -19991,7 +20630,7 @@ var Font = class extends SheetExtension {
19991
20630
  renderFontCtx.endX = mergeInfo.endX;
19992
20631
  renderFontCtx.endY = mergeInfo.endY;
19993
20632
  }
19994
- const fontCache = fontMatrix.getValue(row, col);
20633
+ const fontCache = cacheValue !== null && cacheValue !== void 0 ? cacheValue : fontMatrix.getValue(row, col);
19995
20634
  if (!fontCache) return true;
19996
20635
  renderFontCtx.fontCache = fontCache;
19997
20636
  const overflowRange = spreadsheetSkeleton.overflowCache.getValue(row, col);
@@ -20017,8 +20656,19 @@ var Font = class extends SheetExtension {
20017
20656
  }
20018
20657
  if (isAllColHidden) return true;
20019
20658
  }
20020
- const cellData = spreadsheetSkeleton.worksheet.getCell(row, col) || {};
20021
- if (cellData === null || cellData === void 0 || (_cellData$fontRenderE = cellData.fontRenderExtension) === null || _cellData$fontRenderE === void 0 ? void 0 : _cellData$fontRenderE.isSkip) return true;
20659
+ if ((_fontCache$cellData2 = fontCache.cellData) === null || _fontCache$cellData2 === void 0 ? void 0 : _fontCache$cellData2.fontRenderExtension) {
20660
+ var _cellData$fontRenderE;
20661
+ const cellData = spreadsheetSkeleton.worksheet.getCell(row, col) || {};
20662
+ if (cellData === null || cellData === void 0 || (_cellData$fontRenderE = cellData.fontRenderExtension) === null || _cellData$fontRenderE === void 0 ? void 0 : _cellData$fontRenderE.isSkip) return true;
20663
+ }
20664
+ if (this._renderPlainTextWithoutClip(ctx, renderFontCtx, fontCache)) {
20665
+ renderFontCtx.startX = 0;
20666
+ renderFontCtx.startY = 0;
20667
+ renderFontCtx.endX = 0;
20668
+ renderFontCtx.endY = 0;
20669
+ renderFontCtx.overflowRectangle = null;
20670
+ return false;
20671
+ }
20022
20672
  ctx.save();
20023
20673
  ctx.beginPath();
20024
20674
  renderFontCtx.overflowRectangle = overflowRange;
@@ -20026,7 +20676,6 @@ var Font = class extends SheetExtension {
20026
20676
  ctx.translate(renderFontCtx.startX + FIX_ONE_PIXEL_BLUR_OFFSET, renderFontCtx.startY + FIX_ONE_PIXEL_BLUR_OFFSET);
20027
20677
  if (fontCache.documentSkeleton) this._renderDocuments(ctx, row, col, renderFontCtx, spreadsheetSkeleton.overflowCache);
20028
20678
  else this._renderText(ctx, row, col, renderFontCtx, spreadsheetSkeleton.overflowCache);
20029
- ctx.closePath();
20030
20679
  ctx.restore();
20031
20680
  if (fontCache.documentSkeleton) {
20032
20681
  var _documentDataModel$ge;
@@ -20046,15 +20695,49 @@ var Font = class extends SheetExtension {
20046
20695
  renderFontCtx.overflowRectangle = null;
20047
20696
  return false;
20048
20697
  }
20698
+ _renderPlainTextWithoutClip(ctx, renderFontCtx, fontCache) {
20699
+ var _fontCache$style, _fontCache$style2, _fontCache$style$pd, _fontCache$style3, _padding$l, _padding$r, _padding$t, _padding$b, _fontCache$displayTex, _fontCache$style4;
20700
+ const { cellData, documentSkeleton, textFitsCurrentCell, vertexAngle = 0, centerAngle = 0, wrapStrategy } = fontCache;
20701
+ if (!textFitsCurrentCell) return false;
20702
+ if (documentSkeleton) return false;
20703
+ if (vertexAngle !== 0 || centerAngle !== 0) return false;
20704
+ if (wrapStrategy === WrapStrategy.WRAP) return false;
20705
+ if (needsFontRenderExtensionBounds(fontCache)) return false;
20706
+ 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;
20707
+ if ((cellData === null || cellData === void 0 ? void 0 : cellData.v) === void 0 || (cellData === null || cellData === void 0 ? void 0 : cellData.v) === null) return false;
20708
+ 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;
20709
+ const paddingLeft = (_padding$l = padding.l) !== null && _padding$l !== void 0 ? _padding$l : DEFAULT_PADDING_DATA.l;
20710
+ const paddingRight = (_padding$r = padding.r) !== null && _padding$r !== void 0 ? _padding$r : DEFAULT_PADDING_DATA.r;
20711
+ const paddingTop = (_padding$t = padding.t) !== null && _padding$t !== void 0 ? _padding$t : DEFAULT_PADDING_DATA.t;
20712
+ const paddingBottom = (_padding$b = padding.b) !== null && _padding$b !== void 0 ? _padding$b : DEFAULT_PADDING_DATA.b;
20713
+ const text = (_fontCache$displayTex = fontCache.displayText) !== null && _fontCache$displayTex !== void 0 ? _fontCache$displayTex : getDisplayValueFromCell(cellData);
20714
+ const { startX, startY, endX, endY } = renderFontCtx;
20715
+ const cellWidth = endX - startX - paddingLeft - paddingRight;
20716
+ const cellHeight = endY - startY - paddingTop - paddingBottom;
20717
+ const hAlign = getResolvedRenderHorizontalAlign(fontCache, cellData);
20718
+ Text.drawPlainWith(ctx, {
20719
+ text,
20720
+ fontStyle: fontCache.fontString,
20721
+ hAlign,
20722
+ vAlign: fontCache.verticalAlign,
20723
+ width: cellWidth,
20724
+ height: cellHeight,
20725
+ left: startX + FIX_ONE_PIXEL_BLUR_OFFSET + paddingLeft,
20726
+ top: startY + FIX_ONE_PIXEL_BLUR_OFFSET + paddingTop,
20727
+ 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,
20728
+ cellValueType: cellData.t
20729
+ });
20730
+ return true;
20731
+ }
20049
20732
  _renderImages(ctx, fontsConfig, startX, startY, endX, endY) {
20050
- var _fontsConfig$style, _padding$l, _padding$r, _padding$t, _padding$b, _getSkeletonData;
20733
+ var _fontsConfig$style, _padding$l2, _padding$r2, _padding$t2, _padding$b2, _getSkeletonData;
20051
20734
  const { documentSkeleton, verticalAlign, horizontalAlign } = fontsConfig;
20052
20735
  const PADDING = 2;
20053
20736
  const padding = (_fontsConfig$style = fontsConfig.style) === null || _fontsConfig$style === void 0 ? void 0 : _fontsConfig$style.pd;
20054
- const paddingLeft = (_padding$l = padding === null || padding === void 0 ? void 0 : padding.l) !== null && _padding$l !== void 0 ? _padding$l : PADDING;
20055
- const paddingRight = (_padding$r = padding === null || padding === void 0 ? void 0 : padding.r) !== null && _padding$r !== void 0 ? _padding$r : PADDING;
20056
- const paddingTop = (_padding$t = padding === null || padding === void 0 ? void 0 : padding.t) !== null && _padding$t !== void 0 ? _padding$t : PADDING;
20057
- const paddingBottom = (_padding$b = padding === null || padding === void 0 ? void 0 : padding.b) !== null && _padding$b !== void 0 ? _padding$b : PADDING;
20737
+ const paddingLeft = (_padding$l2 = padding === null || padding === void 0 ? void 0 : padding.l) !== null && _padding$l2 !== void 0 ? _padding$l2 : PADDING;
20738
+ const paddingRight = (_padding$r2 = padding === null || padding === void 0 ? void 0 : padding.r) !== null && _padding$r2 !== void 0 ? _padding$r2 : PADDING;
20739
+ const paddingTop = (_padding$t2 = padding === null || padding === void 0 ? void 0 : padding.t) !== null && _padding$t2 !== void 0 ? _padding$t2 : PADDING;
20740
+ const paddingBottom = (_padding$b2 = padding === null || padding === void 0 ? void 0 : padding.b) !== null && _padding$b2 !== void 0 ? _padding$b2 : PADDING;
20058
20741
  const contentStartX = startX + paddingLeft;
20059
20742
  const contentEndX = endX - paddingRight;
20060
20743
  const contentStartY = startY + paddingTop;
@@ -20124,7 +20807,7 @@ var Font = class extends SheetExtension {
20124
20807
  * @param fontCache
20125
20808
  */
20126
20809
  _clipByRenderBounds(renderFontContext, row, col, padding = 0) {
20127
- var _fontCache$cellData$f, _fontCache$cellData, _fontCache$cellData$f2, _fontCache$cellData2;
20810
+ var _fontCache$cellData$f, _fontCache$cellData3, _fontCache$cellData$f2, _fontCache$cellData4;
20128
20811
  const { ctx, scale, overflowRectangle, fontCache } = renderFontContext;
20129
20812
  let { startX, endX, startY, endY } = renderFontContext;
20130
20813
  const { horizontalAlign = 0, vertexAngle = 0, centerAngle = 0 } = fontCache;
@@ -20133,8 +20816,8 @@ var Font = class extends SheetExtension {
20133
20816
  if (centerAngle === 90 && vertexAngle === 90) horizontalAlignOverFlow = HorizontalAlign.CENTER;
20134
20817
  else if (vertexAngle > 0 && vertexAngle !== 90 || vertexAngle === -90) horizontalAlignOverFlow = HorizontalAlign.RIGHT;
20135
20818
  }
20136
- 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;
20137
- 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;
20819
+ 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;
20820
+ 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;
20138
20821
  let isOverflow = true;
20139
20822
  if (vertexAngle === 0) {
20140
20823
  startX = startX + leftOffset;
@@ -20166,26 +20849,22 @@ var Font = class extends SheetExtension {
20166
20849
  renderFontContext.endY = endY;
20167
20850
  }
20168
20851
  _renderText(ctx, row, col, renderFontCtx, overflowCache) {
20169
- var _fontCache$style$pd, _fontCache$style, _padding$l2, _padding$r2, _padding$t2, _padding$b2, _fontCache$style2, _fontCache$style3, _fontCache$style4, _fontCache$style5;
20852
+ var _fontCache$style$pd2, _fontCache$style5, _padding$l3, _padding$r3, _padding$t3, _padding$b3, _fontCache$displayTex2, _fontCache$style6, _fontCache$style7, _fontCache$style8, _fontCache$style9;
20170
20853
  const { fontCache } = renderFontCtx;
20171
20854
  if (!fontCache) return;
20172
- 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;
20173
- const paddingLeft = (_padding$l2 = padding.l) !== null && _padding$l2 !== void 0 ? _padding$l2 : DEFAULT_PADDING_DATA.l;
20174
- const paddingRight = (_padding$r2 = padding.r) !== null && _padding$r2 !== void 0 ? _padding$r2 : DEFAULT_PADDING_DATA.r;
20175
- const paddingTop = (_padding$t2 = padding.t) !== null && _padding$t2 !== void 0 ? _padding$t2 : DEFAULT_PADDING_DATA.t;
20176
- const paddingBottom = (_padding$b2 = padding.b) !== null && _padding$b2 !== void 0 ? _padding$b2 : DEFAULT_PADDING_DATA.b;
20855
+ 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;
20856
+ const paddingLeft = (_padding$l3 = padding.l) !== null && _padding$l3 !== void 0 ? _padding$l3 : DEFAULT_PADDING_DATA.l;
20857
+ const paddingRight = (_padding$r3 = padding.r) !== null && _padding$r3 !== void 0 ? _padding$r3 : DEFAULT_PADDING_DATA.r;
20858
+ const paddingTop = (_padding$t3 = padding.t) !== null && _padding$t3 !== void 0 ? _padding$t3 : DEFAULT_PADDING_DATA.t;
20859
+ const paddingBottom = (_padding$b3 = padding.b) !== null && _padding$b3 !== void 0 ? _padding$b3 : DEFAULT_PADDING_DATA.b;
20177
20860
  const { vertexAngle = 0, wrapStrategy, cellData } = fontCache;
20178
20861
  if ((cellData === null || cellData === void 0 ? void 0 : cellData.v) === void 0 || (cellData === null || cellData === void 0 ? void 0 : cellData.v) === null) return;
20179
- const text = getDisplayValueFromCell(cellData);
20862
+ const text = (_fontCache$displayTex2 = fontCache.displayText) !== null && _fontCache$displayTex2 !== void 0 ? _fontCache$displayTex2 : getDisplayValueFromCell(cellData);
20180
20863
  const { startX, startY, endX, endY } = renderFontCtx;
20181
20864
  const cellWidth = endX - startX - paddingLeft - paddingRight;
20182
20865
  const cellHeight = endY - startY - paddingTop - paddingBottom;
20183
- let hAlign = fontCache.horizontalAlign;
20184
- if (fontCache.horizontalAlign === HorizontalAlign.UNSPECIFIED) {
20185
- if (cellData.t === CellValueType.NUMBER || !Tools.isDefine(cellData.t) && typeof cellData.v === "number") hAlign = HorizontalAlign.RIGHT;
20186
- else if (cellData.t === CellValueType.BOOLEAN) hAlign = HorizontalAlign.CENTER;
20187
- }
20188
- Text.drawWith(ctx, {
20866
+ const hAlign = getResolvedRenderHorizontalAlign(fontCache, cellData);
20867
+ const textProps = {
20189
20868
  text,
20190
20869
  fontStyle: fontCache.fontString,
20191
20870
  warp: wrapStrategy === WrapStrategy.WRAP && vertexAngle === 0,
@@ -20195,12 +20874,17 @@ var Font = class extends SheetExtension {
20195
20874
  height: cellHeight,
20196
20875
  left: paddingLeft,
20197
20876
  top: paddingTop,
20198
- 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,
20199
- 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),
20200
- 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),
20201
- 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,
20877
+ 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,
20878
+ 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),
20879
+ 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),
20880
+ 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,
20202
20881
  cellValueType: cellData.t
20203
- });
20882
+ };
20883
+ if (!textProps.warp && !textProps.strokeLine && !textProps.underline) {
20884
+ Text.drawPlainWith(ctx, textProps);
20885
+ return;
20886
+ }
20887
+ Text.drawWith(ctx, textProps);
20204
20888
  }
20205
20889
  _renderDocuments(ctx, row, col, renderFontCtx, overflowCache) {
20206
20890
  const documents = this.getDocuments();
@@ -20270,6 +20954,15 @@ const stringifyRange = (range) => {
20270
20954
  const { startRow, endRow, startColumn, endColumn } = range;
20271
20955
  return `${startRow}-${endRow}-${startColumn}-${endColumn}`;
20272
20956
  };
20957
+ function drawTriangleMarker(ctx, color, x, y, x2, y2, x3, y3) {
20958
+ ctx.fillStyle = color;
20959
+ ctx.beginPath();
20960
+ ctx.moveTo(x, y);
20961
+ ctx.lineTo(x2, y2);
20962
+ ctx.lineTo(x3, y3);
20963
+ ctx.closePath();
20964
+ ctx.fill();
20965
+ }
20273
20966
  var Marker = class extends SheetExtension {
20274
20967
  constructor(..._args) {
20275
20968
  super(..._args);
@@ -20281,11 +20974,15 @@ var Marker = class extends SheetExtension {
20281
20974
  const { worksheet, rowColumnSegment } = skeleton;
20282
20975
  if (!worksheet) return;
20283
20976
  const mergeCellRendered = /* @__PURE__ */ new Set();
20284
- ((diffRanges === null || diffRanges === void 0 ? void 0 : diffRanges.length) ? diffRanges : [rowColumnSegment]).forEach((range) => {
20285
- Range.foreach(range, (row, col) => {
20977
+ const renderRanges = (diffRanges === null || diffRanges === void 0 ? void 0 : diffRanges.length) ? diffRanges : [rowColumnSegment];
20978
+ const hasMerge = worksheet.getMergeData().length > 0;
20979
+ renderRanges.forEach((range) => {
20980
+ const { startRow, endRow, startColumn, endColumn } = range;
20981
+ for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
20286
20982
  var _cellData$markers, _cellData$markers2, _cellData$markers3, _cellData$markers4;
20287
- if (!worksheet.getRowVisible(row) || !worksheet.getColVisible(col)) return;
20983
+ if (!worksheet.getRowVisible(row) || !worksheet.getColVisible(col)) continue;
20288
20984
  let cellData = worksheet.getCell(row, col);
20985
+ if (!hasMerge && !(cellData === null || cellData === void 0 ? void 0 : cellData.markers)) continue;
20289
20986
  const cellInfo = skeleton.getCellWithCoordByIndex(row, col, false);
20290
20987
  const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
20291
20988
  let { startY, endY, startX, endX } = cellInfo;
@@ -20302,74 +20999,38 @@ var Marker = class extends SheetExtension {
20302
20999
  };
20303
21000
  cellData = worksheet.getCell(mainCell.row, mainCell.col);
20304
21001
  }
20305
- if (!this.isRenderDiffRangesByRow(mergeInfo.startRow, mergeInfo.endRow, diffRanges)) return true;
21002
+ if (!this.isRenderDiffRangesByRow(mergeInfo.startRow, mergeInfo.endRow, diffRanges)) continue;
20306
21003
  if (cellInfo.isMerged || cellInfo.isMergedMainCell) {
20307
21004
  const rangeStr = stringifyRange(mergeInfo);
20308
- if (mergeCellRendered.has(rangeStr)) return;
21005
+ if (mergeCellRendered.has(rangeStr)) continue;
20309
21006
  mergeCellRendered.add(rangeStr);
20310
21007
  }
20311
- if (!cellData) return;
21008
+ if (!cellData) continue;
20312
21009
  if ((_cellData$markers = cellData.markers) === null || _cellData$markers === void 0 ? void 0 : _cellData$markers.tr) {
20313
- ctx.save();
20314
21010
  const marker = cellData.markers.tr;
20315
21011
  const x = endX;
20316
21012
  const y = startY;
20317
- ctx.fillStyle = marker.color;
20318
- ctx.moveTo(x, y);
20319
- ctx.beginPath();
20320
- ctx.lineTo(x - marker.size, y);
20321
- ctx.lineTo(x, y + marker.size);
20322
- ctx.lineTo(x, y);
20323
- ctx.closePath();
20324
- ctx.fill();
20325
- ctx.restore();
21013
+ drawTriangleMarker(ctx, marker.color, x, y, x - marker.size, y, x, y + marker.size);
20326
21014
  }
20327
21015
  if ((_cellData$markers2 = cellData.markers) === null || _cellData$markers2 === void 0 ? void 0 : _cellData$markers2.tl) {
20328
- ctx.save();
20329
21016
  const marker = cellData.markers.tl;
20330
21017
  const x = startX;
20331
21018
  const y = startY;
20332
- ctx.fillStyle = marker.color;
20333
- ctx.moveTo(x, y);
20334
- ctx.beginPath();
20335
- ctx.lineTo(x + marker.size, y);
20336
- ctx.lineTo(x, y + marker.size);
20337
- ctx.lineTo(x, y);
20338
- ctx.closePath();
20339
- ctx.fill();
20340
- ctx.restore();
21019
+ drawTriangleMarker(ctx, marker.color, x, y, x + marker.size, y, x, y + marker.size);
20341
21020
  }
20342
21021
  if ((_cellData$markers3 = cellData.markers) === null || _cellData$markers3 === void 0 ? void 0 : _cellData$markers3.br) {
20343
- ctx.save();
20344
21022
  const marker = cellData.markers.br;
20345
21023
  const x = endX;
20346
21024
  const y = endY;
20347
- ctx.fillStyle = marker.color;
20348
- ctx.moveTo(x, y);
20349
- ctx.beginPath();
20350
- ctx.lineTo(x - marker.size, y);
20351
- ctx.lineTo(x, y - marker.size);
20352
- ctx.lineTo(x, y);
20353
- ctx.closePath();
20354
- ctx.fill();
20355
- ctx.restore();
21025
+ drawTriangleMarker(ctx, marker.color, x, y, x - marker.size, y, x, y - marker.size);
20356
21026
  }
20357
21027
  if ((_cellData$markers4 = cellData.markers) === null || _cellData$markers4 === void 0 ? void 0 : _cellData$markers4.bl) {
20358
- ctx.save();
20359
21028
  const marker = cellData.markers.bl;
20360
21029
  const x = startX;
20361
21030
  const y = endY;
20362
- ctx.fillStyle = marker.color;
20363
- ctx.moveTo(x, y);
20364
- ctx.beginPath();
20365
- ctx.lineTo(x + marker.size, y);
20366
- ctx.lineTo(x, y - marker.size);
20367
- ctx.lineTo(x, y);
20368
- ctx.closePath();
20369
- ctx.fill();
20370
- ctx.restore();
21031
+ drawTriangleMarker(ctx, marker.color, x, y, x + marker.size, y, x, y - marker.size);
20371
21032
  }
20372
- });
21033
+ }
20373
21034
  });
20374
21035
  }
20375
21036
  };
@@ -20629,6 +21290,12 @@ var DocComponent = class extends RenderComponent {
20629
21290
  _defineProperty(this, "pageMarginLeft", 0);
20630
21291
  _defineProperty(this, "pageMarginTop", 0);
20631
21292
  _defineProperty(this, "pageLayoutType", 0);
21293
+ _defineProperty(this, "onTextFillImageLoaded", void 0);
21294
+ this.onTextFillImageLoaded = () => {
21295
+ var _config$onTextFillIma;
21296
+ this.makeDirty(true);
21297
+ config === null || config === void 0 || (_config$onTextFillIma = config.onTextFillImageLoaded) === null || _config$onTextFillIma === void 0 || _config$onTextFillIma.call(config);
21298
+ };
20632
21299
  this._setConfig(config);
20633
21300
  }
20634
21301
  getSkeleton() {
@@ -21157,7 +21824,6 @@ var Image$1 = class extends Shape {
21157
21824
  this._props = { ...config };
21158
21825
  if (config.image) {
21159
21826
  this._native = config.image;
21160
- this._native.crossOrigin = "anonymous";
21161
21827
  this.makeDirty(true);
21162
21828
  } else if (config.url) {
21163
21829
  this._native = document.createElement("img");
@@ -22478,6 +23144,7 @@ const MIN_THUMB_SIZE = 17;
22478
23144
  const DEFAULT_TRACK_SIZE = 10;
22479
23145
  const DEFAULT_THUMB_MARGIN = 2;
22480
23146
  const HOVER_THUMB_MARGIN = 1;
23147
+ const BAR_DRAG_SCROLL_THROTTLE_MS = 32;
22481
23148
  var ScrollBar = class ScrollBar extends Disposable {
22482
23149
  constructor(view, props) {
22483
23150
  super();
@@ -22500,6 +23167,10 @@ var ScrollBar = class ScrollBar extends Disposable {
22500
23167
  _defineProperty(this, "_lastY", -1);
22501
23168
  _defineProperty(this, "_isHorizonMove", false);
22502
23169
  _defineProperty(this, "_isVerticalMove", false);
23170
+ _defineProperty(this, "_pendingBarDeltaX", 0);
23171
+ _defineProperty(this, "_pendingBarDeltaY", 0);
23172
+ _defineProperty(this, "_pendingBarScrollFrameId", null);
23173
+ _defineProperty(this, "_pendingBarScrollThrottleId", null);
22503
23174
  _defineProperty(this, "_horizonPointerMoveSub", void 0);
22504
23175
  _defineProperty(this, "_horizonPointerUpSub", void 0);
22505
23176
  _defineProperty(this, "_verticalPointerMoveSub", void 0);
@@ -22637,6 +23308,7 @@ var ScrollBar = class ScrollBar extends Disposable {
22637
23308
  dispose() {
22638
23309
  var _this$horizonScrollTr, _this$horizonThumbRec3, _this$verticalScrollT, _this$verticalThumbRe3, _this$placeholderBarR, _this$_horizonPointer, _this$_horizonPointer2, _this$_verticalPointe, _this$_verticalPointe2;
22639
23310
  super.dispose();
23311
+ this._flushPendingBarScroll();
22640
23312
  (_this$horizonScrollTr = this.horizonScrollTrack) === null || _this$horizonScrollTr === void 0 || _this$horizonScrollTr.dispose();
22641
23313
  (_this$horizonThumbRec3 = this.horizonThumbRect) === null || _this$horizonThumbRec3 === void 0 || _this$horizonThumbRec3.dispose();
22642
23314
  (_this$verticalScrollT = this.verticalScrollTrack) === null || _this$verticalScrollT === void 0 || _this$verticalScrollT.dispose();
@@ -22655,6 +23327,47 @@ var ScrollBar = class ScrollBar extends Disposable {
22655
23327
  this._mainScene = null;
22656
23328
  this._viewport.removeScrollBar();
22657
23329
  }
23330
+ _scheduleBarScrollDelta(delta) {
23331
+ var _delta$x, _delta$y;
23332
+ this._pendingBarDeltaX += (_delta$x = delta.x) !== null && _delta$x !== void 0 ? _delta$x : 0;
23333
+ this._pendingBarDeltaY += (_delta$y = delta.y) !== null && _delta$y !== void 0 ? _delta$y : 0;
23334
+ if (this._pendingBarScrollFrameId !== null || this._pendingBarScrollThrottleId !== null) return;
23335
+ this._requestPendingBarScrollFrame();
23336
+ }
23337
+ _requestPendingBarScrollFrame() {
23338
+ this._pendingBarScrollFrameId = requestAnimationFrame(() => {
23339
+ this._pendingBarScrollFrameId = null;
23340
+ this._applyPendingBarScroll({ isBarDragging: true });
23341
+ if (!this._isHorizonMove && !this._isVerticalMove) return;
23342
+ this._pendingBarScrollThrottleId = window.setTimeout(() => {
23343
+ this._pendingBarScrollThrottleId = null;
23344
+ if (this._pendingBarDeltaX !== 0 || this._pendingBarDeltaY !== 0) this._requestPendingBarScrollFrame();
23345
+ }, BAR_DRAG_SCROLL_THROTTLE_MS);
23346
+ });
23347
+ }
23348
+ _flushPendingBarScroll(isBarDragEnd = false) {
23349
+ if (this._pendingBarScrollFrameId !== null) {
23350
+ cancelAnimationFrame(this._pendingBarScrollFrameId);
23351
+ this._pendingBarScrollFrameId = null;
23352
+ }
23353
+ if (this._pendingBarScrollThrottleId !== null) {
23354
+ clearTimeout(this._pendingBarScrollThrottleId);
23355
+ this._pendingBarScrollThrottleId = null;
23356
+ }
23357
+ return this._applyPendingBarScroll({ isBarDragEnd });
23358
+ }
23359
+ _applyPendingBarScroll(options) {
23360
+ const x = this._pendingBarDeltaX;
23361
+ const y = this._pendingBarDeltaY;
23362
+ if (x === 0 && y === 0) return false;
23363
+ this._pendingBarDeltaX = 0;
23364
+ this._pendingBarDeltaY = 0;
23365
+ this._viewport.scrollByBarDeltaValue({
23366
+ ...x === 0 ? null : { x },
23367
+ ...y === 0 ? null : { y }
23368
+ }, true, options);
23369
+ return true;
23370
+ }
22658
23371
  render(ctx, left = 0, top = 0) {
22659
23372
  const { scrollX, scrollY } = this._viewport;
22660
23373
  ctx.save();
@@ -22859,12 +23572,14 @@ var ScrollBar = class ScrollBar extends Disposable {
22859
23572
  var _mainScene$getEngine;
22860
23573
  const e = evt;
22861
23574
  if (!this._isVerticalMove) return;
22862
- this._viewport.scrollByBarDeltaValue({ y: e.offsetY - this._lastY });
23575
+ this._scheduleBarScrollDelta({ y: e.offsetY - this._lastY });
22863
23576
  this._lastY = e.offsetY;
22864
23577
  (_mainScene$getEngine = mainScene.getEngine()) === null || _mainScene$getEngine === void 0 || _mainScene$getEngine.setCapture();
22865
23578
  });
22866
23579
  this._verticalPointerUpSub = mainScene.onPointerUp$.subscribeEvent((_evt, _state) => {
23580
+ if (!this._isVerticalMove) return;
22867
23581
  const srcElement = this.verticalThumbRect;
23582
+ if (!this._flushPendingBarScroll(true)) this._viewport.scrollByBarDeltaValue({ y: 0 }, true, { isBarDragEnd: true });
22868
23583
  this._isVerticalMove = false;
22869
23584
  mainScene.releaseCapturedObject();
22870
23585
  mainScene.enableObjectsEvent();
@@ -22933,12 +23648,14 @@ var ScrollBar = class ScrollBar extends Disposable {
22933
23648
  var _mainScene$getEngine2;
22934
23649
  const e = evt;
22935
23650
  if (!this._isHorizonMove) return;
22936
- this._viewport.scrollByBarDeltaValue({ x: e.offsetX - this._lastX });
23651
+ this._scheduleBarScrollDelta({ x: e.offsetX - this._lastX });
22937
23652
  this._lastX = e.offsetX;
22938
23653
  (_mainScene$getEngine2 = mainScene.getEngine()) === null || _mainScene$getEngine2 === void 0 || _mainScene$getEngine2.setCapture();
22939
23654
  });
22940
23655
  this._horizonPointerUpSub = mainScene.onPointerUp$.subscribeEvent((evt, state) => {
22941
23656
  var _this$horizonThumbRec11;
23657
+ if (!this._isHorizonMove) return;
23658
+ if (!this._flushPendingBarScroll(true)) this._viewport.scrollByBarDeltaValue({ x: 0 }, true, { isBarDragEnd: true });
22942
23659
  this._isHorizonMove = false;
22943
23660
  mainScene.releaseCapturedObject();
22944
23661
  mainScene.enableObjectsEvent();
@@ -22972,6 +23689,7 @@ var FontAndBaseLine = class extends docExtension {
22972
23689
  {}
22973
23690
  );
22974
23691
  _defineProperty(this, "_textFillImageCache", /* @__PURE__ */ new Map());
23692
+ _defineProperty(this, "_textFillImageLoadListeners", /* @__PURE__ */ new Map());
22975
23693
  }
22976
23694
  draw(ctx, _parentScale, glyph, _, _more) {
22977
23695
  var _glyph$parent;
@@ -23097,10 +23815,32 @@ var FontAndBaseLine = class extends docExtension {
23097
23815
  return pattern;
23098
23816
  }
23099
23817
  _getTextFillImage(source) {
23818
+ var _this$parent;
23819
+ const onTextFillImageLoaded = (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.onTextFillImageLoaded;
23100
23820
  const cached = this._textFillImageCache.get(source);
23101
- if (cached) return cached;
23821
+ if (cached) {
23822
+ if (!cached.complete && onTextFillImageLoaded) {
23823
+ var _this$_textFillImageL;
23824
+ (_this$_textFillImageL = this._textFillImageLoadListeners.get(source)) === null || _this$_textFillImageL === void 0 || _this$_textFillImageL.add(onTextFillImageLoaded);
23825
+ }
23826
+ return cached;
23827
+ }
23102
23828
  const image = new Image();
23103
- image.crossOrigin = "anonymous";
23829
+ const listeners = /* @__PURE__ */ new Set();
23830
+ if (onTextFillImageLoaded) listeners.add(onTextFillImageLoaded);
23831
+ this._textFillImageLoadListeners.set(source, listeners);
23832
+ image.onload = () => {
23833
+ image.onload = null;
23834
+ image.onerror = null;
23835
+ const loadListeners = this._textFillImageLoadListeners.get(source);
23836
+ this._textFillImageLoadListeners.delete(source);
23837
+ loadListeners === null || loadListeners === void 0 || loadListeners.forEach((listener) => listener());
23838
+ };
23839
+ image.onerror = () => {
23840
+ image.onload = null;
23841
+ image.onerror = null;
23842
+ this._textFillImageLoadListeners.delete(source);
23843
+ };
23104
23844
  image.src = source;
23105
23845
  this._textFillImageCache.set(source, image);
23106
23846
  return image.complete ? image : null;
@@ -23154,7 +23894,7 @@ var FontAndBaseLine = class extends docExtension {
23154
23894
  const { vertexAngle, centerAngle } = renderConfig !== null && renderConfig !== void 0 ? renderConfig : {};
23155
23895
  const VERTICAL_DEG = 90;
23156
23896
  const isVertical = vertexAngle === VERTICAL_DEG && centerAngle === VERTICAL_DEG;
23157
- if (isVertical && !hasCJK(content)) {
23897
+ if (isVertical && !cjk.hasCJK(content)) {
23158
23898
  ctx.save();
23159
23899
  ctx.translate(spanStartPoint.x + centerPoint.x, spanStartPoint.y + centerPoint.y);
23160
23900
  ctx.rotate(Math.PI / 2);
@@ -23676,7 +24416,7 @@ var Documents = class Documents extends DocComponent {
23676
24416
  ctx.restore();
23677
24417
  }
23678
24418
  _drawBorderBottom(ctx, page, line, left = 0, top = 0) {
23679
- var _line$borderBottom$pa, _line$borderBottom, _line$borderBottom$co, _line$borderBottom2;
24419
+ var _line$borderBottom$pa, _line$borderBottom, _border$width, _border$color$rgb;
23680
24420
  if (this._drawLiquid == null) return;
23681
24421
  let { x, y } = this._drawLiquid;
23682
24422
  const { pageWidth, marginLeft, marginRight, marginTop } = page;
@@ -23685,8 +24425,10 @@ var Documents = class Documents extends DocComponent {
23685
24425
  y -= line.paddingTop;
23686
24426
  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);
23687
24427
  ctx.save();
23688
- ctx.setLineWidthByPrecision(1);
23689
- 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";
24428
+ const border = line.borderBottom;
24429
+ ctx.setLineWidthByPrecision(Math.max(0, (_border$width = border === null || border === void 0 ? void 0 : border.width) !== null && _border$width !== void 0 ? _border$width : 1));
24430
+ 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";
24431
+ setDocsBorderDash(ctx, border === null || border === void 0 ? void 0 : border.dashStyle);
23690
24432
  drawLineByBorderType(ctx, "b", 0, {
23691
24433
  startX: x,
23692
24434
  startY: y,
@@ -23848,21 +24590,21 @@ var Documents = class Documents extends DocComponent {
23848
24590
  return DEFAULT_BORDER_COLOR;
23849
24591
  }
23850
24592
  _isDrawableTableCellBorder(border) {
23851
- var _border$width$v, _border$width, _border$color$rgb, _border$color;
24593
+ var _border$width$v, _border$width2, _border$color$rgb2, _border$color;
23852
24594
  if (!border) return false;
23853
- 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;
23854
- 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;
24595
+ 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;
24596
+ 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;
23855
24597
  return lineWidth > 0 && color !== "transparent";
23856
24598
  }
23857
24599
  _drawTableCellBorder(ctx, border, type, position) {
23858
- var _border$width$v2, _border$width2, _border$color$rgb2, _border$color2;
24600
+ var _border$width$v2, _border$width3, _border$color$rgb3, _border$color2;
23859
24601
  if (!border) return;
23860
- 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;
23861
- 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;
24602
+ 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;
24603
+ 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;
23862
24604
  if (lineWidth <= 0 || color === "transparent") return;
23863
24605
  ctx.save();
23864
24606
  ctx.setLineWidthByPrecision(lineWidth);
23865
- setTableCellBorderDash(ctx, border.dashStyle);
24607
+ setDocsBorderDash(ctx, border.dashStyle);
23866
24608
  ctx.strokeStyle = color;
23867
24609
  drawLineByBorderType(ctx, type, 0, position);
23868
24610
  ctx.restore();
@@ -23992,7 +24734,7 @@ var Documents = class Documents extends DocComponent {
23992
24734
  });
23993
24735
  }
23994
24736
  };
23995
- function setTableCellBorderDash(ctx, dashStyle) {
24737
+ function setDocsBorderDash(ctx, dashStyle) {
23996
24738
  if (dashStyle === DashStyleType.DOT) {
23997
24739
  ctx.setLineDash([2]);
23998
24740
  return;
@@ -24038,6 +24780,85 @@ function rectByPrecisionBounds(ctx, x, y, width, height) {
24038
24780
  //#endregion
24039
24781
  //#region src/components/sheets/spreadsheet.ts
24040
24782
  const OBJECT_KEY = "__SHEET_EXTENSION_FONT_DOCUMENT_INSTANCE__";
24783
+ function pushSparseCellRange(ranges, row, col) {
24784
+ const last = ranges[ranges.length - 1];
24785
+ if (last && last.startRow === row && last.endRow === row && last.endColumn + 1 === col) {
24786
+ last.endColumn = col;
24787
+ return;
24788
+ }
24789
+ ranges.push({
24790
+ startRow: row,
24791
+ endRow: row,
24792
+ startColumn: col,
24793
+ endColumn: col
24794
+ });
24795
+ }
24796
+ function scanSparseExtensionFeatures(spreadsheetSkeleton, ranges) {
24797
+ const { worksheet } = spreadsheetSkeleton;
24798
+ if (!worksheet || !ranges.length || worksheet.getMergeData().length > 0) return null;
24799
+ const flags = {
24800
+ hasCustomRender: false,
24801
+ hasMarkers: false,
24802
+ hasSelectionProtection: false,
24803
+ customRenderRanges: [],
24804
+ markerRanges: [],
24805
+ selectionProtectionRanges: []
24806
+ };
24807
+ for (const range of ranges) for (let row = range.startRow; row <= range.endRow; row++) {
24808
+ if (!worksheet.getRowVisible(row)) continue;
24809
+ for (let col = range.startColumn; col <= range.endColumn; col++) {
24810
+ var _spreadsheetSkeleton$, _cell$customRender, _cell$selectionProtec;
24811
+ if (!worksheet.getColVisible(col)) continue;
24812
+ const cachedCell = (_spreadsheetSkeleton$ = spreadsheetSkeleton.stylesCache.fontMatrix.getValue(row, col)) === null || _spreadsheetSkeleton$ === void 0 ? void 0 : _spreadsheetSkeleton$.cellData;
24813
+ const cell = cachedCell !== null && cachedCell !== void 0 ? cachedCell : worksheet.getCell(row, col);
24814
+ if (!cell) continue;
24815
+ if ((_cell$customRender = cell.customRender) === null || _cell$customRender === void 0 ? void 0 : _cell$customRender.length) {
24816
+ flags.hasCustomRender = true;
24817
+ pushSparseCellRange(flags.customRenderRanges, row, col);
24818
+ }
24819
+ if (cell.markers) {
24820
+ flags.hasMarkers = true;
24821
+ pushSparseCellRange(flags.markerRanges, row, col);
24822
+ }
24823
+ if ((_cell$selectionProtec = cell.selectionProtection) === null || _cell$selectionProtec === void 0 ? void 0 : _cell$selectionProtec.length) {
24824
+ flags.hasSelectionProtection = true;
24825
+ pushSparseCellRange(flags.selectionProtectionRanges, row, col);
24826
+ }
24827
+ }
24828
+ }
24829
+ return flags;
24830
+ }
24831
+ function shouldSkipSparseExtension(uKey, flags) {
24832
+ if (!flags) return false;
24833
+ switch (uKey) {
24834
+ case "DefaultCustomExtension": return !flags.hasCustomRender;
24835
+ case "DefaultMarkerExtension": return !flags.hasMarkers;
24836
+ case "RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY":
24837
+ case "RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY": return !flags.hasSelectionProtection;
24838
+ default: return false;
24839
+ }
24840
+ }
24841
+ function hasSparseExtension(extensions) {
24842
+ return extensions.some((extension) => {
24843
+ switch (extension.uKey) {
24844
+ case "DefaultCustomExtension":
24845
+ case "DefaultMarkerExtension":
24846
+ case "RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY":
24847
+ case "RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY": return true;
24848
+ default: return false;
24849
+ }
24850
+ });
24851
+ }
24852
+ function getSparseExtensionDiffRanges(uKey, flags, diffRanges) {
24853
+ if (!flags) return diffRanges;
24854
+ switch (uKey) {
24855
+ case "DefaultCustomExtension": return flags.customRenderRanges;
24856
+ case "DefaultMarkerExtension": return flags.markerRanges;
24857
+ case "RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY":
24858
+ case "RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY": return flags.selectionProtectionRanges;
24859
+ default: return diffRanges;
24860
+ }
24861
+ }
24041
24862
  var Spreadsheet = class extends SheetComponent {
24042
24863
  constructor(oKey, spreadsheetSkeleton, _allowCache = true) {
24043
24864
  super(oKey, spreadsheetSkeleton);
@@ -24092,7 +24913,8 @@ var Spreadsheet = class extends SheetComponent {
24092
24913
  var _viewportInfo$diffBou;
24093
24914
  const spreadsheetSkeleton = this.getSkeleton();
24094
24915
  if (!spreadsheetSkeleton) return;
24095
- this._drawAuxiliary(ctx);
24916
+ const hasMergeData = spreadsheetSkeleton.worksheet.getMergeData().length > 0;
24917
+ this._drawAuxiliary(ctx, hasMergeData);
24096
24918
  const parentScale = this.getParentScale();
24097
24919
  const diffRanges = this._refreshIncrementalState && viewportInfo.diffBounds ? (_viewportInfo$diffBou = viewportInfo.diffBounds) === null || _viewportInfo$diffBou === void 0 ? void 0 : _viewportInfo$diffBou.map((bound) => spreadsheetSkeleton.getRangeByViewBound(bound)) : [];
24098
24920
  const cacheRange = spreadsheetSkeleton.getCacheRangeByViewport(viewportInfo, this.isPrinting);
@@ -24103,14 +24925,19 @@ var Spreadsheet = class extends SheetComponent {
24103
24925
  endColumn: cacheRange.endColumn
24104
24926
  })) : viewRanges;
24105
24927
  const extensions = this.getExtensionsByOrder();
24928
+ const sparseExtensionFeatures = !hasMergeData && hasSparseExtension(extensions) ? scanSparseExtensionFeatures(spreadsheetSkeleton, viewRanges) : null;
24106
24929
  const scene = this.getScene();
24107
24930
  for (const extension of extensions) {
24931
+ if (shouldSkipSparseExtension(extension.uKey, sparseExtensionFeatures)) continue;
24108
24932
  const extensionViewRanges = extension === this._fontExtension || extension === this._borderExtension ? overflowSafeViewRanges : viewRanges;
24933
+ const extensionDiffRanges = getSparseExtensionDiffRanges(extension.uKey, sparseExtensionFeatures, diffRanges);
24109
24934
  const timeKey = `${SHEET_EXTENSION_PREFIX}${extension.uKey}`;
24110
24935
  const st = Tools.now();
24111
- extension.draw(ctx, parentScale, spreadsheetSkeleton, diffRanges, {
24936
+ extension.draw(ctx, parentScale, spreadsheetSkeleton, extensionDiffRanges, {
24112
24937
  viewRanges: extensionViewRanges,
24113
24938
  checkOutOfViewBound: true,
24939
+ fontRenderRanges: extension === this._fontExtension ? spreadsheetSkeleton.incrementalFontRenderRanges : void 0,
24940
+ hasMergeData,
24114
24941
  viewportKey: viewportInfo.viewportKey,
24115
24942
  viewBound: viewportInfo.cacheBound,
24116
24943
  diffBounds: viewportInfo.diffBounds
@@ -24208,7 +25035,7 @@ var Spreadsheet = class extends SheetComponent {
24208
25035
  this._dirtyBounds = dirtyBounds;
24209
25036
  }
24210
25037
  renderByViewports(mainCtx, viewportInfo, spreadsheetSkeleton) {
24211
- const { diffBounds, diffX, diffY, viewPortPosition, cacheCanvas, leftOrigin, topOrigin, bufferEdgeX, bufferEdgeY, isDirty: isViewportDirty, isForceDirty: isViewportForceDirty } = viewportInfo;
25038
+ const { diffBounds, diffX, diffY, viewPortPosition, cacheCanvas, leftOrigin, topOrigin, bufferEdgeX, bufferEdgeY, isDirty: isViewportDirty, isForceDirty: isViewportForceDirty, shouldCacheUpdate } = viewportInfo;
24212
25039
  const { rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = spreadsheetSkeleton;
24213
25040
  const { a: scaleX = 1, d: scaleY = 1 } = mainCtx.getTransform();
24214
25041
  const bufferEdgeSizeX = bufferEdgeX * scaleX / window.devicePixelRatio;
@@ -24217,8 +25044,10 @@ var Spreadsheet = class extends SheetComponent {
24217
25044
  cacheCtx.save();
24218
25045
  const isForceDirty = isViewportForceDirty || this.isForceDirty();
24219
25046
  const isDirty = isViewportDirty || this.isDirty();
24220
- const isScrollJumpOutsideCache = Math.abs(diffX) * scaleX >= cacheCanvas.getWidth() || Math.abs(diffY) * scaleY >= cacheCanvas.getHeight();
24221
- const shouldRefreshCache = isDirty || isForceDirty || isScrollJumpOutsideCache;
25047
+ const cachePixelRatio = cacheCanvas.getPixelRatio();
25048
+ const isScrollJumpOutsideCache = Math.abs(diffX) * scaleX >= cacheCanvas.getWidth() * cachePixelRatio || Math.abs(diffY) * scaleY >= cacheCanvas.getHeight() * cachePixelRatio;
25049
+ const hasMergeData = spreadsheetSkeleton.worksheet.getMergeData().length > 0;
25050
+ const shouldRefreshCache = isDirty || isForceDirty || isScrollJumpOutsideCache || hasMergeData && (diffX !== 0 || diffY !== 0) || shouldCacheUpdate && diffX !== 0;
24222
25051
  if (diffBounds.length === 0 || diffX === 0 && diffY === 0 || shouldRefreshCache) {
24223
25052
  if (shouldRefreshCache) {
24224
25053
  this.addRenderTagToScene("scrolling", false);
@@ -24312,6 +25141,8 @@ var Spreadsheet = class extends SheetComponent {
24312
25141
  }
24313
25142
  const spreadsheetSkeleton = this.getSkeleton();
24314
25143
  if (!spreadsheetSkeleton) return;
25144
+ const { viewportKey } = viewportInfo;
25145
+ if (sheetHeaderViewportKeys.includes(viewportKey)) return this;
24315
25146
  spreadsheetSkeleton.setStylesCache(viewportInfo);
24316
25147
  const segment = spreadsheetSkeleton.rowColumnSegment;
24317
25148
  if (!segment) return;
@@ -24320,10 +25151,9 @@ var Spreadsheet = class extends SheetComponent {
24320
25151
  const { rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = spreadsheetSkeleton;
24321
25152
  mainCtx.translateWithPrecision(rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop);
24322
25153
  (_this$getScene = this.getScene()) === null || _this$getScene === void 0 || _this$getScene.updateTransformerZero(rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop);
24323
- const { viewportKey } = viewportInfo;
24324
25154
  if (sheetContentViewportKeys.includes(viewportKey)) if (viewportInfo && viewportInfo.cacheCanvas) this.renderByViewports(mainCtx, viewportInfo, spreadsheetSkeleton);
24325
25155
  else this._draw(mainCtx, viewportInfo);
24326
- else if (sheetHeaderViewportKeys.includes(viewportKey)) {} else if (viewportInfo && viewportInfo.cacheCanvas) this.renderByViewports(mainCtx, viewportInfo, spreadsheetSkeleton);
25156
+ else if (viewportInfo && viewportInfo.cacheCanvas) this.renderByViewports(mainCtx, viewportInfo, spreadsheetSkeleton);
24327
25157
  else this._draw(mainCtx, viewportInfo);
24328
25158
  mainCtx.restore();
24329
25159
  return this;
@@ -24391,7 +25221,7 @@ var Spreadsheet = class extends SheetComponent {
24391
25221
  * draw gridlines
24392
25222
  * @param ctx
24393
25223
  */
24394
- _drawAuxiliary(ctx) {
25224
+ _drawAuxiliary(ctx, hasMergeData = true) {
24395
25225
  var _ref;
24396
25226
  const spreadsheetSkeleton = this.getSkeleton();
24397
25227
  if (spreadsheetSkeleton == null) return;
@@ -24433,22 +25263,24 @@ var Spreadsheet = class extends SheetComponent {
24433
25263
  const mergeVisibleRanges = [];
24434
25264
  let mergeVisibleRangeStartRow = startRow;
24435
25265
  for (let r = rowStart; r <= rowEnd; r++) {
24436
- if (worksheet.getRowVisible(r) === false) {
24437
- if (mergeVisibleRangeStartRow < r) {
24438
- mergeVisibleRanges.push({
24439
- startRow: mergeVisibleRangeStartRow,
24440
- endRow: r - 1,
24441
- startColumn,
24442
- endColumn
24443
- });
24444
- mergeVisibleRangeStartRow = r + 1;
24445
- } else if (mergeVisibleRangeStartRow === r) mergeVisibleRangeStartRow = r + 1;
24446
- } else if (r === endRow && mergeVisibleRangeStartRow <= r) mergeVisibleRanges.push({
24447
- startRow: mergeVisibleRangeStartRow,
24448
- endRow: r,
24449
- startColumn,
24450
- endColumn
24451
- });
25266
+ if (hasMergeData) {
25267
+ if (worksheet.getRowVisible(r) === false) {
25268
+ if (mergeVisibleRangeStartRow < r) {
25269
+ mergeVisibleRanges.push({
25270
+ startRow: mergeVisibleRangeStartRow,
25271
+ endRow: r - 1,
25272
+ startColumn,
25273
+ endColumn
25274
+ });
25275
+ mergeVisibleRangeStartRow = r + 1;
25276
+ } else if (mergeVisibleRangeStartRow === r) mergeVisibleRangeStartRow = r + 1;
25277
+ } else if (r === endRow && mergeVisibleRangeStartRow <= r) mergeVisibleRanges.push({
25278
+ startRow: mergeVisibleRangeStartRow,
25279
+ endRow: r,
25280
+ startColumn,
25281
+ endColumn
25282
+ });
25283
+ }
24452
25284
  if (r < 0 || r > rowHeightAccumulationLength - 1) continue;
24453
25285
  const rowEndPosition = rowHeightAccumulation[r];
24454
25286
  ctx.beginPath();
@@ -24467,7 +25299,7 @@ var Spreadsheet = class extends SheetComponent {
24467
25299
  ctx.stroke();
24468
25300
  }
24469
25301
  const mergeCellRanges = [];
24470
- for (const mergeVisibleRange of mergeVisibleRanges) {
25302
+ if (hasMergeData) for (const mergeVisibleRange of mergeVisibleRanges) {
24471
25303
  const mergeRangeInVisible = spreadsheetSkeleton.getCurrentRowColumnSegmentMergeData(mergeVisibleRange);
24472
25304
  mergeCellRanges.push(...mergeRangeInVisible);
24473
25305
  }
@@ -25406,6 +26238,164 @@ var DocBackground = class DocBackground extends DocComponent {
25406
26238
  }
25407
26239
  };
25408
26240
 
26241
+ //#endregion
26242
+ //#region src/components/docs/layout/doc-no-wrap-measure.ts
26243
+ function splitDocumentNoWrapMeasureLines(text) {
26244
+ return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
26245
+ }
26246
+ function isDocumentNoWrapMeasureTrailingWhitespace(char) {
26247
+ return char === " " || char === " " || char === "\xA0";
26248
+ }
26249
+ function getDocumentNoWrapMeasureTrailingWhitespaceStart(text) {
26250
+ let index = text.length;
26251
+ while (index > 0 && isDocumentNoWrapMeasureTrailingWhitespace(text[index - 1])) index--;
26252
+ return index;
26253
+ }
26254
+ function isDocumentNoWrapMeasureCJKText(char) {
26255
+ return /[\u2E80-\u9FFF\uF900-\uFAFF]/u.test(char);
26256
+ }
26257
+ function isDocumentNoWrapMeasureLatinText(char) {
26258
+ return /[a-z\d]/i.test(char);
26259
+ }
26260
+ function measureDocumentNoWrapTextByStyle(text, textStyle) {
26261
+ if (!text) return 0;
26262
+ return FontCache.getMeasureText(text, getFontStyleString(textStyle).fontCache).width;
26263
+ }
26264
+ function measureDocumentNoWrapCJKLatinSpacing(segment, textStyle, previous) {
26265
+ let spacing = 0;
26266
+ for (const char of Array.from(segment)) {
26267
+ const isCJK = isDocumentNoWrapMeasureCJKText(char);
26268
+ const cjkWidth = isCJK ? measureDocumentNoWrapTextByStyle(char, textStyle) : 0;
26269
+ if (isCJK && isDocumentNoWrapMeasureLatinText(previous.char)) spacing += cjkWidth / 4;
26270
+ if (isDocumentNoWrapMeasureLatinText(char) && isDocumentNoWrapMeasureCJKText(previous.char)) spacing += previous.cjkWidth / 4;
26271
+ previous.char = char;
26272
+ previous.cjkWidth = cjkWidth;
26273
+ }
26274
+ return spacing;
26275
+ }
26276
+ function measureDocumentNoWrapLineByStyle(text, textStyle) {
26277
+ const visibleText = text.slice(0, getDocumentNoWrapMeasureTrailingWhitespaceStart(text));
26278
+ return measureDocumentNoWrapTextByStyle(visibleText, textStyle) + measureDocumentNoWrapCJKLatinSpacing(visibleText, textStyle, {
26279
+ char: "",
26280
+ cjkWidth: 0
26281
+ });
26282
+ }
26283
+ function measureDocumentNoWrapRunsWidth(dataStream, textRuns, fallbackTextStyle) {
26284
+ let currentLineWidth = 0;
26285
+ let maxLineWidth = 0;
26286
+ let pendingTrailingWhitespaceWidth = 0;
26287
+ const previous = {
26288
+ char: "",
26289
+ cjkWidth: 0
26290
+ };
26291
+ const appendSegment = (segment, textStyle) => {
26292
+ if (!segment) return;
26293
+ const trailingStart = getDocumentNoWrapMeasureTrailingWhitespaceStart(segment);
26294
+ const visibleSegment = segment.slice(0, trailingStart);
26295
+ const trailingWhitespace = segment.slice(trailingStart);
26296
+ if (visibleSegment) {
26297
+ currentLineWidth += pendingTrailingWhitespaceWidth;
26298
+ pendingTrailingWhitespaceWidth = 0;
26299
+ currentLineWidth += measureDocumentNoWrapTextByStyle(visibleSegment, textStyle);
26300
+ currentLineWidth += measureDocumentNoWrapCJKLatinSpacing(visibleSegment, textStyle, previous);
26301
+ }
26302
+ if (trailingWhitespace) {
26303
+ pendingTrailingWhitespaceWidth += measureDocumentNoWrapTextByStyle(trailingWhitespace, textStyle);
26304
+ measureDocumentNoWrapCJKLatinSpacing(trailingWhitespace, textStyle, previous);
26305
+ }
26306
+ };
26307
+ const finishLine = () => {
26308
+ maxLineWidth = Math.max(maxLineWidth, currentLineWidth);
26309
+ currentLineWidth = 0;
26310
+ pendingTrailingWhitespaceWidth = 0;
26311
+ previous.char = "";
26312
+ previous.cjkWidth = 0;
26313
+ };
26314
+ const appendRange = (text, textStyle) => {
26315
+ splitDocumentNoWrapMeasureLines(text).forEach((segment, index) => {
26316
+ if (index > 0) finishLine();
26317
+ appendSegment(segment, textStyle);
26318
+ });
26319
+ };
26320
+ let cursor = 0;
26321
+ [...textRuns].sort((a, b) => a.st - b.st).forEach((run) => {
26322
+ const start = Math.max(0, run.st);
26323
+ const end = Math.max(start, run.ed);
26324
+ if (start > cursor) appendRange(dataStream.slice(cursor, start), fallbackTextStyle);
26325
+ const effectiveStart = Math.max(start, cursor);
26326
+ if (end > effectiveStart) appendRange(dataStream.slice(effectiveStart, end), run.ts);
26327
+ cursor = Math.max(cursor, end);
26328
+ });
26329
+ if (cursor < dataStream.length) appendRange(dataStream.slice(cursor), fallbackTextStyle);
26330
+ return Math.max(maxLineWidth, currentLineWidth);
26331
+ }
26332
+ function measureDocumentNoWrapTextRangeWidth(documentData, start, end) {
26333
+ var _body$dataStream, _body$textRuns, _documentData$documen2;
26334
+ const body = documentData.body;
26335
+ const dataStream = (_body$dataStream = body === null || body === void 0 ? void 0 : body.dataStream) !== null && _body$dataStream !== void 0 ? _body$dataStream : "";
26336
+ const rangeStart = Math.max(0, Math.min(dataStream.length, start));
26337
+ const rangeEnd = Math.max(rangeStart, Math.min(dataStream.length, end));
26338
+ const rangeText = dataStream.slice(rangeStart, rangeEnd);
26339
+ const textRuns = ((_body$textRuns = body === null || body === void 0 ? void 0 : body.textRuns) !== null && _body$textRuns !== void 0 ? _body$textRuns : []).map((run) => {
26340
+ const runStart = Math.max(rangeStart, run.st);
26341
+ const runEnd = Math.min(rangeEnd, run.ed);
26342
+ if (runEnd <= runStart) return null;
26343
+ return {
26344
+ ...run,
26345
+ st: runStart - rangeStart,
26346
+ ed: runEnd - rangeStart
26347
+ };
26348
+ }).filter((run) => run !== null);
26349
+ if (textRuns.length) {
26350
+ var _documentData$documen;
26351
+ return measureDocumentNoWrapRunsWidth(rangeText, textRuns, (_documentData$documen = documentData.documentStyle) === null || _documentData$documen === void 0 ? void 0 : _documentData$documen.textStyle);
26352
+ }
26353
+ return measureDocumentNoWrapLineByStyle(rangeText, (_documentData$documen2 = documentData.documentStyle) === null || _documentData$documen2 === void 0 ? void 0 : _documentData$documen2.textStyle);
26354
+ }
26355
+ /**
26356
+ * Measures the widest no-wrap line using the same text-width policy that docs
26357
+ * layout relies on for lightweight shape/text-box autofit flows.
26358
+ *
26359
+ * This is intentionally not a full document layout replacement: callers that
26360
+ * need line breaking, pagination, floating objects, or final line metrics should
26361
+ * use `DocumentSkeleton`. This helper exists for consumers that must size a
26362
+ * no-wrap host before committing a full layout pass. Keep docs-specific glyph
26363
+ * width adjustments here so feature packages do not duplicate paragraph shaping
26364
+ * details such as CJK-Latin spacing.
26365
+ */
26366
+ function measureDocumentNoWrapTextWidth(documentData) {
26367
+ var _body$dataStream2, _documentData$documen4;
26368
+ const body = documentData === null || documentData === void 0 ? void 0 : documentData.body;
26369
+ const dataStream = (_body$dataStream2 = body === null || body === void 0 ? void 0 : body.dataStream) !== null && _body$dataStream2 !== void 0 ? _body$dataStream2 : "";
26370
+ const textRuns = body === null || body === void 0 ? void 0 : body.textRuns;
26371
+ if (textRuns === null || textRuns === void 0 ? void 0 : textRuns.length) {
26372
+ var _documentData$documen3;
26373
+ return measureDocumentNoWrapRunsWidth(dataStream, textRuns, documentData === null || documentData === void 0 || (_documentData$documen3 = documentData.documentStyle) === null || _documentData$documen3 === void 0 ? void 0 : _documentData$documen3.textStyle);
26374
+ }
26375
+ const fallbackTextStyle = documentData === null || documentData === void 0 || (_documentData$documen4 = documentData.documentStyle) === null || _documentData$documen4 === void 0 ? void 0 : _documentData$documen4.textStyle;
26376
+ return Math.max(0, ...splitDocumentNoWrapMeasureLines(dataStream).map((line) => measureDocumentNoWrapLineByStyle(line, fallbackTextStyle)));
26377
+ }
26378
+ /**
26379
+ * Measures the widest segment that docs line breaking keeps together. This is
26380
+ * useful when a host may wrap normally but still needs enough width to avoid
26381
+ * clipping an individual word, CJK glyph, or punctuation segment.
26382
+ */
26383
+ function measureDocumentUnbreakableTextWidth(documentData) {
26384
+ var _documentData$body$da, _documentData$body;
26385
+ 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 : "";
26386
+ if (!documentData || !dataStream) return 0;
26387
+ const breaker = new LineBreaker(dataStream);
26388
+ let start = 0;
26389
+ let maxWidth = 0;
26390
+ let breakPoint = breaker.nextBreakPoint();
26391
+ while (breakPoint) {
26392
+ maxWidth = Math.max(maxWidth, measureDocumentNoWrapTextRangeWidth(documentData, start, breakPoint.position));
26393
+ start = breakPoint.position;
26394
+ breakPoint = breaker.nextBreakPoint();
26395
+ }
26396
+ return maxWidth;
26397
+ }
26398
+
25409
26399
  //#endregion
25410
26400
  //#region src/custom/custom-object.ts
25411
26401
  var CustomObject = class extends BaseObject {
@@ -25617,6 +26607,11 @@ var DrawingGroupObject = class extends Group {
25617
26607
  width: 0,
25618
26608
  height: 0
25619
26609
  });
26610
+ _defineProperty(this, "_outerShadow", void 0);
26611
+ }
26612
+ setOuterShadow(shadow) {
26613
+ this._outerShadow = shadow;
26614
+ this.makeDirty(true);
25620
26615
  }
25621
26616
  /**
25622
26617
  * Set the baseBound (chOff/chExt in OOXML) for this group.
@@ -25664,6 +26659,12 @@ var DrawingGroupObject = class extends Group {
25664
26659
  const centerX = realLeft + realWidth / 2;
25665
26660
  const centerY = realTop + realHeight / 2;
25666
26661
  ctx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
26662
+ if (this._outerShadow) {
26663
+ ctx.shadowColor = this._outerShadow.shadowColor;
26664
+ ctx.shadowBlur = this._outerShadow.shadowBlur;
26665
+ ctx.shadowOffsetX = this._outerShadow.shadowOffsetX;
26666
+ ctx.shadowOffsetY = this._outerShadow.shadowOffsetY;
26667
+ }
25667
26668
  const objects = this.getObjectsByOrder();
25668
26669
  for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
25669
26670
  ctx.restore();
@@ -26600,7 +27601,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
26600
27601
  //#endregion
26601
27602
  //#region package.json
26602
27603
  var name = "@univerjs/engine-render";
26603
- var version = "1.0.0-alpha.2";
27604
+ var version = "1.0.0-alpha.4";
26604
27605
 
26605
27606
  //#endregion
26606
27607
  //#region src/config/config.ts
@@ -27873,6 +28874,7 @@ var Transformer = class extends Disposable {
27873
28874
  _recoverySizeBoundary(selectedObjects, ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight) {
27874
28875
  for (let i = 0; i < selectedObjects.length; i++) {
27875
28876
  const moveObject = selectedObjects[i];
28877
+ if (this._getConfig(moveObject).moveBoundaryEnabled === false) continue;
27876
28878
  const { left, top, width, height } = moveObject;
27877
28879
  const newTransform = {};
27878
28880
  if (left + ancestorLeft < this.zeroLeft) {
@@ -27953,11 +28955,13 @@ var Transformer = class extends Disposable {
27953
28955
  });
27954
28956
  }
27955
28957
  _getOutlinePosition(width, height, borderSpacing, borderStrokeWidth) {
28958
+ const offset = borderSpacing + borderStrokeWidth;
28959
+ const strokeOffset = borderStrokeWidth / 2;
27956
28960
  return {
27957
- left: borderSpacing - borderStrokeWidth,
27958
- top: -borderSpacing - this.borderStrokeWidth,
27959
- width: width + borderSpacing * 2,
27960
- height: height + borderSpacing * 2
28961
+ left: -offset - strokeOffset,
28962
+ top: -offset - strokeOffset,
28963
+ width: width + offset * 2,
28964
+ height: height + offset * 2
27961
28965
  };
27962
28966
  }
27963
28967
  _getRotateAnchorCursor(type) {
@@ -28031,7 +29035,7 @@ var Transformer = class extends Disposable {
28031
29035
  top += -borderSpacing - borderStrokeWidth;
28032
29036
  break;
28033
29037
  case "__SpreadsheetTransformerResizeLM__":
28034
- left += borderSpacing - borderStrokeWidth;
29038
+ left += -borderSpacing - borderStrokeWidth;
28035
29039
  top += height / 2 - longEdge / 2;
28036
29040
  break;
28037
29041
  case "__SpreadsheetTransformerResizeRM__":
@@ -28039,7 +29043,7 @@ var Transformer = class extends Disposable {
28039
29043
  top += height / 2 - longEdge / 2;
28040
29044
  break;
28041
29045
  case "__SpreadsheetTransformerResizeLB__":
28042
- left += -this.borderSpacing - borderStrokeWidth;
29046
+ left += -borderSpacing - borderStrokeWidth;
28043
29047
  top += height + borderSpacing - borderStrokeWidth - longEdge;
28044
29048
  break;
28045
29049
  case "__SpreadsheetTransformerResizeCB__":
@@ -28079,28 +29083,28 @@ var Transformer = class extends Disposable {
28079
29083
  top += -borderSpacing - borderStrokeWidth;
28080
29084
  break;
28081
29085
  case "__SpreadsheetTransformerResizeRT__":
28082
- left += width + borderSpacing - borderStrokeWidth;
29086
+ left += width + borderSpacing + borderStrokeWidth;
28083
29087
  top += -borderSpacing - borderStrokeWidth;
28084
29088
  break;
28085
29089
  case "__SpreadsheetTransformerResizeLM__":
28086
- left += borderSpacing - borderStrokeWidth;
29090
+ left += -borderSpacing - borderStrokeWidth;
28087
29091
  top += height / 2;
28088
29092
  break;
28089
29093
  case "__SpreadsheetTransformerResizeRM__":
28090
- left += width + borderSpacing - borderStrokeWidth;
29094
+ left += width + borderSpacing + borderStrokeWidth;
28091
29095
  top += height / 2;
28092
29096
  break;
28093
29097
  case "__SpreadsheetTransformerResizeLB__":
28094
- left += -this.borderSpacing - borderStrokeWidth;
28095
- top += height + borderSpacing - borderStrokeWidth;
29098
+ left += -borderSpacing - borderStrokeWidth;
29099
+ top += height + borderSpacing + borderStrokeWidth;
28096
29100
  break;
28097
29101
  case "__SpreadsheetTransformerResizeCB__":
28098
29102
  left += width / 2;
28099
- top += height + borderSpacing - borderStrokeWidth;
29103
+ top += height + borderSpacing + borderStrokeWidth;
28100
29104
  break;
28101
29105
  case "__SpreadsheetTransformerResizeRB__":
28102
- left += width + borderSpacing - borderStrokeWidth;
28103
- top += height + borderSpacing - borderStrokeWidth;
29106
+ left += width + borderSpacing + borderStrokeWidth;
29107
+ top += height + borderSpacing + borderStrokeWidth;
28104
29108
  break;
28105
29109
  }
28106
29110
  return {
@@ -28139,8 +29143,8 @@ var Transformer = class extends Disposable {
28139
29143
  width: anchorProps.width,
28140
29144
  height: anchorProps.height,
28141
29145
  radius: anchorProps.radius,
28142
- left: left + (anchorSize - anchorProps.width) / 2,
28143
- top: top + (anchorSize - anchorProps.height) / 2,
29146
+ left: left + (anchorSize - anchorProps.width) / 2 - anchorStrokeWidth / 2,
29147
+ top: top + (anchorSize - anchorProps.height) / 2 - anchorStrokeWidth / 2,
28144
29148
  shadowColor: anchorShadowColor,
28145
29149
  shadowBlur: anchorShadowBlur,
28146
29150
  shadowOffsetX: anchorShadowOffsetX,
@@ -29454,14 +30458,17 @@ let RenderUnit = class RenderUnit extends Disposable {
29454
30458
  return this._renderContext.components;
29455
30459
  }
29456
30460
  constructor(init, parentInjector) {
29457
- var _init$createUnitOptio;
30461
+ var _init$createUnitOptio, _init$createUnitOptio2, _init$createUnitOptio3;
29458
30462
  super();
29459
30463
  _defineProperty(this, "isRenderUnit", true);
29460
30464
  _defineProperty(this, "_activated$", new BehaviorSubject(true));
29461
30465
  _defineProperty(this, "activated$", this._activated$.pipe(distinctUntilChanged()));
29462
30466
  _defineProperty(this, "_injector", void 0);
29463
30467
  _defineProperty(this, "_renderContext", void 0);
29464
- this._injector = parentInjector.createChild();
30468
+ _defineProperty(this, "_dependencyService", void 0);
30469
+ 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;
30470
+ this._injector = renderParentInjector.createChild();
30471
+ this._dependencyService = new RenderUnitDependencyService(this._injector, () => this._renderContext);
29465
30472
  this._renderContext = {
29466
30473
  unit: init.unit,
29467
30474
  unitId: init.unit.getUnitId(),
@@ -29475,13 +30482,14 @@ let RenderUnit = class RenderUnit extends Disposable {
29475
30482
  activate: () => this._activated$.next(true),
29476
30483
  deactivate: () => this._activated$.next(false)
29477
30484
  };
29478
- if (((_init$createUnitOptio = init.createUnitOptions) === null || _init$createUnitOptio === void 0 ? void 0 : _init$createUnitOptio.makeCurrent) === false) this.deactivate();
30485
+ if (((_init$createUnitOptio3 = init.createUnitOptions) === null || _init$createUnitOptio3 === void 0 ? void 0 : _init$createUnitOptio3.makeCurrent) === false) this.deactivate();
29479
30486
  }
29480
30487
  dispose() {
29481
- this._injector.dispose();
29482
- super.dispose();
30488
+ if (this._disposed) return;
29483
30489
  this._activated$.next(false);
29484
30490
  this._activated$.complete();
30491
+ super.dispose();
30492
+ this._injector.dispose();
29485
30493
  this._renderContext.unit = null;
29486
30494
  this._renderContext.components.clear();
29487
30495
  }
@@ -29492,7 +30500,10 @@ let RenderUnit = class RenderUnit extends Disposable {
29492
30500
  * Get a dependency from the RenderUnit's injector.
29493
30501
  */
29494
30502
  with(dependency) {
29495
- return this._injector.get(dependency);
30503
+ return this._dependencyService.resolve(dependency);
30504
+ }
30505
+ getInjector() {
30506
+ return this._injector;
29496
30507
  }
29497
30508
  /**
29498
30509
  * Add render dependencies to the RenderUnit's injector. Note that the dependencies would be initialized immediately
@@ -29502,16 +30513,8 @@ let RenderUnit = class RenderUnit extends Disposable {
29502
30513
  this._initDependencies(dependencies);
29503
30514
  }
29504
30515
  _initDependencies(dependencies) {
29505
- const j = this._injector;
29506
- dependencies.forEach((dep) => {
29507
- const [identifier, implOrNull] = Array.isArray(dep) ? dep : [dep, null];
29508
- if (!implOrNull) j.add([identifier, { useFactory: () => j.createInstance(identifier, this._renderContext) }]);
29509
- else if (isClassDependencyItem(implOrNull)) j.add([identifier, { useFactory: () => j.createInstance(implOrNull.useClass, this._renderContext) }]);
29510
- else throw new Error("[RenderUnit]: render dependency could only be an class!");
29511
- });
29512
- dependencies.forEach((dep) => {
29513
- const [identifier] = Array.isArray(dep) ? dep : [dep, null];
29514
- j.get(identifier);
30516
+ this._dependencyService.register(dependencies).forEach((record) => {
30517
+ this._dependencyService.resolveRecord(record);
29515
30518
  });
29516
30519
  }
29517
30520
  getRenderContext() {
@@ -29525,6 +30528,86 @@ let RenderUnit = class RenderUnit extends Disposable {
29525
30528
  }
29526
30529
  };
29527
30530
  RenderUnit = __decorate([__decorateParam(1, Inject(Injector))], RenderUnit);
30531
+ var RenderUnitDependencyService = class {
30532
+ constructor(_injector, _getRenderContext) {
30533
+ this._injector = _injector;
30534
+ this._getRenderContext = _getRenderContext;
30535
+ _defineProperty(this, "_records", /* @__PURE__ */ new Map());
30536
+ _defineProperty(this, "_resolved", /* @__PURE__ */ new Map());
30537
+ _defineProperty(this, "_resolving", /* @__PURE__ */ new Set());
30538
+ }
30539
+ register(dependencies) {
30540
+ const records = [];
30541
+ const seen = /* @__PURE__ */ new Set();
30542
+ dependencies.forEach((dependency) => {
30543
+ const parsed = this._parseDependency(dependency);
30544
+ const key = getRenderDependencyIdentifierKey$1(parsed.identifier);
30545
+ const existing = this._records.get(key);
30546
+ const record = existing !== null && existing !== void 0 ? existing : this._addRecord(key, parsed.identifier, parsed.create);
30547
+ if (seen.has(record.key)) return;
30548
+ seen.add(record.key);
30549
+ records.push(record);
30550
+ });
30551
+ return records;
30552
+ }
30553
+ resolve(dependency) {
30554
+ const key = getRenderDependencyIdentifierKey$1(dependency);
30555
+ if (this._resolved.has(key)) return this._resolved.get(key);
30556
+ if (this._resolving.has(key)) return;
30557
+ const record = this._records.get(key);
30558
+ if (record) return this.resolveRecord(record);
30559
+ return this._injector.get(dependency, LookUp.SELF);
30560
+ }
30561
+ resolveRecord(record) {
30562
+ if (this._resolved.has(record.key)) return this._resolved.get(record.key);
30563
+ if (this._resolving.has(record.key)) return;
30564
+ this._resolving.add(record.key);
30565
+ try {
30566
+ return this._injector.get(record.identifier, LookUp.SELF);
30567
+ } finally {
30568
+ this._resolving.delete(record.key);
30569
+ }
30570
+ }
30571
+ _addRecord(key, identifier, create) {
30572
+ const record = {
30573
+ key,
30574
+ identifier,
30575
+ create
30576
+ };
30577
+ this._records.set(key, record);
30578
+ this._injector.add([identifier, { useFactory: () => this._create(record) }]);
30579
+ return record;
30580
+ }
30581
+ _create(record) {
30582
+ if (this._resolved.has(record.key)) return this._resolved.get(record.key);
30583
+ const alreadyResolving = this._resolving.has(record.key);
30584
+ if (!alreadyResolving) this._resolving.add(record.key);
30585
+ try {
30586
+ const instance = record.create();
30587
+ this._resolved.set(record.key, instance);
30588
+ return instance;
30589
+ } finally {
30590
+ if (!alreadyResolving) this._resolving.delete(record.key);
30591
+ }
30592
+ }
30593
+ _parseDependency(dependency) {
30594
+ const [identifier, implOrNull] = Array.isArray(dependency) ? dependency : [dependency, null];
30595
+ if (!implOrNull) return {
30596
+ identifier,
30597
+ create: () => this._injector.createInstance(identifier, this._getRenderContext())
30598
+ };
30599
+ if (isClassDependencyItem(implOrNull)) return {
30600
+ identifier,
30601
+ create: () => this._injector.createInstance(implOrNull.useClass, this._getRenderContext())
30602
+ };
30603
+ throw new Error("[RenderUnit]: render dependency could only be an class!");
30604
+ }
30605
+ };
30606
+ function getRenderDependencyIdentifierKey$1(identifier) {
30607
+ const decoratorName = identifier === null || identifier === void 0 ? void 0 : identifier.decoratorName;
30608
+ if (typeof decoratorName === "string" && decoratorName) return `identifier:${decoratorName}`;
30609
+ return identifier;
30610
+ }
29528
30611
 
29529
30612
  //#endregion
29530
30613
  //#region src/render-manager/render-manager.service.ts
@@ -29565,10 +30648,11 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29565
30648
  registerRenderModules(type, deps) {
29566
30649
  if (!this._renderDependencies.has(type)) this._renderDependencies.set(type, []);
29567
30650
  const dependencies = this._renderDependencies.get(type);
29568
- dependencies.push(...deps);
29569
- for (const [_, render] of this._renderMap) if (render.type === type) this._tryAddRenderDependencies(render, deps);
30651
+ const registeredDeps = deps.filter((dep) => !hasRenderDependency(dependencies, dep));
30652
+ dependencies.push(...registeredDeps);
30653
+ for (const [_, render] of this._renderMap) if (render.type === type) this._tryAddRenderDependencies(render, registeredDeps);
29570
30654
  return toDisposable(() => {
29571
- deps.forEach((dep) => remove(dependencies, dep));
30655
+ registeredDeps.forEach((dep) => remove(dependencies, dep));
29572
30656
  });
29573
30657
  }
29574
30658
  /**
@@ -29579,6 +30663,7 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29579
30663
  registerRenderModule(type, depCtor) {
29580
30664
  if (!this._renderDependencies.has(type)) this._renderDependencies.set(type, []);
29581
30665
  const dependencies = this._renderDependencies.get(type);
30666
+ if (hasRenderDependency(dependencies, depCtor)) return toDisposable(() => {});
29582
30667
  dependencies.push(depCtor);
29583
30668
  for (const [_, render] of this._renderMap) if (render.type === type) this._tryAddRenderDependencies(render, [depCtor]);
29584
30669
  return toDisposable(() => remove(dependencies, depCtor));
@@ -29611,7 +30696,9 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29611
30696
  * @returns renderUnit:IRender
29612
30697
  */
29613
30698
  createRender(unitId, createUnitOptions) {
29614
- const renderer = this._createRender(unitId, this._injector.createInstance(Engine, unitId, void 0), true, createUnitOptions);
30699
+ var _createUnitOptions$re;
30700
+ const parentInjector = (_createUnitOptions$re = createUnitOptions === null || createUnitOptions === void 0 ? void 0 : createUnitOptions.renderParentInjector) !== null && _createUnitOptions$re !== void 0 ? _createUnitOptions$re : this._injector;
30701
+ const renderer = this._createRender(unitId, parentInjector.createInstance(Engine, unitId, void 0), (createUnitOptions === null || createUnitOptions === void 0 ? void 0 : createUnitOptions.embeddedRender) !== true, createUnitOptions, parentInjector);
29615
30702
  this._renderCreated$.next(renderer);
29616
30703
  return renderer;
29617
30704
  }
@@ -29635,7 +30722,7 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29635
30722
  * @param isMainScene
29636
30723
  * @returns renderUnit:IRender
29637
30724
  */
29638
- _createRender(unitId, engine, isMainScene = true, createUnitOptions) {
30725
+ _createRender(unitId, engine, isMainScene = true, createUnitOptions, parentInjector = this._injector) {
29639
30726
  const existItem = this.getRenderById(unitId);
29640
30727
  let shouldDestroyEngine = true;
29641
30728
  if (existItem != null) {
@@ -29652,7 +30739,7 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29652
30739
  if (unit) {
29653
30740
  const type = this._univerInstanceService.getUnitType(unitId);
29654
30741
  const ctorOfDeps = this._getRenderDepsByType(type);
29655
- renderUnit = this._injector.createInstance(RenderUnit, {
30742
+ renderUnit = parentInjector.createInstance(RenderUnit, {
29656
30743
  unit,
29657
30744
  engine,
29658
30745
  scene,
@@ -29660,7 +30747,16 @@ let RenderManagerService = class RenderManagerService extends Disposable {
29660
30747
  createUnitOptions
29661
30748
  });
29662
30749
  this._addRenderUnit(unitId, renderUnit);
29663
- this._tryAddRenderDependencies(renderUnit, ctorOfDeps);
30750
+ try {
30751
+ this._tryAddRenderDependencies(renderUnit, ctorOfDeps);
30752
+ } catch (error) {
30753
+ try {
30754
+ this._disposeItem(renderUnit);
30755
+ } finally {
30756
+ this._renderMap.delete(unitId);
30757
+ }
30758
+ throw error;
30759
+ }
29664
30760
  } else {
29665
30761
  renderUnit = {
29666
30762
  isThumbNail: true,
@@ -29723,6 +30819,18 @@ RenderManagerService = __decorate([
29723
30819
  __decorateParam(1, IUniverInstanceService),
29724
30820
  __decorateParam(2, Inject(ThemeService))
29725
30821
  ], RenderManagerService);
30822
+ function hasRenderDependency(dependencies, dep) {
30823
+ const key = getRenderDependencyIdentifierKey(getRenderDependencyIdentifier(dep));
30824
+ return dependencies.some((registered) => getRenderDependencyIdentifierKey(getRenderDependencyIdentifier(registered)) === key);
30825
+ }
30826
+ function getRenderDependencyIdentifier(dep) {
30827
+ return Array.isArray(dep) ? dep[0] : dep;
30828
+ }
30829
+ function getRenderDependencyIdentifierKey(identifier) {
30830
+ const decoratorName = identifier.decoratorName;
30831
+ if (typeof decoratorName === "string" && decoratorName) return `identifier:${decoratorName}`;
30832
+ return identifier;
30833
+ }
29726
30834
  const IRenderManagerService = createIdentifier("engine-render.render-manager.service");
29727
30835
  function isDisposable(thing) {
29728
30836
  return !!thing && typeof thing.dispose === "function";
@@ -30151,13 +31259,13 @@ var Viewport = class {
30151
31259
  * @param delta
30152
31260
  * @returns isLimited
30153
31261
  */
30154
- scrollByBarDeltaValue(delta, isTrigger = true) {
31262
+ scrollByBarDeltaValue(delta, isTrigger = true, options) {
30155
31263
  const x = this.scrollX + (delta.x || 0);
30156
31264
  const y = this.scrollY + (delta.y || 0);
30157
31265
  return this._scrollToBarPosCore({
30158
31266
  x,
30159
31267
  y
30160
- }, isTrigger);
31268
+ }, isTrigger, options);
30161
31269
  }
30162
31270
  /**
30163
31271
  * Viewport scroll to certain position.
@@ -30695,7 +31803,7 @@ var Viewport = class {
30695
31803
  * @param rawScrollXY Partial<IViewportScrollPosition>
30696
31804
  * @param isTrigger
30697
31805
  */
30698
- _scrollToBarPosCore(rawScrollXY, isTrigger = true) {
31806
+ _scrollToBarPosCore(rawScrollXY, isTrigger = true, options) {
30699
31807
  var _this$_scrollBar6, _this$_scrollBar7, _this$_scrollBar8, _this$_scrollBar9, _this$_scrollBar10;
30700
31808
  if (this._scrollBar == null) return;
30701
31809
  let scrollX = rawScrollXY.x;
@@ -30716,7 +31824,9 @@ var Viewport = class {
30716
31824
  rawScrollY: rawScrollXY.y,
30717
31825
  limitX: (_this$_scrollBar6 = this._scrollBar) === null || _this$_scrollBar6 === void 0 ? void 0 : _this$_scrollBar6.limitX,
30718
31826
  limitY: (_this$_scrollBar7 = this._scrollBar) === null || _this$_scrollBar7 === void 0 ? void 0 : _this$_scrollBar7.limitY,
30719
- isTrigger
31827
+ isTrigger,
31828
+ isBarDragging: options === null || options === void 0 ? void 0 : options.isBarDragging,
31829
+ isBarDragEnd: options === null || options === void 0 ? void 0 : options.isBarDragEnd
30720
31830
  };
30721
31831
  (_this$_scrollBar8 = this._scrollBar) === null || _this$_scrollBar8 === void 0 || _this$_scrollBar8.makeDirty(true);
30722
31832
  this.onScrollAfter$.emitEvent(scrollSubParam);
@@ -30729,7 +31839,9 @@ var Viewport = class {
30729
31839
  viewportScrollY: this.viewportScrollY,
30730
31840
  limitX: (_this$_scrollBar9 = this._scrollBar) === null || _this$_scrollBar9 === void 0 ? void 0 : _this$_scrollBar9.limitX,
30731
31841
  limitY: (_this$_scrollBar10 = this._scrollBar) === null || _this$_scrollBar10 === void 0 ? void 0 : _this$_scrollBar10.limitY,
30732
- isTrigger
31842
+ isTrigger,
31843
+ isBarDragging: options === null || options === void 0 ? void 0 : options.isBarDragging,
31844
+ isBarDragEnd: options === null || options === void 0 ? void 0 : options.isBarDragEnd
30733
31845
  });
30734
31846
  return afterLimit;
30735
31847
  }
@@ -30845,13 +31957,11 @@ var Viewport = class {
30845
31957
  left: Math.max(prevBound.left, currBound.left),
30846
31958
  right: Math.min(prevBound.right, currBound.right)
30847
31959
  });
30848
- const expandX = this.bufferEdgeX;
30849
- const expandY = this.bufferEdgeY;
30850
31960
  for (const bound of additionalAreas) {
30851
- bound.left = bound.left - expandX;
30852
- bound.right = bound.right + expandX;
30853
- bound.top = bound.top - expandY;
30854
- bound.bottom = bound.bottom + expandY;
31961
+ bound.left = bound.left - this.bufferEdgeX;
31962
+ bound.right = bound.right + this.bufferEdgeX;
31963
+ bound.top = bound.top - this.bufferEdgeY;
31964
+ bound.bottom = bound.bottom + this.bufferEdgeY;
30855
31965
  }
30856
31966
  return additionalAreas;
30857
31967
  }
@@ -30878,4 +31988,4 @@ var Viewport = class {
30878
31988
  };
30879
31989
 
30880
31990
  //#endregion
30881
- export { BASE_OBJECT_ARRAY, BG_Z_INDEX, BORDER_TYPE, BORDER_Z_INDEX, Background, BaseObject, Border, BreakType, CHECK_OBJECT_ARRAY, CIRCLE_OBJECT_ARRAY, COLOR_BLACK_RGB, CURSOR_TYPE, Canvas, CanvasColorService, CanvasRenderMode, CheckboxShape, Circle, ColumnHeaderLayout, ComponentExtension, Control, Custom, CustomObject, DEFAULT_DOCUMENT_FONTSIZE, DEFAULT_FONTFACE_PLANE, DEFAULT_FRAME_LIST_SIZE, DEFAULT_FRAME_SAMPLE_SIZE, DEFAULT_MEASURE_TEXT, DEFAULT_OFFSET_SPACING, DEFAULT_PADDING_DATA, DEFAULT_SKELETON_FOOTER, DEFAULT_SKELETON_HEADER, DOCUMENT_CONTEXT_CLIP_TYPE, DRAWING_OBJECT_LAYER_INDEX, DRAWING_OBJECT_LOWER_LAYER_INDEX, DRAWING_OBJECT_UPPER_LAYER_INDEX, DashedRect, DataStreamTreeNode, DeviceInputEventType, DeviceType, DocBackground, DocSimpleSkeleton, DocumentEditArea, DocumentSkeleton, DocumentSkeletonPageType, DocumentViewModel, Documents, DocumentsSpanAndLineExtensionRegistry, Drawing, DrawingGroupObject, DumbCanvasColorService, EXPAND_SIZE_FOR_RENDER_OVERFLOW, Engine, EventConstants, FIX_ONE_PIXEL_BLUR_OFFSET, FONT_EXTENSION_Z_INDEX, Font, FontCache, GlyphType, Group, HitCanvas, ICanvasColorService, INITIAL_MATRIX, INITIAL_Path2, IRenderManagerService, IRenderingEngine, IWatermarkTypeEnum, Image$1 as Image, IsSafari, LINK_VIEW_PORT_TYPE, Layer, LineType, Liquid, MAIN_VIEW_PORT_KEY, MAXIMUM_COL_WIDTH, MAXIMUM_ROW_HEIGHT, MEASURE_EXTENT, MEASURE_EXTENT_FOR_PARAGRAPH, MIDDLE_CELL_POS_MAGIC_NUMBER, MIN_COL_WIDTH, Marker, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, ORIENTATION_TYPE, ObjectType, PATH_OBJECT_ARRAY, PRINTING_BG_Z_INDEX, PageLayoutType, Path, Path2, PerformanceMonitor, PointerInput, RECT_OBJECT_ARRAY, REGULAR_POLYGON_OBJECT_ARRAY, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, RICHTEXT_OBJECT_ARRAY, Rect, RegularPolygon, RenderComponent, RenderManagerService, RenderUnit, RichText, RollingAverage, RowHeaderLayout, SHAPE_OBJECT_ARRAY, SHAPE_TYPE, SHEET_EXTENSION_PREFIX, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, SLIDE_NAVIGATION_KEY, Scene, SceneCanvas, SceneViewer, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetColumnHeaderExtensionRegistry, SheetComponent, SheetExtension, SheetRowHeaderExtensionRegistry, ShowGridlinesState, SkeletonType, Slide, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetExtensionRegistry, SpreadsheetHeader, SpreadsheetRowHeader, SpreadsheetSkeleton, TEXT_OBJECT_ARRAY, TRANSFORM_CHANGE_OBSERVABLE_TYPE, Text, Transform, UNIVER_WATERMARK_LAYER_INDEX, UNIVER_WATERMARK_STORAGE_KEY, UniverPrintingContext, UniverRenderEnginePlugin, UniverRenderingContext, UniverRenderingContext2D, VERTICAL_ROTATE_ANGLE, Vector2, Viewport, WatermarkLayer, calculateRectRotate, cancelRequestFrame, checkStyle, clampRange, clearLineByBorderType, compareDocumentSkeletonNestedPagePathOrder, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, createCanvasElement, createImageElement, degToRad, documentSkeletonLineIterator, documentSkeletonTableIterator, drawDiagonalLineByBorderType, drawLineByBorderType, expandRangeIfIntersects, fixLineWidthByScale, generateRandomKey, getCellByIndexWithMergeInfo, getCellPositionByIndex, getCharSpaceApply, getColor, getCurrentScrollXY, getCurrentTypeOfRenderer, getDPI, getDevicePixelRatio, getDocsSkeletonPageSize, getDocsTableRenderViewport, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, getDrawingGroupState, getFirstGrapheme, getFontStyleString, getGroupState, getLastColumn, getLastLine, getLineOffset, getLineWidth, getLineWith, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getPointerPrefix, getRenderTransformBaseOnParentBound, getRotateOffsetAndFarthestHypotenuse, getRotateOrientation, getRotatedBoundInGroup, getScale, getSizeForDom, getSystemHighlightColor, getTableIdAndSliceIndex, getTranslateInSpreadContextWithPixelRatio, getValueType, glyphIterator, hasAllLatin, hasArabic, hasBasicLatin, hasCJK, hasCJKPunctuation, hasCJKText, hasLatinExtendedA, hasLatinExtendedB, hasLatinOneSupplement, hasListGlyph, hasSpace, hasThai, hasTibetan, hasUnMergedCellInRow, inViewRanges, injectStyle, isArray, isCjkCenterAlignedPunctuation, isCjkLeftAlignedPunctuation, isCjkRightAlignedPunctuation, isDate, isEmojiGrapheme, isFirstGlyph, isFunction, isIndentByGlyph, isLastGlyph, isNumber, isObject, isPlaceholderOrSpace, isRectIntersect, isRegExp, isSameLine, isString, lineIterator, mergeInfoOffset, parseDataStreamToTree, pixelToPt, precisionTo, ptToMM, ptToPixel, ptToPx, pxToInch, pxToNum, pxToPt, radToDeg, renderImageWatermark, renderTextWatermark, renderUserInfoWatermark, renderWatermark, requestNewFrame, setDocsTableRenderViewportProvider, setLineType, sheetContentViewportKeys, sheetHeaderViewportKeys, startWithEmoji, toPx, transformObjectOutOfGroup, withCurrentTypeOfRenderer };
31991
+ 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, getShrinkToFitScale, 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, scaleDocumentDataForShrinkToFit, setDocsCustomBlockRenderViewportProvider, setDocsTableRenderViewportProvider, setLineType, sheetContentViewportKeys, sheetHeaderViewportKeys, startWithEmoji, toPx, transformObjectOutOfGroup, withCurrentTypeOfRenderer };