@univerjs/engine-render 0.25.0-insiders.20260623-012b5a8 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentDataModel, DocumentFlavor, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, ListGlyphType, LocaleService, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SectionType, SheetSkeleton, Skeleton, SpacingRule, TableAlignmentType, TableRowHeightRule, TableTextWrapType, TextDecoration, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, addLinkToDocumentModel, checkParagraphHasIndentByStyle, createIdentifier, createParagraphId, deleteContent, extractPureTextFromCell, getCellInfoInMergeData, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isClassDependencyItem, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, registerDependencies, remove, requestImmediateMacroTask, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
1
+ import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentDataModel, DocumentFlavor, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, ListGlyphType, LocaleService, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SectionType, SheetSkeleton, Skeleton, SpacingRule, TableAlignmentType, TableRowHeightRule, TableTextWrapType, TextDecoration, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, addLinkToDocumentModel, checkParagraphHasIndentByStyle, createIdentifier, deleteContent, extractPureTextFromCell, getCellInfoInMergeData, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isClassDependencyItem, isNullCell, isWhiteColor, merge, mergeWith, noop, numberToABC, numberToListABC, registerDependencies, remove, requestImmediateMacroTask, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
2
2
  import * as cjk from "cjk-regex";
3
3
  import { BehaviorSubject, Observable, Subject, Subscription, debounceTime, distinctUntilChanged, shareReplay, startWith } from "rxjs";
4
4
  import { parse } from "opentype.js";
@@ -640,7 +640,7 @@ function getSystemHighlightColor() {
640
640
  }
641
641
 
642
642
  //#endregion
643
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
643
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
644
644
  function _typeof(o) {
645
645
  "@babel/helpers - typeof";
646
646
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -651,7 +651,7 @@ function _typeof(o) {
651
651
  }
652
652
 
653
653
  //#endregion
654
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
654
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
655
655
  function toPrimitive(t, r) {
656
656
  if ("object" != _typeof(t) || !t) return t;
657
657
  var e = t[Symbol.toPrimitive];
@@ -664,14 +664,14 @@ function toPrimitive(t, r) {
664
664
  }
665
665
 
666
666
  //#endregion
667
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
667
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
668
668
  function toPropertyKey(t) {
669
669
  var i = toPrimitive(t, "string");
670
670
  return "symbol" == _typeof(i) ? i : i + "";
671
671
  }
672
672
 
673
673
  //#endregion
674
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
674
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
675
675
  function _defineProperty(e, r, t) {
676
676
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
677
677
  value: t,
@@ -2288,8 +2288,8 @@ var Path2 = class {
2288
2288
  const from = this._lines[o - 1];
2289
2289
  const to = this._lines[o];
2290
2290
  for (let n = 1; n < lines.length; n++) {
2291
- const contrastFrom = lines[n - 1];
2292
- const contrastTo = lines[n];
2291
+ const contrastFrom = this._lines[o - 1];
2292
+ const contrastTo = this._lines[o];
2293
2293
  const point = this._intersection({
2294
2294
  from,
2295
2295
  to
@@ -10853,8 +10853,8 @@ const TINF_OK = 0;
10853
10853
  const TINF_DATA_ERROR = -3;
10854
10854
  var Tree = class {
10855
10855
  constructor() {
10856
- _defineProperty(this, "table", /* @__PURE__ */ new Uint16Array(16));
10857
- _defineProperty(this, "trans", /* @__PURE__ */ new Uint16Array(288));
10856
+ _defineProperty(this, "table", new Uint16Array(16));
10857
+ _defineProperty(this, "trans", new Uint16Array(288));
10858
10858
  }
10859
10859
  };
10860
10860
  var Data = class {
@@ -10879,10 +10879,10 @@ var Data = class {
10879
10879
  };
10880
10880
  const sltree = new Tree();
10881
10881
  const sdtree = new Tree();
10882
- const length_bits = /* @__PURE__ */ new Uint8Array(30);
10883
- const length_base = /* @__PURE__ */ new Uint16Array(30);
10884
- const dist_bits = /* @__PURE__ */ new Uint8Array(30);
10885
- const dist_base = /* @__PURE__ */ new Uint16Array(30);
10882
+ const length_bits = new Uint8Array(30);
10883
+ const length_base = new Uint16Array(30);
10884
+ const dist_bits = new Uint8Array(30);
10885
+ const dist_base = new Uint16Array(30);
10886
10886
  const clcidx = new Uint8Array([
10887
10887
  16,
10888
10888
  17,
@@ -10905,7 +10905,7 @@ const clcidx = new Uint8Array([
10905
10905
  15
10906
10906
  ]);
10907
10907
  const code_tree = new Tree();
10908
- const lengths = /* @__PURE__ */ new Uint8Array(320);
10908
+ const lengths = new Uint8Array(320);
10909
10909
  function tinf_build_bits_base(bits, base, delta, first) {
10910
10910
  let i;
10911
10911
  let sum;
@@ -10930,7 +10930,7 @@ function tinf_build_fixed_trees(lt, dt) {
10930
10930
  dt.table[5] = 32;
10931
10931
  for (i = 0; i < 32; ++i) dt.trans[i] = i;
10932
10932
  }
10933
- const offs = /* @__PURE__ */ new Uint16Array(16);
10933
+ const offs = new Uint16Array(16);
10934
10934
  function tinf_build_tree(t, lengths, off, num) {
10935
10935
  let i;
10936
10936
  let sum;
@@ -12086,13 +12086,6 @@ function getDocsTableRenderViewport(unitId, tableId) {
12086
12086
  var _docsTableRenderViewp;
12087
12087
  return (_docsTableRenderViewp = docsTableRenderViewportProvider === null || docsTableRenderViewportProvider === void 0 ? void 0 : docsTableRenderViewportProvider(unitId, tableId)) !== null && _docsTableRenderViewp !== void 0 ? _docsTableRenderViewp : null;
12088
12088
  }
12089
- function getDocsTableVirtualContentWidth(viewport) {
12090
- var _viewport$leadingInse, _viewport$trailingIns;
12091
- return ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0) + viewport.contentWidth + ((_viewport$trailingIns = viewport.trailingInsetRight) !== null && _viewport$trailingIns !== void 0 ? _viewport$trailingIns : 0);
12092
- }
12093
- function hasDocsTableHorizontalViewport(viewport) {
12094
- return viewport != null && getDocsTableVirtualContentWidth(viewport) > viewport.viewportWidth;
12095
- }
12096
12089
 
12097
12090
  //#endregion
12098
12091
  //#region src/components/docs/view-model/data-stream-tree-node.ts
@@ -12563,68 +12556,6 @@ var DocumentViewModel = class DocumentViewModel {
12563
12556
  }
12564
12557
  };
12565
12558
 
12566
- //#endregion
12567
- //#region src/components/docs/document-compatibility.ts
12568
- const MODERN_DOCUMENT_COMPATIBILITY_POLICY = {
12569
- mode: "modern",
12570
- applyDocumentDefaultParagraphStyle: true,
12571
- useWordStyleLineHeight: true,
12572
- font: { metricScaleRules: [] },
12573
- table: {
12574
- currentPageOverflowTolerance: 0,
12575
- rowOverflowTolerance: 0,
12576
- allowImportedTableMarginOverflow: false
12577
- }
12578
- };
12579
- const TRADITIONAL_DOCUMENT_COMPATIBILITY_POLICY = {
12580
- mode: "traditional",
12581
- applyDocumentDefaultParagraphStyle: false,
12582
- useWordStyleLineHeight: true,
12583
- font: { metricScaleRules: [{
12584
- fontFamily: /^calibri$/i,
12585
- minFontSize: 20,
12586
- fontString: /\bbold\b/i,
12587
- content: /^[\d/]+$/u,
12588
- widthScale: .92
12589
- }] },
12590
- table: {
12591
- currentPageOverflowTolerance: 12,
12592
- rowOverflowTolerance: 4,
12593
- allowImportedTableMarginOverflow: true
12594
- }
12595
- };
12596
- const UNSPECIFIED_DOCUMENT_COMPATIBILITY_POLICY = {
12597
- mode: "unspecified",
12598
- applyDocumentDefaultParagraphStyle: false,
12599
- useWordStyleLineHeight: false,
12600
- font: { metricScaleRules: [] },
12601
- table: {
12602
- currentPageOverflowTolerance: 0,
12603
- rowOverflowTolerance: 0,
12604
- allowImportedTableMarginOverflow: false
12605
- }
12606
- };
12607
- function getDocumentCompatibilityPolicy(documentFlavor) {
12608
- if (documentFlavor === DocumentFlavor.MODERN) return MODERN_DOCUMENT_COMPATIBILITY_POLICY;
12609
- if (documentFlavor === DocumentFlavor.TRADITIONAL) return TRADITIONAL_DOCUMENT_COMPATIBILITY_POLICY;
12610
- return UNSPECIFIED_DOCUMENT_COMPATIBILITY_POLICY;
12611
- }
12612
- function applyFontMetricCompatibility(content, fontStyle, bBox, policy) {
12613
- const fontFamilies = fontStyle.fontFamily.split(",").map((item) => item.trim().replace(/^['"]|['"]$/g, ""));
12614
- const rule = policy.font.metricScaleRules.find((rule) => (rule.minFontSize == null || fontStyle.originFontSize >= rule.minFontSize) && (rule.fontString == null || rule.fontString.test(fontStyle.fontString)) && (rule.content == null || rule.content.test(content)) && fontFamilies.some((family) => rule.fontFamily.test(family)));
12615
- if ((rule === null || rule === void 0 ? void 0 : rule.widthScale) == null) return bBox;
12616
- return {
12617
- ...bBox,
12618
- width: bBox.width * rule.widthScale
12619
- };
12620
- }
12621
- function isTraditionalDocumentCompatibility(policy) {
12622
- return policy.mode === "traditional";
12623
- }
12624
- function shouldAllowImportedTableMarginOverflow(policy, tableSource) {
12625
- return policy.table.allowImportedTableMarginOverflow && tableSource != null && typeof tableSource === "object" && "docxWidth" in tableSource;
12626
- }
12627
-
12628
12559
  //#endregion
12629
12560
  //#region src/components/docs/layout/model/glyph.ts
12630
12561
  function isSpace(char) {
@@ -12705,7 +12636,6 @@ function createSkeletonCustomBlockGlyph(config, glyphWidth = 0, glyphHeight = 0,
12705
12636
  };
12706
12637
  }
12707
12638
  function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, glyphInfo) {
12708
- var _config$documentCompa;
12709
12639
  const { fontStyle, textStyle, charSpace = 1, gridType = GridType.LINES, snapToGrid = BooleanNumber.FALSE } = config;
12710
12640
  const skipWidthList = [
12711
12641
  DataStreamTreeTokenType.SECTION_BREAK,
@@ -12756,7 +12686,6 @@ function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, gly
12756
12686
  let xOffset = 0;
12757
12687
  if (glyphInfo && glyphInfo.boundingBox && glyphInfo.font) bBox = FontCache.getBBoxFromGlyphInfo(glyphInfo, fontStyle);
12758
12688
  else bBox = FontCache.getTextSize(content, fontStyle);
12759
- bBox = applyFontMetricCompatibility(content, fontStyle, bBox, (_config$documentCompa = config.documentCompatibilityPolicy) !== null && _config$documentCompa !== void 0 ? _config$documentCompa : getDocumentCompatibilityPolicy());
12760
12689
  const { width: contentWidth = 0 } = bBox;
12761
12690
  let width = glyphWidth !== null && glyphWidth !== void 0 ? glyphWidth : contentWidth;
12762
12691
  if (validationGrid(gridType, snapToGrid)) {
@@ -12877,11 +12806,11 @@ function createSkeletonLine(paragraphIndex, lineType, lineBoundingBox, columnWid
12877
12806
  lineSke.isBehindTable = true;
12878
12807
  lineSke.tableId = tableId;
12879
12808
  }
12880
- lineSke.divides = _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, new Map(Array.from(pageSkeDrawings).filter(([_, drawing]) => drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.INLINE && drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.WRAP_NONE)), headersDrawings, footersDrawings, new Map(Array.from(pageSkeTables).filter(([_, table]) => table.tableSource.textWrap === TableTextWrapType.WRAP)));
12809
+ lineSke.divides = _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, new Map(Array.from(pageSkeDrawings).filter(([_, drawing]) => drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.INLINE)), headersDrawings, footersDrawings, new Map(Array.from(pageSkeTables).filter(([_, table]) => table.tableSource.textWrap === TableTextWrapType.WRAP)));
12881
12810
  for (const divide of lineSke.divides) divide.parent = lineSke;
12882
12811
  return lineSke;
12883
12812
  }
12884
- function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, headerPage, footerPage, columnLeft = 0, columnWidth = 0) {
12813
+ function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, headerPage, footerPage) {
12885
12814
  let maxTop = lineTop;
12886
12815
  const pageSkeDrawings = page.skeDrawings;
12887
12816
  const skeNonWrapTables = new Map(Array.from(page.skeTables).filter(([_, table]) => table.tableSource.textWrap === TableTextWrapType.NONE));
@@ -12898,8 +12827,6 @@ function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, header
12898
12827
  pageSkeDrawings === null || pageSkeDrawings === void 0 || pageSkeDrawings.forEach((drawing) => {
12899
12828
  const top = _getLineTopWidthWrapTopBottom(drawing, lineHeight, lineTop);
12900
12829
  if (top) maxTop = Math.max(maxTop, top);
12901
- const blockingWrapTop = _getLineTopWithFullColumnWrap(drawing, lineHeight, lineTop, columnLeft, columnWidth);
12902
- if (blockingWrapTop) maxTop = Math.max(maxTop, blockingWrapTop);
12903
12830
  });
12904
12831
  skeNonWrapTables === null || skeNonWrapTables === void 0 || skeNonWrapTables.forEach((table) => {
12905
12832
  const top = _getLineTopWidthWrapNone(table, lineHeight, lineTop);
@@ -12907,37 +12834,6 @@ function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, header
12907
12834
  });
12908
12835
  return maxTop;
12909
12836
  }
12910
- function _getLineTopWithFullColumnWrap(drawing, lineHeight, lineTop, columnLeft, columnWidth) {
12911
- if (columnWidth <= 0) return;
12912
- const { aTop, height, aLeft, width, angle = 0, drawingOrigin } = drawing;
12913
- const { layoutType, distL = 0, distT = 0, distB = 0, distR = 0, wrapText } = drawingOrigin;
12914
- if (layoutType === PositionedObjectLayoutType.INLINE || layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) return;
12915
- let top = aTop;
12916
- let drawingHeight = height;
12917
- let left = aLeft - columnLeft;
12918
- let drawingWidth = width;
12919
- if (angle !== 0) {
12920
- var _boundingBox$top, _boundingBox$height, _boundingBox$left, _boundingBox$width;
12921
- const boundingBox = getBoundingBox(angle, left, width, top, height);
12922
- top = (_boundingBox$top = boundingBox.top) !== null && _boundingBox$top !== void 0 ? _boundingBox$top : top;
12923
- drawingHeight = (_boundingBox$height = boundingBox.height) !== null && _boundingBox$height !== void 0 ? _boundingBox$height : drawingHeight;
12924
- left = (_boundingBox$left = boundingBox.left) !== null && _boundingBox$left !== void 0 ? _boundingBox$left : left;
12925
- drawingWidth = (_boundingBox$width = boundingBox.width) !== null && _boundingBox$width !== void 0 ? _boundingBox$width : drawingWidth;
12926
- }
12927
- const newTop = top - (layoutType === PositionedObjectLayoutType.WRAP_SQUARE ? distT : 0);
12928
- const newHeight = drawingHeight + (layoutType === PositionedObjectLayoutType.WRAP_SQUARE ? distB + distT : 0);
12929
- const bottom = newTop + newHeight;
12930
- if (bottom <= lineTop) return;
12931
- const split = __getSplitWidthNoAngle(top, drawingHeight, left, drawingWidth, newTop, Math.max(1, newHeight), columnWidth, {
12932
- distL,
12933
- distT,
12934
- distB,
12935
- distR
12936
- }, layoutType, wrapText);
12937
- if (!split) return;
12938
- if (split.left > 0 || split.left + split.width < columnWidth) return;
12939
- return bottom;
12940
- }
12941
12837
  function _getLineTopWidthWrapNone(table, lineHeight, lineTop) {
12942
12838
  const { top, height } = table;
12943
12839
  if (top + height < lineTop || top > lineHeight + lineTop) return;
@@ -13137,7 +13033,6 @@ function _calculateDivideByDrawings(columnWidth, drawingSplit) {
13137
13033
  divideSkeleton.push(divide);
13138
13034
  }
13139
13035
  }
13140
- if (divideSkeleton.length === 0 && columnWidth > 0) return [__getDivideSKe(0, columnWidth)];
13141
13036
  return divideSkeleton;
13142
13037
  }
13143
13038
  function __getDivideSKe(left, width) {
@@ -13194,11 +13089,17 @@ function createSkeletonSection(columnProperties = [], columnSeparatorType = Colu
13194
13089
  let colWidth = 0;
13195
13090
  let spaceWidth = 0;
13196
13091
  if (columnProperties.length === 0) columns.push(_getSkeletonColumn(left, sectionWidth, 0, ColumnSeparatorType.NONE));
13197
- else for (const { width, paddingEnd } of _fitColumnProperties(columnProperties, sectionWidth)) {
13092
+ else for (let i = 0; i < columnProperties.length; i++) {
13093
+ const { width, paddingEnd } = columnProperties[i];
13198
13094
  spaceWidth = paddingEnd;
13199
13095
  colWidth = width;
13200
13096
  columns.push(_getSkeletonColumn(left, colWidth, spaceWidth, columnSeparatorType));
13201
13097
  left += colWidth + spaceWidth;
13098
+ if (i === columnProperties.length - 1) {
13099
+ colWidth = sectionWidth !== Number.POSITIVE_INFINITY ? sectionWidth - colWidth : width;
13100
+ spaceWidth = 0;
13101
+ columns.push(_getSkeletonColumn(left, colWidth, spaceWidth, columnSeparatorType));
13102
+ }
13202
13103
  }
13203
13104
  const newSection = {
13204
13105
  columns,
@@ -13213,42 +13114,6 @@ function createSkeletonSection(columnProperties = [], columnSeparatorType = Colu
13213
13114
  });
13214
13115
  return newSection;
13215
13116
  }
13216
- function _fitColumnProperties(columnProperties, sectionWidth) {
13217
- if (sectionWidth === Number.POSITIVE_INFINITY || columnProperties.length === 0) return columnProperties;
13218
- const safeSectionWidth = Math.max(0, sectionWidth);
13219
- const widths = columnProperties.map(({ width }) => Math.max(0, width));
13220
- const spaces = columnProperties.map(({ paddingEnd }, index) => index === columnProperties.length - 1 ? 0 : Math.max(0, paddingEnd));
13221
- const totalWidth = widths.reduce((sum, width) => sum + width, 0);
13222
- if (safeSectionWidth === 0) return columnProperties.map((columnProperty) => ({
13223
- ...columnProperty,
13224
- width: 0,
13225
- paddingEnd: 0
13226
- }));
13227
- if (totalWidth <= 0) {
13228
- const equalWidth = safeSectionWidth / columnProperties.length;
13229
- return columnProperties.map((columnProperty, index) => ({
13230
- ...columnProperty,
13231
- width: equalWidth,
13232
- paddingEnd: 0
13233
- }));
13234
- }
13235
- if (totalWidth > safeSectionWidth) {
13236
- const scale = safeSectionWidth / totalWidth;
13237
- return columnProperties.map((columnProperty, index) => ({
13238
- ...columnProperty,
13239
- width: widths[index] * scale,
13240
- paddingEnd: 0
13241
- }));
13242
- }
13243
- const spaceBudget = safeSectionWidth - totalWidth;
13244
- const totalSpace = spaces.reduce((sum, space) => sum + space, 0);
13245
- const fittedSpaces = totalSpace > spaceBudget && totalSpace > 0 ? spaces.map((space) => space / totalSpace * spaceBudget) : spaces;
13246
- return columnProperties.map((columnProperty, index) => ({
13247
- ...columnProperty,
13248
- width: widths[index],
13249
- paddingEnd: fittedSpaces[index]
13250
- }));
13251
- }
13252
13117
  function setColumnFullState(column, state) {
13253
13118
  column.isFull = state;
13254
13119
  }
@@ -13349,13 +13214,12 @@ function createTableSkeleton(ctx, curPage, viewModel, tableNode, sectionBreakCon
13349
13214
  function rollbackListCache(listLevel, table) {
13350
13215
  const { startIndex, endIndex } = table;
13351
13216
  for (const paragraphLists of listLevel.values()) for (const paragraphList of paragraphLists) {
13352
- if (paragraphList == null) continue;
13353
13217
  const paragraphListIndex = paragraphList.findIndex((p) => p.paragraph.startIndex > startIndex && p.paragraph.startIndex < endIndex);
13354
13218
  if (paragraphListIndex > -1) paragraphList.splice(paragraphListIndex);
13355
13219
  }
13356
13220
  }
13357
13221
  function createTableSkeletons(ctx, curPage, viewModel, tableNode, sectionBreakConfig, availableHeight) {
13358
- var _viewModel$getTableBy2, _sectionBreakConfig$d;
13222
+ var _viewModel$getTableBy2;
13359
13223
  const skeTables = [];
13360
13224
  const { startIndex, endIndex, children: rowNodes } = tableNode;
13361
13225
  const table = (_viewModel$getTableBy2 = viewModel.getTableByStartIndex(startIndex)) === null || _viewModel$getTableBy2 === void 0 ? void 0 : _viewModel$getTableBy2.tableSource;
@@ -13378,10 +13242,9 @@ function createTableSkeletons(ctx, curPage, viewModel, tableNode, sectionBreakCo
13378
13242
  skeTables.push(curTableSkeleton);
13379
13243
  for (const rowNode of rowNodes) dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig, rowNode, rowNodes.indexOf(rowNode), table, createCache);
13380
13244
  updateTableSkeletonsPosition(createCache, curPage, skeTables, table);
13381
- const documentCompatibilityPolicy = (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy();
13382
13245
  return {
13383
13246
  skeTables,
13384
- fromCurrentPage: skeTables[0].height <= availableHeight + documentCompatibilityPolicy.table.currentPageOverflowTolerance
13247
+ fromCurrentPage: skeTables[0].height <= availableHeight
13385
13248
  };
13386
13249
  }
13387
13250
  function updateTableSkeletonsPosition(cache, curPage, skeTables, table) {
@@ -13411,16 +13274,14 @@ function getAvailableHeight(curPage, cache, hasRepeatHeader) {
13411
13274
  return pageContentHeight;
13412
13275
  }
13413
13276
  function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig, rowNode, row, table, cache, isRepeatRow = false) {
13414
- var _sectionBreakConfig$d2;
13415
13277
  const pageContentHeight = getAvailableHeight(curPage, cache, false);
13416
13278
  const availableHeight = getAvailableHeight(curPage, cache, true);
13417
- const documentCompatibilityPolicy = (_sectionBreakConfig$d2 = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d2 !== void 0 ? _sectionBreakConfig$d2 : getDocumentCompatibilityPolicy();
13418
13279
  const { children: cellNodes, startIndex, endIndex } = rowNode;
13419
13280
  const rowSource = table.tableRows[row];
13420
13281
  const { trHeight, cantSplit } = rowSource;
13421
13282
  const rowSkeletons = [];
13422
13283
  const { hRule, val } = trHeight;
13423
- const canRowSplit = cantSplit !== BooleanNumber.TRUE && trHeight.hRule === TableRowHeightRule.AUTO;
13284
+ const canRowSplit = cantSplit === BooleanNumber.TRUE && trHeight.hRule === TableRowHeightRule.AUTO;
13424
13285
  const MAX_FONT_SIZE = 72;
13425
13286
  const needOpenNewTable = cache.remainHeight <= MAX_FONT_SIZE;
13426
13287
  let curTableSkeleton = getCurTableSkeleton(skeTables);
@@ -13466,8 +13327,7 @@ function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig
13466
13327
  while (rowSkeletons.length > 0) {
13467
13328
  const rowSkeleton = rowSkeletons.shift();
13468
13329
  const lastRow = curTableSkeleton.rows[curTableSkeleton.rows.length - 1];
13469
- const rowOverflowHeight = rowSkeleton.height - cache.remainHeight;
13470
- if (cache.remainHeight < MAX_FONT_SIZE || rowOverflowHeight > documentCompatibilityPolicy.table.rowOverflowTolerance) {
13330
+ if (cache.remainHeight < MAX_FONT_SIZE || cache.remainHeight < rowSkeleton.height) {
13471
13331
  cache.remainHeight = getAvailableHeight(curPage, cache, row !== 0 && rowSkeleton.index !== lastRow.index);
13472
13332
  cache.rowTop = 0;
13473
13333
  if (curTableSkeleton.rows.length > 0) {
@@ -13643,22 +13503,18 @@ function getTableIdAndSliceIndex(tableSliceId) {
13643
13503
 
13644
13504
  //#endregion
13645
13505
  //#region src/components/docs/layout/block/paragraph/layout-ruler.ts
13646
- const LINE_LAYOUT_OVERFLOW_TOLERANCE = 2;
13647
- const FLOAT_OBJECT_RELAYOUT_LIMIT = 5;
13648
13506
  function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal") {
13649
13507
  if (isParagraphFirstShapedText) if (paragraphConfig.bulletSkeleton) {
13650
- var _paragraphProperties$;
13651
13508
  const { bulletSkeleton, paragraphStyle = {} } = paragraphConfig;
13652
13509
  const { gridType = GridType.LINES, charSpace = 0, defaultTabStop = 10.5 } = sectionBreakConfig;
13653
13510
  const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
13654
13511
  const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
13655
13512
  const bulletGlyph = createSkeletonBulletGlyph(glyphGroup[0], bulletSkeleton, charSpaceApply);
13656
13513
  const paragraphProperties = bulletSkeleton.paragraphProperties || {};
13657
- paragraphConfig.paragraphStyle = {
13514
+ paragraphConfig.paragraphStyle = mergeByV(paragraphConfig.paragraphStyle, {
13658
13515
  ...paragraphProperties,
13659
- hanging: (_paragraphProperties$ = paragraphProperties.hanging) !== null && _paragraphProperties$ !== void 0 ? _paragraphProperties$ : { v: bulletGlyph.width },
13660
- ...paragraphConfig.paragraphStyle
13661
- };
13516
+ hanging: { v: bulletGlyph.width }
13517
+ }, "max");
13662
13518
  _lineOperator(ctx, [bulletGlyph, ...glyphGroup], pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
13663
13519
  } else _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
13664
13520
  else _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
@@ -13687,11 +13543,6 @@ function isGlyphGroupBeyondContentBox(glyphGroup, left, divideWidth) {
13687
13543
  }
13688
13544
  return isBeyondContentBox;
13689
13545
  }
13690
- function shouldKeepOverflowingTextOnLine(sectionBreakConfig) {
13691
- var _sectionBreakConfig$r;
13692
- const wrapStrategy = (_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.wrapStrategy;
13693
- return wrapStrategy === WrapStrategy.CLIP || wrapStrategy === WrapStrategy.OVERFLOW;
13694
- }
13695
13546
  function _getConsecutiveHyphenLineCount(divide) {
13696
13547
  var _divide$parent;
13697
13548
  const column = (_divide$parent = divide.parent) === null || _divide$parent === void 0 ? void 0 : _divide$parent.parent;
@@ -13727,20 +13578,12 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13727
13578
  const preOffsetLeft = ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.width) || 0) + ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.left) || 0);
13728
13579
  const { hyphenationZone } = sectionBreakConfig;
13729
13580
  if (preOffsetLeft + width > divide.width) {
13730
- if (shouldKeepOverflowingTextOnLine(sectionBreakConfig)) {
13731
- addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13732
- updateDivideInfo(divide, { breakType: breakPointType });
13733
- return;
13734
- }
13735
13581
  updateDivideInfo(divide, { isFull: true });
13736
13582
  const hyphenLineCount = _getConsecutiveHyphenLineCount(divideInfo.divide);
13737
13583
  const { consecutiveHyphenLimit = Number.POSITIVE_INFINITY } = sectionBreakConfig;
13738
13584
  if (divideInfo.isLast && glyphGroup.length === 1 && (glyphGroup[0].content === DataStreamTreeTokenType.SPACE || glyphGroup[0].content === DataStreamTreeTokenType.PARAGRAPH)) addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13739
13585
  else if (divideInfo.isLast && !isGlyphGroupBeyondContentBox(glyphGroup, preOffsetLeft, divide.width) && isGlyphGroupEndWithWhiteSpaces(glyphGroup)) addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13740
- else if (!isLast && (divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0 && glyphGroup.length === 1 && glyphGroup[0].streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyphGroup[0].width > divide.width) {
13741
- updateDivideInfo(divide, { isFull: true });
13742
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
13743
- } else if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0) {
13586
+ else if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0) {
13744
13587
  const sliceGlyphGroup = [];
13745
13588
  while (glyphGroup.length) {
13746
13589
  sliceGlyphGroup.push(glyphGroup.shift());
@@ -13765,16 +13608,11 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13765
13608
  } else {
13766
13609
  const currentLine = divide.parent;
13767
13610
  const maxBox = __maxFontBoundingBoxByGlyphGroup(glyphGroup);
13768
- if (currentLine && __isZeroWidthNonFlowFloatingAnchorLine(__getGlyphGroupByLine(currentLine), paragraphConfig.paragraphNonInlineSkeDrawings) && __hasFlowGlyph(glyphGroup)) {
13769
- for (const lineDivide of currentLine.divides) updateDivideInfo(lineDivide, { isFull: true });
13770
- _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, false, breakPointType);
13771
- return;
13772
- }
13773
- if (currentLine && maxBox && !__isNullLine(currentLine) && __hasFlowGlyph(__getGlyphGroupByLine(currentLine)) && !__isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphConfig.paragraphNonInlineSkeDrawings)) {
13611
+ if (currentLine && maxBox && !__isNullLine(currentLine)) {
13774
13612
  const { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(sectionBreakConfig, paragraphConfig);
13775
13613
  const { boundingBoxAscent, boundingBoxDescent } = maxBox;
13776
- const { contentHeight } = getLineHeightMetrics(boundingBoxAscent + boundingBoxDescent, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid, paragraphConfig.useWordStyleLineHeight);
13777
- if (contentHeight - currentLine.contentHeight > LINE_LAYOUT_OVERFLOW_TOLERANCE) {
13614
+ const { contentHeight } = __getLineHeight(boundingBoxAscent + boundingBoxDescent, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid);
13615
+ if (currentLine.contentHeight < contentHeight) {
13778
13616
  const spanGroupCached = __getGlyphGroupByLine(currentLine);
13779
13617
  const spanGroupCachedLen = spanGroupCached.length;
13780
13618
  let newGlyphGroup = [];
@@ -13790,15 +13628,6 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13790
13628
  return;
13791
13629
  }
13792
13630
  }
13793
- if (currentLine === null || currentLine === void 0 ? void 0 : currentLine.parent) {
13794
- const anchorDrawings = __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphConfig.paragraphNonInlineSkeDrawings);
13795
- if (anchorDrawings.length > 0) {
13796
- var _paragraphConfig$para, _paragraphConfig$pDra;
13797
- const paragraphAnchorLeft = __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, (_paragraphConfig$para = paragraphConfig.paragraphStyle) === null || _paragraphConfig$para === void 0 ? void 0 : _paragraphConfig$para.indentStart);
13798
- const drawings = __getDrawingPosition(currentLine.top, currentLine.lineHeight, currentLine.parent, true, (_paragraphConfig$pDra = paragraphConfig.pDrawingAnchor) === null || _paragraphConfig$pDra === void 0 || (_paragraphConfig$pDra = _paragraphConfig$pDra.get(paragraphConfig.paragraphIndex)) === null || _paragraphConfig$pDra === void 0 ? void 0 : _paragraphConfig$pDra.top, anchorDrawings, paragraphAnchorLeft);
13799
- __updateDrawingPosition(currentLine.parent, drawings);
13800
- }
13801
- }
13802
13631
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13803
13632
  updateDivideInfo(divide, { breakType: breakPointType });
13804
13633
  }
@@ -13824,7 +13653,6 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13824
13653
  const descent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.bd));
13825
13654
  const glyphLineHeight = defaultGlyphLineHeight || ascent + descent;
13826
13655
  const { paragraphStyle: originParagraphStyle = {}, paragraphNonInlineSkeDrawings, skeTablesInParagraph, skeHeaders, skeFooters, pDrawingAnchor, paragraphIndex } = paragraphConfig;
13827
- const isZeroWidthNonFlowFloatingAnchorLine = __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings);
13828
13656
  const { namedStyleType } = originParagraphStyle;
13829
13657
  const namedStyle = namedStyleType !== void 0 ? NAMED_STYLE_SPACE_MAP[namedStyleType] : null;
13830
13658
  const { spaceAbove, spaceBelow, indentFirstLine, hanging, indentStart, indentEnd } = {
@@ -13833,22 +13661,9 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13833
13661
  spaceBelow: (_originParagraphStyle2 = originParagraphStyle.spaceBelow) !== null && _originParagraphStyle2 !== void 0 ? _originParagraphStyle2 : namedStyle === null || namedStyle === void 0 ? void 0 : namedStyle.spaceBelow
13834
13662
  };
13835
13663
  const { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(sectionBreakConfig, paragraphConfig);
13836
- const hasInlineCustomBlock = glyphGroup.some((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0);
13837
- const glyphGroupCustomBlockIds = new Set(glyphGroup.filter((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.drawingId != null).map((glyph) => glyph.drawingId));
13838
- let { paddingTop, paddingBottom, contentHeight, lineSpacingApply } = getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid, paragraphConfig.useWordStyleLineHeight, !hasInlineCustomBlock);
13839
- let { marginTop, spaceBelowApply } = __getParagraphSpace(ctx, lineSpacingApply, spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine);
13840
- if (isZeroWidthNonFlowFloatingAnchorLine) {
13841
- paddingTop = 0;
13842
- paddingBottom = 0;
13843
- contentHeight = 0;
13844
- lineSpacingApply = 0;
13845
- marginTop = 0;
13846
- spaceBelowApply = 0;
13847
- }
13664
+ const { paddingTop, paddingBottom, contentHeight, lineSpacingApply } = __getLineHeight(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid);
13665
+ const { marginTop, spaceBelowApply } = __getParagraphSpace(ctx, lineSpacingApply, spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine);
13848
13666
  const lineHeight = marginTop + paddingTop + contentHeight + paddingBottom;
13849
- const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);
13850
- const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
13851
- const paragraphAnchorLeft = __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, indentStart);
13852
13667
  let section = column.parent;
13853
13668
  if (!section) section = getLastSection(lastPage);
13854
13669
  const lineTop = ((preLine === null || preLine === void 0 ? void 0 : preLine.lineHeight) || 0) + ((preLine === null || preLine === void 0 ? void 0 : preLine.top) || 0);
@@ -13865,22 +13680,16 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13865
13680
  if (relativeLineDrawings.length > 0) __updateAndPositionDrawings(ctx, preLine.top, preLine.lineHeight, column, relativeLineDrawings, preLine.paragraphIndex, isParagraphFirstShapedText);
13866
13681
  }
13867
13682
  }
13868
- let deferredInlineGroupAnchorDrawings = [];
13869
13683
  if (paragraphNonInlineSkeDrawings != null && paragraphNonInlineSkeDrawings.size > 0) {
13870
13684
  var _pDrawingAnchor$get;
13871
- let targetDrawings = [...paragraphNonInlineSkeDrawings.values()].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom !== ObjectRelativeFromV.LINE);
13872
- if (hasInlineCustomBlock) {
13873
- deferredInlineGroupAnchorDrawings = targetDrawings.filter((drawing) => glyphGroupCustomBlockIds.has(drawing.drawingId) && drawing.drawingOrigin.docTransform.positionV.relativeFrom === ObjectRelativeFromV.LINE);
13874
- targetDrawings = targetDrawings.filter((drawing) => !deferredInlineGroupAnchorDrawings.includes(drawing));
13875
- }
13876
- __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);
13685
+ __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, [...paragraphNonInlineSkeDrawings.values()].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom !== ObjectRelativeFromV.LINE), paragraphConfig.paragraphIndex, isParagraphFirstShapedText, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get === void 0 ? void 0 : _pDrawingAnchor$get.top);
13877
13686
  }
13878
13687
  if (skeTablesInParagraph != null && skeTablesInParagraph.length > 0) {
13879
13688
  var _pDrawingAnchor$get2;
13880
13689
  needOpenNewPageByTableLayout = _updateAndPositionTable(ctx, lineTop, lineHeight, lastPage, column, section, skeTablesInParagraph, paragraphConfig.paragraphIndex, sectionBreakConfig, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get2 = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get2 === void 0 ? void 0 : _pDrawingAnchor$get2.top);
13881
13690
  }
13882
13691
  const newLineTop = calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage);
13883
- if (lineHeight + newLineTop - section.height > LINE_LAYOUT_OVERFLOW_TOLERANCE && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
13692
+ if (lineHeight + newLineTop > section.height && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
13884
13693
  setColumnFullState(column, true);
13885
13694
  _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
13886
13695
  if (isParagraphFirstShapedText && paragraphNonInlineSkeDrawings && paragraphNonInlineSkeDrawings.size > 0) for (const drawing of paragraphNonInlineSkeDrawings.values()) {
@@ -13894,7 +13703,8 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13894
13703
  return;
13895
13704
  }
13896
13705
  const lineIndex = preLine ? preLine.lineIndex + 1 : 0;
13897
- let { paddingLeft, paddingRight } = __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, charSpaceApply, isParagraphFirstShapedText);
13706
+ const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);
13707
+ let { paddingLeft, paddingRight } = __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid), isParagraphFirstShapedText);
13898
13708
  if (paddingLeft + paddingRight >= column.width) {
13899
13709
  const leftPercent = paddingLeft / (paddingLeft + paddingRight);
13900
13710
  paddingLeft = column.width * leftPercent - .5;
@@ -13915,16 +13725,12 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13915
13725
  newLine.parent = column;
13916
13726
  createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor);
13917
13727
  _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
13918
- if (deferredInlineGroupAnchorDrawings.length > 0) {
13919
- var _pDrawingAnchor$get3;
13920
- __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);
13921
- }
13922
13728
  }
13923
- function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop, drawingAnchorLeft = 0, skipRelayoutCheck = false) {
13729
+ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop) {
13924
13730
  if (targetDrawings.length === 0) return;
13925
- const drawings = __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
13731
+ const drawings = __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings);
13926
13732
  if (drawings == null || drawings.size === 0) return;
13927
- const floatObjects = [...drawings.values()].filter((drawing) => {
13733
+ _reLayoutCheck(ctx, [...drawings.values()].filter((drawing) => {
13928
13734
  const layoutType = drawing.drawingOrigin.layoutType;
13929
13735
  return layoutType !== PositionedObjectLayoutType.INLINE && layoutType !== PositionedObjectLayoutType.WRAP_NONE;
13930
13736
  }).map((drawing) => {
@@ -13937,13 +13743,10 @@ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDra
13937
13743
  width,
13938
13744
  height,
13939
13745
  angle,
13940
- behindDoc: drawingOrigin.behindDoc,
13941
- layoutType: drawingOrigin.layoutType,
13942
13746
  type: "IMAGE",
13943
13747
  positionV
13944
13748
  };
13945
- });
13946
- if (!skipRelayoutCheck) _reLayoutCheck(ctx, floatObjects, column, paragraphIndex);
13749
+ }), column, paragraphIndex);
13947
13750
  __updateDrawingPosition(column, drawings);
13948
13751
  }
13949
13752
  function __updateWrapTablePosition(ctx, table, lineTop, lineHeight, column, paragraphIndex, drawingAnchorTop) {
@@ -13976,22 +13779,6 @@ function __getWrapTablePosition(table, column, lineTop, lineHeight, drawingAncho
13976
13779
  top: (_getPositionVertical = getPositionVertical(positionV, page, lineTop, lineHeight, height, drawingAnchorTop, isPageBreak)) !== null && _getPositionVertical !== void 0 ? _getPositionVertical : 0
13977
13780
  };
13978
13781
  }
13979
- function __avoidFlowAffectingDrawingsForTable(table, page, column) {
13980
- const tableTop = table.top;
13981
- const tableBottom = table.top + table.height;
13982
- const tableRight = table.left + table.width;
13983
- for (const drawing of page.skeDrawings.values()) {
13984
- var _drawingOrigin$distR;
13985
- const drawingOrigin = drawing.drawingOrigin;
13986
- if (drawingOrigin == null || drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE || drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_NONE || drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) continue;
13987
- const drawingTop = drawing.aTop;
13988
- const drawingBottom = drawing.aTop + drawing.height;
13989
- if (drawingTop >= tableBottom || drawingBottom <= tableTop) continue;
13990
- const drawingRight = drawing.aLeft + drawing.width + ((_drawingOrigin$distR = drawingOrigin.distR) !== null && _drawingOrigin$distR !== void 0 ? _drawingOrigin$distR : 0);
13991
- if (drawing.aLeft >= tableRight || drawingRight <= table.left) continue;
13992
- if (drawingRight + table.width <= column.width) table.left = Math.max(table.left, drawingRight);
13993
- }
13994
- }
13995
13782
  function _updateAndPositionTable(ctx, lineTop, lineHeight, page, column, section, skeTablesInParagraph, paragraphIndex, sectionBreakConfig, drawingAnchorTop) {
13996
13783
  if (skeTablesInParagraph.length === 0) return false;
13997
13784
  const firstUnPositionedTable = skeTablesInParagraph.find((table) => table.hasPositioned === false);
@@ -14001,7 +13788,6 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, column, section
14001
13788
  if (firstUnPositionedTable.isSlideTable === false) switch (tableSource.textWrap) {
14002
13789
  case TableTextWrapType.NONE:
14003
13790
  table.top = lineTop;
14004
- __avoidFlowAffectingDrawingsForTable(table, page, column);
14005
13791
  break;
14006
13792
  case TableTextWrapType.WRAP:
14007
13793
  __updateWrapTablePosition(ctx, table, lineTop, lineHeight, column, paragraphIndex, drawingAnchorTop);
@@ -14055,47 +13841,15 @@ function _getCustomBlockIdsInLine(line) {
14055
13841
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) customBlockIds.push(glyph.drawingId);
14056
13842
  return customBlockIds;
14057
13843
  }
14058
- function __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings) {
14059
- return __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings).length > 0;
14060
- }
14061
- function __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings) {
14062
- const drawings = [];
14063
- for (const glyph of glyphGroup) {
14064
- if (__isStructuralTerminatorGlyph(glyph)) continue;
14065
- if (__isIgnorableZeroSizeGlyph(glyph)) continue;
14066
- if (glyph.streamType !== DataStreamTreeTokenType.CUSTOM_BLOCK || glyph.width !== 0 || glyph.drawingId == null) return [];
14067
- const drawing = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.get(glyph.drawingId);
14068
- const drawingOrigin = drawing === null || drawing === void 0 ? void 0 : drawing.drawingOrigin;
14069
- if (drawing == null || drawingOrigin == null) return [];
14070
- if (drawingOrigin.layoutType !== PositionedObjectLayoutType.WRAP_NONE) return [];
14071
- drawings.push(drawing);
14072
- }
14073
- return drawings;
14074
- }
14075
- function __isIgnorableZeroSizeGlyph(glyph) {
14076
- return glyph.content === "" && glyph.drawingId == null && glyph.width === 0 && glyph.bBox.ba + glyph.bBox.bd === 0;
14077
- }
14078
- function __isStructuralTerminatorGlyph(glyph) {
14079
- return glyph.streamType === DataStreamTreeTokenType.PARAGRAPH || glyph.streamType === DataStreamTreeTokenType.SECTION_BREAK || glyph.streamType === DataStreamTreeTokenType.DOCS_END;
14080
- }
14081
- function __hasFlowGlyph(glyphGroup) {
14082
- return glyphGroup.some((glyph) => {
14083
- if (__isStructuralTerminatorGlyph(glyph)) return false;
14084
- if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) return glyph.width !== 0;
14085
- return glyph.content !== "" || glyph.width > 0 || glyph.bBox.ba + glyph.bBox.bd > 0;
14086
- });
14087
- }
14088
13844
  function _reLayoutCheck(ctx, floatObjects, column, paragraphIndex) {
14089
13845
  var _column$parent2;
14090
13846
  const page = (_column$parent2 = column.parent) === null || _column$parent2 === void 0 ? void 0 : _column$parent2.parent;
14091
- const flowAffectingFloatObjects = floatObjects.filter((floatObject) => floatObject.behindDoc !== BooleanNumber.TRUE || floatObject.layoutType != null && floatObject.layoutType !== PositionedObjectLayoutType.WRAP_NONE);
14092
- if (flowAffectingFloatObjects.length === 0 || page == null) return;
13847
+ if (floatObjects.length === 0 || page == null) return;
14093
13848
  let needBreakLineIterator = false;
14094
- for (const floatObject of flowAffectingFloatObjects) {
13849
+ for (const floatObject of floatObjects) {
14095
13850
  var _floatObjectCache$pag, _page$sections$;
14096
13851
  const floatObjectCache = ctx.floatObjectsCache.get(floatObject.id);
14097
13852
  if (floatObjectCache == null || floatObjectCache.page.segmentId !== page.segmentId) continue;
14098
- if (floatObjectCache.count >= FLOAT_OBJECT_RELAYOUT_LIMIT) continue;
14099
13853
  const cachePageStartParagraphIndex = (_floatObjectCache$pag = floatObjectCache.page.sections[0]) === null || _floatObjectCache$pag === void 0 || (_floatObjectCache$pag = _floatObjectCache$pag.columns[0]) === null || _floatObjectCache$pag === void 0 || (_floatObjectCache$pag = _floatObjectCache$pag.lines[0]) === null || _floatObjectCache$pag === void 0 ? void 0 : _floatObjectCache$pag.paragraphIndex;
14100
13854
  const startIndex = (_page$sections$ = page.sections[0]) === null || _page$sections$ === void 0 || (_page$sections$ = _page$sections$.columns[0]) === null || _page$sections$ === void 0 || (_page$sections$ = _page$sections$.lines[0]) === null || _page$sections$ === void 0 ? void 0 : _page$sections$.paragraphIndex;
14101
13855
  if (floatObjectCache.page && cachePageStartParagraphIndex && startIndex && cachePageStartParagraphIndex !== startIndex) {
@@ -14121,7 +13875,7 @@ function _reLayoutCheck(ctx, floatObjects, column, paragraphIndex) {
14121
13875
  const { lineHeight, top } = line;
14122
13876
  const { width: columnWidth, left: columnLeft } = column;
14123
13877
  if (needBreakLineIterator) return;
14124
- for (const floatObject of flowAffectingFloatObjects.values()) {
13878
+ for (const floatObject of floatObjects.values()) {
14125
13879
  let targetObject = floatObject;
14126
13880
  if (ctx.floatObjectsCache.has(floatObject.id)) {
14127
13881
  const drawingCache = ctx.floatObjectsCache.get(floatObject.id);
@@ -14159,7 +13913,7 @@ function checkRelativeDrawingNeedRePosition(ctx, floatObject) {
14159
13913
  if (drawingCache == null) return false;
14160
13914
  if (relativeFrom === ObjectRelativeFromV.PARAGRAPH || relativeFrom === ObjectRelativeFromV.LINE) {
14161
13915
  const { count, floatObject: prevObject } = drawingCache;
14162
- if (count < FLOAT_OBJECT_RELAYOUT_LIMIT && Math.abs(floatObject.top - prevObject.top) > 5) return true;
13916
+ if (count < 5 && Math.abs(floatObject.top - prevObject.top) > 5) return true;
14163
13917
  }
14164
13918
  return false;
14165
13919
  }
@@ -14216,87 +13970,43 @@ function __getParagraphSpace(ctx, lineSpacing = 0, spaceAbove, spaceBelow, isPar
14216
13970
  spaceBelowApply
14217
13971
  };
14218
13972
  }
14219
- function __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, indentStart) {
14220
- const { paragraphStyle = {} } = paragraphConfig;
14221
- const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
14222
- const { gridType = GridType.LINES } = sectionBreakConfig;
14223
- const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);
14224
- const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
14225
- const paragraphAnchorLeft = getNumberUnitValue(indentStart, charSpaceApply);
14226
- if (paragraphAnchorLeft > 0) return paragraphAnchorLeft;
14227
- return getNumberUnitValue(paragraphConfig.docxFallbackAnchorLeft, charSpaceApply);
14228
- }
14229
- function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid, useWordStyleLineHeight = true, scaleAutoLineSpacingByGlyphHeight = true) {
14230
- if (!useWordStyleLineHeight) {
14231
- let paddingTop = paragraphLineGapDefault;
14232
- let paddingBottom = paragraphLineGapDefault;
14233
- if (gridType === GridType.DEFAULT || snapToGrid === BooleanNumber.FALSE) {
14234
- if (spacingRule === SpacingRule.AUTO) return {
14235
- paddingTop,
14236
- paddingBottom,
14237
- contentHeight: lineSpacing * glyphLineHeight,
14238
- lineSpacingApply: glyphLineHeight
14239
- };
14240
- return {
14241
- paddingTop,
14242
- paddingBottom,
14243
- contentHeight: Math.max(lineSpacing, glyphLineHeight),
14244
- lineSpacingApply: lineSpacing
14245
- };
14246
- }
14247
- let lineSpacingApply = 0;
14248
- if (spacingRule === SpacingRule.AUTO) lineSpacingApply = lineSpacing * linePitch;
14249
- else lineSpacingApply = lineSpacing;
14250
- if (glyphLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply) paddingTop = paddingBottom = (lineSpacingApply - glyphLineHeight) / 2;
14251
- else lineSpacingApply = glyphLineHeight;
14252
- return {
13973
+ function __getLineHeight(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid) {
13974
+ let paddingTop = paragraphLineGapDefault;
13975
+ let paddingBottom = paragraphLineGapDefault;
13976
+ if (gridType === GridType.DEFAULT || snapToGrid === BooleanNumber.FALSE) {
13977
+ if (spacingRule === SpacingRule.AUTO) return {
14253
13978
  paddingTop,
14254
13979
  paddingBottom,
14255
- contentHeight: glyphLineHeight,
14256
- lineSpacingApply
13980
+ contentHeight: lineSpacing * glyphLineHeight,
13981
+ lineSpacingApply: glyphLineHeight
14257
13982
  };
14258
- }
14259
- const usesDocumentGrid = spacingRule === SpacingRule.AUTO && snapToGrid === BooleanNumber.TRUE && gridType !== GridType.DEFAULT;
14260
- if (spacingRule === SpacingRule.AUTO) {
14261
- const lineSpacingApply = usesDocumentGrid ? lineSpacing * linePitch : scaleAutoLineSpacingByGlyphHeight ? lineSpacing * glyphLineHeight : glyphLineHeight;
14262
- const padding = (lineSpacingApply - glyphLineHeight) / 2;
14263
- return {
14264
- paddingTop: padding,
14265
- paddingBottom: padding,
14266
- contentHeight: glyphLineHeight,
14267
- lineSpacingApply
14268
- };
14269
- }
14270
- if (spacingRule === SpacingRule.AT_LEAST) {
14271
- const lineSpacingApply = Math.max(lineSpacing, glyphLineHeight);
14272
- const padding = (lineSpacingApply - glyphLineHeight) / 2;
14273
13983
  return {
14274
- paddingTop: padding,
14275
- paddingBottom: padding,
14276
- contentHeight: glyphLineHeight,
14277
- lineSpacingApply
13984
+ paddingTop,
13985
+ paddingBottom,
13986
+ contentHeight: Math.max(lineSpacing, glyphLineHeight),
13987
+ lineSpacingApply: lineSpacing
14278
13988
  };
14279
13989
  }
14280
- const exactLineSpacingApply = snapToGrid === BooleanNumber.TRUE && gridType !== GridType.DEFAULT ? Math.max(lineSpacing, linePitch) : lineSpacing;
14281
- const exactPadding = (exactLineSpacingApply - glyphLineHeight) / 2;
13990
+ let lineSpacingApply = 0;
13991
+ if (spacingRule === SpacingRule.AUTO) lineSpacingApply = lineSpacing * linePitch;
13992
+ else lineSpacingApply = lineSpacing;
13993
+ if (glyphLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply) paddingTop = paddingBottom = (lineSpacingApply - glyphLineHeight) / 2;
13994
+ else lineSpacingApply = glyphLineHeight;
14282
13995
  return {
14283
- paddingTop: exactPadding,
14284
- paddingBottom: exactPadding,
13996
+ paddingTop,
13997
+ paddingBottom,
14285
13998
  contentHeight: glyphLineHeight,
14286
- lineSpacingApply: exactLineSpacingApply
13999
+ lineSpacingApply
14287
14000
  };
14288
14001
  }
14289
- function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnchorTop, paragraphNonInlineSkeDrawings) {
14290
- var _line$parent, _section$top;
14002
+ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnchorTop) {
14003
+ var _line$parent;
14291
14004
  const column = line.parent;
14292
- const section = column === null || column === void 0 ? void 0 : column.parent;
14293
14005
  const page = line === null || line === void 0 || (_line$parent = line.parent) === null || _line$parent === void 0 || (_line$parent = _line$parent.parent) === null || _line$parent === void 0 ? void 0 : _line$parent.parent;
14294
14006
  if (page == null || column == null) return;
14295
14007
  const isPageBreak = __checkPageBreak(column);
14296
14008
  const drawings = /* @__PURE__ */ new Map();
14297
14009
  const { top, lineHeight, marginBottom = 0 } = line;
14298
- const sectionTop = (_section$top = section === null || section === void 0 ? void 0 : section.top) !== null && _section$top !== void 0 ? _section$top : 0;
14299
- const lineTop = sectionTop + top;
14300
14010
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0) {
14301
14011
  const { drawingId } = glyph;
14302
14012
  if (drawingId == null) continue;
@@ -14307,37 +14017,21 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14307
14017
  const { size, angle } = docTransform;
14308
14018
  const { width = 0, height = 0 } = size;
14309
14019
  const glyphHeight = glyph.bBox.bd + glyph.bBox.ba;
14310
- drawing.aLeft = column.left + divide.left + divide.paddingLeft + glyph.left + .5 * glyph.width - .5 * width || 0;
14311
- if (glyph.width > divide.width) {
14312
- var _paragraphNonInlineSk;
14313
- for (const positionedDrawing of (_paragraphNonInlineSk = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.values()) !== null && _paragraphNonInlineSk !== void 0 ? _paragraphNonInlineSk : []) {
14314
- const positionedOrigin = positionedDrawing.drawingOrigin;
14315
- if (positionedOrigin == null || positionedOrigin.layoutType === PositionedObjectLayoutType.INLINE || positionedOrigin.layoutType === PositionedObjectLayoutType.WRAP_NONE || positionedOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) continue;
14316
- const positionedBottom = positionedDrawing.aTop + positionedDrawing.height;
14317
- const lineBottom = lineTop + lineHeight;
14318
- if (positionedDrawing.aTop >= lineBottom || positionedBottom <= lineTop) continue;
14319
- const positionedRight = positionedDrawing.aLeft + positionedDrawing.width;
14320
- const drawingRight = drawing.aLeft + width;
14321
- if (positionedDrawing.aLeft < drawingRight && positionedRight > drawing.aLeft) {
14322
- var _positionedOrigin$dis;
14323
- drawing.aLeft = Math.max(drawing.aLeft, positionedDrawing.aLeft + positionedDrawing.width + ((_positionedOrigin$dis = positionedOrigin.distR) !== null && _positionedOrigin$dis !== void 0 ? _positionedOrigin$dis : 0));
14324
- }
14325
- }
14326
- }
14327
- drawing.aTop = lineTop + lineHeight - .5 * glyphHeight - .5 * height - marginBottom;
14020
+ drawing.aLeft = divide.left + divide.paddingLeft + glyph.left + .5 * glyph.width - .5 * width || 0;
14021
+ drawing.aTop = top + lineHeight - .5 * glyphHeight - .5 * height - marginBottom;
14328
14022
  drawing.width = width;
14329
14023
  drawing.height = height;
14330
14024
  drawing.angle = angle;
14331
14025
  drawing.isPageBreak = isPageBreak;
14332
- drawing.lineTop = lineTop;
14026
+ drawing.lineTop = top;
14333
14027
  drawing.columnLeft = column.left;
14334
- drawing.blockAnchorTop = blockAnchorTop == null ? lineTop : sectionTop + blockAnchorTop;
14028
+ drawing.blockAnchorTop = blockAnchorTop !== null && blockAnchorTop !== void 0 ? blockAnchorTop : top;
14335
14029
  drawing.lineHeight = line.lineHeight;
14336
14030
  drawings.set(drawing.drawingId, drawing);
14337
14031
  }
14338
14032
  page.skeDrawings = new Map([...page.skeDrawings, ...drawings]);
14339
14033
  }
14340
- function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = [], blockAnchorLeft = 0) {
14034
+ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = []) {
14341
14035
  var _column$parent3;
14342
14036
  const page = (_column$parent3 = column.parent) === null || _column$parent3 === void 0 ? void 0 : _column$parent3.parent;
14343
14037
  if (page == null || needPositionDrawings.length === 0) return;
@@ -14351,12 +14045,7 @@ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShape
14351
14045
  const { docTransform } = drawingOrigin;
14352
14046
  const { positionH, positionV, size, angle } = docTransform;
14353
14047
  const { width = 0, height = 0 } = size;
14354
- let aLeft = (_getPositionHorizon2 = getPositionHorizon(positionH, column, page, width, isPageBreak)) !== null && _getPositionHorizon2 !== void 0 ? _getPositionHorizon2 : 0;
14355
- if (positionH.relativeFrom === ObjectRelativeFromH.COLUMN && blockAnchorLeft > 0) {
14356
- const renderedColumnOrigin = isPageBreak ? 0 : column.left || page.marginLeft;
14357
- aLeft += blockAnchorLeft - renderedColumnOrigin;
14358
- }
14359
- drawing.aLeft = aLeft;
14048
+ drawing.aLeft = (_getPositionHorizon2 = getPositionHorizon(positionH, column, page, width, isPageBreak)) !== null && _getPositionHorizon2 !== void 0 ? _getPositionHorizon2 : 0;
14360
14049
  drawing.aTop = (_getPositionVertical2 = getPositionVertical(positionV, page, lineTop, lineHeight, height, blockAnchorTop, isPageBreak)) !== null && _getPositionVertical2 !== void 0 ? _getPositionVertical2 : 0;
14361
14050
  drawing.width = width;
14362
14051
  drawing.height = height;
@@ -14425,7 +14114,7 @@ function __getGlyphGroupByLine({ divides }) {
14425
14114
  return divides.flatMap((divide) => divide.glyphGroup);
14426
14115
  }
14427
14116
  function __isNullLine(line) {
14428
- return __getGlyphGroupByLine(line).every((glyph) => !glyph.content && !glyph.drawingId);
14117
+ return !line.divides[0].glyphGroup[0];
14429
14118
  }
14430
14119
 
14431
14120
  //#endregion
@@ -14508,7 +14197,6 @@ function isColumnFull(page) {
14508
14197
  function getNumberUnitValue(unitValue, benchMark) {
14509
14198
  if (!unitValue) return 0;
14510
14199
  const { v: value, u: unit } = unitValue;
14511
- if (typeof value !== "number" || !Number.isFinite(value)) return 0;
14512
14200
  if (!unit) return value;
14513
14201
  if (unit === NumberUnitType.PIXEL) return value;
14514
14202
  return value * benchMark;
@@ -14523,22 +14211,18 @@ function validationGrid(gridType = GridType.LINES, snapToGrid = BooleanNumber.FA
14523
14211
  return snapToGrid === BooleanNumber.TRUE && (gridType === GridType.LINES_AND_CHARS || gridType === GridType.SNAP_TO_CHARS);
14524
14212
  }
14525
14213
  function getLineHeightConfig(sectionBreakConfig, paragraphConfig) {
14526
- const { paragraphStyle = {}, useWordStyleLineHeight = false } = paragraphConfig;
14214
+ const { paragraphStyle = {} } = paragraphConfig;
14527
14215
  const { linePitch = 15.6, gridType = GridType.LINES, paragraphLineGapDefault = 0 } = sectionBreakConfig;
14528
- const hasDocumentGrid = gridType === GridType.LINES_AND_CHARS || gridType === GridType.SNAP_TO_CHARS;
14529
- const defaultSnapToGrid = useWordStyleLineHeight && !hasDocumentGrid ? BooleanNumber.FALSE : BooleanNumber.TRUE;
14530
- const { lineSpacing = 0, spacingRule = SpacingRule.AUTO, snapToGrid = defaultSnapToGrid } = paragraphStyle;
14216
+ const { lineSpacing = 0, spacingRule = SpacingRule.AUTO, snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
14531
14217
  let lineSpacingApply = lineSpacing;
14532
- if (useWordStyleLineHeight && lineSpacing === 0 && spacingRule === SpacingRule.AUTO) lineSpacingApply = 1;
14533
- else if (!useWordStyleLineHeight && (gridType === GridType.LINES || gridType === GridType.LINES_AND_CHARS) && lineSpacing === 0 && spacingRule === SpacingRule.AUTO) lineSpacingApply = 1;
14218
+ if ((gridType === GridType.LINES || gridType === GridType.LINES_AND_CHARS) && lineSpacing === 0 && spacingRule === SpacingRule.AUTO) lineSpacingApply = 1;
14534
14219
  return {
14535
14220
  paragraphLineGapDefault,
14536
14221
  linePitch,
14537
14222
  gridType,
14538
14223
  lineSpacing: lineSpacingApply,
14539
14224
  spacingRule,
14540
- snapToGrid,
14541
- useWordStyleLineHeight
14225
+ snapToGrid
14542
14226
  };
14543
14227
  }
14544
14228
  function getCharSpaceConfig(sectionBreakConfig, paragraphConfig) {
@@ -14645,16 +14329,13 @@ function updateBlockIndex(pages, start = -1) {
14645
14329
  }
14646
14330
  function updateInlineDrawingCoordsAndBorder(ctx, pages) {
14647
14331
  lineIterator(pages, (line, _, __, page) => {
14648
- var _ctx$paragraphConfigC, _ctx$skeletonResource, _paragraphStyle$shadi;
14332
+ var _ctx$paragraphConfigC, _ctx$skeletonResource;
14649
14333
  const { segmentId } = page;
14650
14334
  const paragraphConfig = (_ctx$paragraphConfigC = ctx.paragraphConfigCache.get(segmentId)) === null || _ctx$paragraphConfigC === void 0 ? void 0 : _ctx$paragraphConfigC.get(line.paragraphIndex);
14651
14335
  const affectInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphInlineSkeDrawings;
14652
- const affectNonInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphNonInlineSkeDrawings;
14653
14336
  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);
14654
- if (affectInlineDrawings && affectInlineDrawings.size > 0) updateInlineDrawingPosition(line, affectInlineDrawings, drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top, affectNonInlineDrawings);
14337
+ if (affectInlineDrawings && affectInlineDrawings.size > 0) updateInlineDrawingPosition(line, affectInlineDrawings, drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top);
14655
14338
  const paragraphStyle = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphStyle;
14656
- const paragraphBackgroundColor = paragraphStyle === null || paragraphStyle === void 0 || (_paragraphStyle$shadi = paragraphStyle.shading) === null || _paragraphStyle$shadi === void 0 ? void 0 : _paragraphStyle$shadi.backgroundColor;
14657
- if (paragraphBackgroundColor) line.backgroundColor = paragraphBackgroundColor;
14658
14339
  if (line.divides.length > 0) {
14659
14340
  const lastDivide = line.divides[line.divides.length - 1];
14660
14341
  const lastGlyph = lastDivide.glyphGroup[lastDivide.glyphGroup.length - 1];
@@ -14724,12 +14405,14 @@ function getPositionHorizon(positionH, column, page, objectWidth, isPageBreak =
14724
14405
  return absoluteLeft;
14725
14406
  }
14726
14407
  }
14727
- else if (posOffset != null) {
14408
+ else if (posOffset) {
14409
+ const { pageWidth, marginLeft, marginRight } = page;
14410
+ const boundaryRight = pageWidth - marginRight;
14728
14411
  let absoluteLeft = 0;
14729
- const { marginLeft } = page;
14730
14412
  if (relativeFrom === ObjectRelativeFromH.COLUMN) absoluteLeft = (isPageBreak ? 0 : (column === null || column === void 0 ? void 0 : column.left) || 0) + posOffset;
14731
14413
  else if (relativeFrom === ObjectRelativeFromH.LEFT_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.MARGIN) absoluteLeft = posOffset + marginLeft;
14732
14414
  else if (relativeFrom === ObjectRelativeFromH.RIGHT_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.INSIDE_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.OUTSIDE_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.PAGE) absoluteLeft = posOffset;
14415
+ if (absoluteLeft + objectWidth > boundaryRight) absoluteLeft = boundaryRight - objectWidth;
14733
14416
  return absoluteLeft;
14734
14417
  } else if (percent) {
14735
14418
  const { pageWidth, marginLeft, marginRight } = page;
@@ -14791,9 +14474,9 @@ function getFontConfigFromLastGlyph(glyph, sectionBreakConfig, paragraphStyle) {
14791
14474
  };
14792
14475
  }
14793
14476
  function getBulletParagraphTextStyle(bullet, viewModel) {
14794
- var _lists$listType;
14477
+ var _lists$listType$nesti;
14795
14478
  const { listType } = bullet;
14796
- return (_lists$listType = viewModel.getDataModel().getBulletPresetList()[listType]) === null || _lists$listType === void 0 || (_lists$listType = _lists$listType.nestingLevel) === null || _lists$listType === void 0 || (_lists$listType = _lists$listType[0]) === null || _lists$listType === void 0 || (_lists$listType = _lists$listType.paragraphProperties) === null || _lists$listType === void 0 ? void 0 : _lists$listType.textStyle;
14479
+ return (_lists$listType$nesti = viewModel.getDataModel().getBulletPresetList()[listType].nestingLevel[0].paragraphProperties) === null || _lists$listType$nesti === void 0 ? void 0 : _lists$listType$nesti.textStyle;
14797
14480
  }
14798
14481
  const DEFAULT_TEXT_RUN = {
14799
14482
  ts: {},
@@ -14801,7 +14484,6 @@ const DEFAULT_TEXT_RUN = {
14801
14484
  ed: 0
14802
14485
  };
14803
14486
  function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
14804
- var _sectionBreakConfig$d;
14805
14487
  const { gridType = GridType.LINES, charSpace = 0, documentTextStyle = {}, pageSize = {
14806
14488
  width: Number.POSITIVE_INFINITY,
14807
14489
  height: Number.POSITIVE_INFINITY
@@ -14833,20 +14515,16 @@ function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig
14833
14515
  ...customRangeStyle,
14834
14516
  ...bulletTextStyle
14835
14517
  };
14836
- const fontStyle = getFontStyleString(textStyle);
14837
- const mixTextStyle = {
14838
- ...documentTextStyle,
14839
- ...textStyle
14840
- };
14841
- const pageWidth = pageSize.width || Number.POSITIVE_INFINITY - marginLeft - marginRight;
14842
14518
  const result = {
14843
- fontStyle,
14844
- textStyle: mixTextStyle,
14519
+ fontStyle: getFontStyleString(textStyle),
14520
+ textStyle: {
14521
+ ...documentTextStyle,
14522
+ ...textStyle
14523
+ },
14845
14524
  charSpace,
14846
14525
  gridType,
14847
14526
  snapToGrid,
14848
- documentCompatibilityPolicy: (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy(),
14849
- pageWidth
14527
+ pageWidth: pageSize.width || Number.POSITIVE_INFINITY - marginLeft - marginRight
14850
14528
  };
14851
14529
  if (!hasAddonStyle && originTextRun) fontCreateConfigCache.setValue(st, ed, result);
14852
14530
  return result;
@@ -14981,6 +14659,17 @@ function resetContext(ctx) {
14981
14659
  ctx.isDirty = false;
14982
14660
  (_ctx$skeleton$drawing = ctx.skeleton.drawingAnchor) === null || _ctx$skeleton$drawing === void 0 || _ctx$skeleton$drawing.clear();
14983
14661
  }
14662
+ function mergeByV(object, originObject, type) {
14663
+ const mergeIterator = (obj, originObj, key) => {
14664
+ if (key !== "v") if (typeof originObj === "object") return mergeWith(obj, originObj, mergeIterator);
14665
+ else return originObj !== null && originObj !== void 0 ? originObj : obj;
14666
+ if (typeof originObj === "number") {
14667
+ if (typeof obj === "number") return type === "max" ? Math.max(originObj, obj) : Math.min(originObj, obj);
14668
+ }
14669
+ return originObj !== null && originObj !== void 0 ? originObj : obj;
14670
+ };
14671
+ return mergeWith(object, originObject, mergeIterator);
14672
+ }
14984
14673
  function getPageFromPath(skeletonData, path) {
14985
14674
  const pathCopy = [...path];
14986
14675
  let page = null;
@@ -15046,7 +14735,7 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
15046
14735
  header = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(pageWidth);
15047
14736
  } else if (headerTreeMap && headerTreeMap.has(headerId)) {
15048
14737
  header = _createSkeletonHeaderFooter(ctx, headerTreeMap.get(headerId), sectionBreakConfig, skeletonResourceReference, headerId, true);
15049
- skeHeaders.set(headerId, /* @__PURE__ */ new Map([[pageWidth, header]]));
14738
+ skeHeaders.set(headerId, new Map([[pageWidth, header]]));
15050
14739
  }
15051
14740
  page.headerId = headerId;
15052
14741
  }
@@ -15057,7 +14746,7 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
15057
14746
  footer = (_skeFooters$get2 = skeFooters.get(footerId)) === null || _skeFooters$get2 === void 0 ? void 0 : _skeFooters$get2.get(pageWidth);
15058
14747
  } else if (footerTreeMap && footerTreeMap.has(footerId)) {
15059
14748
  footer = _createSkeletonHeaderFooter(ctx, footerTreeMap.get(footerId), sectionBreakConfig, skeletonResourceReference, footerId, false);
15060
- skeFooters.set(footerId, /* @__PURE__ */ new Map([[pageWidth, footer]]));
14749
+ skeFooters.set(footerId, new Map([[pageWidth, footer]]));
15061
14750
  }
15062
14751
  page.footerId = footerId;
15063
14752
  }
@@ -15152,22 +14841,9 @@ function createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, avai
15152
14841
  const { skeletonResourceReference } = ctx;
15153
14842
  const { cellMargin, tableRows, tableColumns, tableId } = tableConfig;
15154
14843
  const cellConfig = tableRows[row].tableCells[col];
15155
- let { start = { v: 10 }, end = { v: 10 }, top = { v: 5 }, bottom = { v: 5 } } = (_ref = (_cellConfig$margin = cellConfig.margin) !== null && _cellConfig$margin !== void 0 ? _cellConfig$margin : cellMargin) !== null && _ref !== void 0 ? _ref : {};
14844
+ const { start = { v: 10 }, end = { v: 10 }, top = { v: 5 }, bottom = { v: 5 } } = (_ref = (_cellConfig$margin = cellConfig.margin) !== null && _cellConfig$margin !== void 0 ? _cellConfig$margin : cellMargin) !== null && _ref !== void 0 ? _ref : {};
15156
14845
  const columnSpan = Math.max(1, (_cellConfig$columnSpa = cellConfig.columnSpan) !== null && _cellConfig$columnSpa !== void 0 ? _cellConfig$columnSpa : 1);
15157
14846
  const pageWidth = tableColumns.slice(col, col + columnSpan).reduce((sum, column) => sum + column.size.width.v, 0);
15158
- if (start.v + end.v >= pageWidth) {
15159
- const marginWidth = start.v + end.v;
15160
- const availableMarginWidth = Math.max(0, pageWidth - 1);
15161
- const startRatio = marginWidth > 0 ? start.v / marginWidth : .5;
15162
- start = {
15163
- ...start,
15164
- v: availableMarginWidth * startRatio
15165
- };
15166
- end = {
15167
- ...end,
15168
- v: availableMarginWidth - start.v
15169
- };
15170
- }
15171
14847
  const pageHeight = maxCellPageHeight;
15172
14848
  const cellSectionBreakConfig = {
15173
14849
  lists,
@@ -15235,8 +14911,11 @@ function applyTrailingCellBlockRangeSpaceBelow(pages, body, cellEndIndex) {
15235
14911
  page.height += lastLine.spaceBelowApply || trailingBlockRangeSpace;
15236
14912
  }
15237
14913
  }
15238
- function _getVerticalMargin(marginTB, _headerOrFooter, _pageHeight) {
15239
- return marginTB;
14914
+ function _getVerticalMargin(marginTB, headerOrFooter, pageHeight) {
14915
+ if (!headerOrFooter || headerOrFooter.sections[0].columns[0].lines.length === 0) return marginTB;
14916
+ const HeaderFooterPageHeight = headerOrFooter.height + headerOrFooter.marginTop + headerOrFooter.marginBottom;
14917
+ const maxMargin = getHeaderFooterMaxHeight(pageHeight);
14918
+ return Math.min(maxMargin, Math.max(marginTB, HeaderFooterPageHeight));
15240
14919
  }
15241
14920
 
15242
14921
  //#endregion
@@ -15349,26 +15028,7 @@ function adjustGlyphsInDivide(divide, justificationRatio, extraJustification) {
15349
15028
  * Therefore, multiple calculations are performed, which may impact performance.
15350
15029
  * Needs optimization for efficiency.
15351
15030
  */
15352
- function shouldAllowOverflowHorizontalOffset(sectionBreakConfig) {
15353
- var _sectionBreakConfig$r;
15354
- return ((_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.wrapStrategy) === WrapStrategy.OVERFLOW;
15355
- }
15356
- function getGlyphGroupInkBounds(divide) {
15357
- if (divide.glyphGroup.length === 0) return null;
15358
- let left = Infinity;
15359
- let right = -Infinity;
15360
- for (const glyph of divide.glyphGroup) {
15361
- const glyphLeft = glyph.left + glyph.xOffset;
15362
- left = Math.min(left, glyphLeft);
15363
- right = Math.max(right, glyphLeft + glyph.bBox.width);
15364
- }
15365
- if (!Number.isFinite(left) || !Number.isFinite(right)) return null;
15366
- return {
15367
- left,
15368
- right
15369
- };
15370
- }
15371
- function horizontalAlignHandler(line, horizontalAlign, allowOverflowHorizontalOffset = false) {
15031
+ function horizontalAlignHandler(line, horizontalAlign) {
15372
15032
  const { divides } = line;
15373
15033
  for (let i = 0; i < divides.length; i++) {
15374
15034
  const divide = divides[i];
@@ -15407,12 +15067,9 @@ function horizontalAlignHandler(line, horizontalAlign, allowOverflowHorizontalOf
15407
15067
  divide.glyphGroupWidth = glyphGroupWidth;
15408
15068
  }
15409
15069
  }
15410
- const inkBounds = allowOverflowHorizontalOffset ? getGlyphGroupInkBounds(divide) : null;
15411
- if (horizontalAlign === HorizontalAlign.CENTER && inkBounds) divide.paddingLeft = width / 2 - (inkBounds.left + inkBounds.right) / 2;
15412
- else if (horizontalAlign === HorizontalAlign.RIGHT && inkBounds) divide.paddingLeft = width - inkBounds.right;
15413
- else if (horizontalAlign === HorizontalAlign.CENTER) divide.paddingLeft = (width - glyphGroupWidth) / 2;
15070
+ if (horizontalAlign === HorizontalAlign.CENTER) divide.paddingLeft = (width - glyphGroupWidth) / 2;
15414
15071
  else if (horizontalAlign === HorizontalAlign.RIGHT) divide.paddingLeft = width - glyphGroupWidth;
15415
- if (!allowOverflowHorizontalOffset) divide.paddingLeft = Math.max(divide.paddingLeft, 0);
15072
+ divide.paddingLeft = Math.max(divide.paddingLeft, 0);
15416
15073
  }
15417
15074
  }
15418
15075
  function restoreLastCJKGlyphWidth(line) {
@@ -15457,10 +15114,7 @@ function addHyphenDash(line, viewModel, paragraphNode, sectionBreakConfig, parag
15457
15114
  }
15458
15115
  function lineAdjustment(pages, viewModel, paragraphNode, sectionBreakConfig) {
15459
15116
  const { endIndex } = paragraphNode;
15460
- const paragraph = viewModel.getParagraph(endIndex) || {
15461
- startIndex: 0,
15462
- paragraphId: "para_render_fallback"
15463
- };
15117
+ const paragraph = viewModel.getParagraph(endIndex) || { startIndex: 0 };
15464
15118
  lineIterator(pages, (line) => {
15465
15119
  if (line.paragraphIndex !== paragraph.startIndex) return;
15466
15120
  const { paragraphStyle = {} } = paragraph;
@@ -15468,7 +15122,7 @@ function lineAdjustment(pages, viewModel, paragraphNode, sectionBreakConfig) {
15468
15122
  shrinkStartAndEndCJKPunctuation(line);
15469
15123
  restoreLastCJKGlyphWidth(line);
15470
15124
  addHyphenDash(line, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
15471
- horizontalAlignHandler(line, horizontalAlign, shouldAllowOverflowHorizontalOffset(sectionBreakConfig));
15125
+ horizontalAlignHandler(line, horizontalAlign);
15472
15126
  });
15473
15127
  }
15474
15128
 
@@ -15663,43 +15317,11 @@ function ___getLevelAndSuffix(levelAndSuffixPre) {
15663
15317
 
15664
15318
  //#endregion
15665
15319
  //#region src/components/docs/layout/block/paragraph/linebreaking.ts
15666
- const BLOCK_LAYOUT_OUTER_SPACING_MAP = /* @__PURE__ */ new Map([
15667
- [DocumentBlockRangeType.CALLOUT, 34],
15668
- [DocumentBlockRangeType.CODE, 32],
15669
- [DocumentBlockRangeType.QUOTE, 24]
15320
+ const BLOCK_LAYOUT_OUTER_SPACING_MAP = new Map([
15321
+ ["callout", 34],
15322
+ ["code", 32],
15323
+ ["quote", 24]
15670
15324
  ]);
15671
- function _endsWithToken(text, glyphs, token) {
15672
- var _glyphs, _glyphs2;
15673
- return text.endsWith(token) || ((_glyphs = glyphs[glyphs.length - 1]) === null || _glyphs === void 0 ? void 0 : _glyphs.raw) === token || ((_glyphs2 = glyphs[glyphs.length - 1]) === null || _glyphs2 === void 0 ? void 0 : _glyphs2.streamType) === token;
15674
- }
15675
- function _isMarkedDocxColumnBreak(viewModel, absoluteIndex) {
15676
- const customRange = viewModel.getCustomRange(absoluteIndex);
15677
- const properties = customRange === null || customRange === void 0 ? void 0 : customRange.properties;
15678
- return (properties === null || properties === void 0 ? void 0 : properties.docxBreakType) === "column";
15679
- }
15680
- function _glyphCount(glyphs) {
15681
- return glyphs.reduce((count, glyph) => count + glyph.count, 0);
15682
- }
15683
- function _hasOnlyCustomBlockGlyphs(glyphs) {
15684
- return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK);
15685
- }
15686
- function _mergeAdjacentCustomBlockShapedTexts(shapedTextList) {
15687
- const mergedShapedTextList = [];
15688
- for (const shapedText of shapedTextList) {
15689
- const lastShapedText = mergedShapedTextList[mergedShapedTextList.length - 1];
15690
- if (lastShapedText && _hasOnlyCustomBlockGlyphs(lastShapedText.glyphs) && _hasOnlyCustomBlockGlyphs(shapedText.glyphs)) {
15691
- lastShapedText.text += shapedText.text;
15692
- lastShapedText.glyphs.push(...shapedText.glyphs);
15693
- lastShapedText.breakPointType = shapedText.breakPointType;
15694
- continue;
15695
- }
15696
- mergedShapedTextList.push({
15697
- ...shapedText,
15698
- glyphs: [...shapedText.glyphs]
15699
- });
15700
- }
15701
- return mergedShapedTextList;
15702
- }
15703
15325
  function _getListLevelAncestors(bullet, listLevel) {
15704
15326
  if (!bullet || !listLevel) return;
15705
15327
  const { listId, nestingLevel } = bullet;
@@ -15770,23 +15392,12 @@ function _applyBlockRangeLayoutParagraphStyle(body, paragraph, paragraphStyle, s
15770
15392
  if ((lastParagraph === null || lastParagraph === void 0 ? void 0 : lastParagraph.startIndex) === paragraph.startIndex && !_hasNextAdjacentLayoutBlockRange(blockRanges, blockRange)) _withMinSpacing(style, "spaceBelow", outerSpacing);
15771
15393
  return style;
15772
15394
  }
15773
- function _isOnlyFloatingCustomBlockParagraph(viewModel, paragraphNode, drawings) {
15774
- var _paragraphNode$blocks, _paragraphNode$conten;
15775
- if (!((_paragraphNode$blocks = paragraphNode.blocks) === null || _paragraphNode$blocks === void 0 ? void 0 : _paragraphNode$blocks.length)) return false;
15776
- if (!((_paragraphNode$conten = paragraphNode.content) !== null && _paragraphNode$conten !== void 0 ? _paragraphNode$conten : "").split("").every((char) => char === DataStreamTreeTokenType.CUSTOM_BLOCK || char === DataStreamTreeTokenType.PARAGRAPH || char === DataStreamTreeTokenType.SECTION_BREAK)) return false;
15777
- return paragraphNode.blocks.every((charIndex) => {
15778
- const customBlock = viewModel.getCustomBlock(charIndex);
15779
- const drawing = customBlock == null ? null : drawings[customBlock.blockId];
15780
- return drawing != null && drawing.layoutType !== PositionedObjectLayoutType.INLINE;
15781
- });
15782
- }
15783
- function _getFollowingIndentedParagraphAnchorLeft(viewModel, paragraph, paragraphNode, drawings, isTraditionalDocument) {
15784
- var _paragraph$paragraphS, _paragraph$paragraphS2, _viewModel$getBody$pa, _viewModel$getBody, _paragraphs$0$paragra, _paragraphs$, _paragraphs$0$paragra2;
15785
- if (!isTraditionalDocument) return;
15786
- if (((_paragraph$paragraphS = (_paragraph$paragraphS2 = paragraph.paragraphStyle) === null || _paragraph$paragraphS2 === void 0 || (_paragraph$paragraphS2 = _paragraph$paragraphS2.indentStart) === null || _paragraph$paragraphS2 === void 0 ? void 0 : _paragraph$paragraphS2.v) !== null && _paragraph$paragraphS !== void 0 ? _paragraph$paragraphS : 0) > 0) return;
15787
- if (!_isOnlyFloatingCustomBlockParagraph(viewModel, paragraphNode, drawings)) return;
15788
- const paragraphs = [...(_viewModel$getBody$pa = (_viewModel$getBody = viewModel.getBody) === null || _viewModel$getBody === void 0 || (_viewModel$getBody = _viewModel$getBody.call(viewModel)) === null || _viewModel$getBody === void 0 ? void 0 : _viewModel$getBody.paragraphs) !== null && _viewModel$getBody$pa !== void 0 ? _viewModel$getBody$pa : []].filter((item) => item.startIndex > paragraph.startIndex).sort((left, right) => left.startIndex - right.startIndex);
15789
- return ((_paragraphs$0$paragra = (_paragraphs$ = paragraphs[0]) === null || _paragraphs$ === void 0 || (_paragraphs$ = _paragraphs$.paragraphStyle) === null || _paragraphs$ === void 0 || (_paragraphs$ = _paragraphs$.indentStart) === null || _paragraphs$ === void 0 ? void 0 : _paragraphs$.v) !== null && _paragraphs$0$paragra !== void 0 ? _paragraphs$0$paragra : 0) > 0 ? (_paragraphs$0$paragra2 = paragraphs[0].paragraphStyle) === null || _paragraphs$0$paragra2 === void 0 ? void 0 : _paragraphs$0$paragra2.indentStart : void 0;
15395
+ function _shouldApplyDocumentDefaultParagraphStyle(viewModel) {
15396
+ var _viewModel$getSnapsho;
15397
+ const snapshot = (_viewModel$getSnapsho = viewModel.getSnapshot) === null || _viewModel$getSnapsho === void 0 ? void 0 : _viewModel$getSnapsho.call(viewModel);
15398
+ const documentFlavor = snapshot === null || snapshot === void 0 ? void 0 : snapshot.documentStyle.documentFlavor;
15399
+ if (snapshot == null) return true;
15400
+ return documentFlavor != null && documentFlavor !== DocumentFlavor.UNSPECIFIED;
15790
15401
  }
15791
15402
  function _getDrawingSkeletonFormat(drawingOrigin) {
15792
15403
  const { drawingId } = drawingOrigin;
@@ -15810,24 +15421,16 @@ function _getNextPageNumber(lastPage) {
15810
15421
  return lastPage.pageNumber + 1;
15811
15422
  }
15812
15423
  function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, sectionBreakConfig, tableSkeleton) {
15813
- var _sectionBreakConfig$d, _viewModel$getSnapsho, _viewModel$getBody2, _viewModel$getBody3;
15424
+ var _viewModel$getBody, _viewModel$getBody2;
15814
15425
  const { skeletonResourceReference } = ctx;
15815
15426
  const { lists, drawings = {}, localeService } = sectionBreakConfig;
15816
15427
  const { endIndex, blocks = [], children } = paragraphNode;
15817
15428
  const { segmentId } = curPage;
15818
- const paragraph = viewModel.getParagraph(endIndex) || {
15819
- startIndex: 0,
15820
- paragraphId: "para_render_fallback"
15821
- };
15429
+ const paragraph = viewModel.getParagraph(endIndex) || { startIndex: 0 };
15822
15430
  const { paragraphStyle = {}, bullet } = paragraph;
15823
- 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);
15824
- const shouldApplyDocumentDefaults = documentCompatibilityPolicy.applyDocumentDefaultParagraphStyle;
15825
- const useWordStyleLineHeight = documentCompatibilityPolicy.useWordStyleLineHeight;
15826
15431
  const { skeHeaders, skeFooters, skeListLevel, drawingAnchor } = skeletonResourceReference;
15827
15432
  const paragraphNonInlineSkeDrawings = /* @__PURE__ */ new Map();
15828
15433
  const paragraphInlineSkeDrawings = /* @__PURE__ */ new Map();
15829
- const paragraphNonInlineSkeDrawingsByBlockId = /* @__PURE__ */ new Map();
15830
- const paragraphInlineSkeDrawingsByBlockId = /* @__PURE__ */ new Map();
15831
15434
  let segmentDrawingAnchorCache = drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.get(segmentId);
15832
15435
  if (segmentDrawingAnchorCache == null) {
15833
15436
  segmentDrawingAnchorCache = /* @__PURE__ */ new Map();
@@ -15835,10 +15438,7 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
15835
15438
  }
15836
15439
  const paragraphConfig = {
15837
15440
  paragraphIndex: endIndex,
15838
- documentCompatibilityPolicy,
15839
- 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),
15840
- docxFallbackAnchorLeft: _getFollowingIndentedParagraphAnchorLeft(viewModel, paragraph, paragraphNode, drawings, isTraditionalDocumentCompatibility(documentCompatibilityPolicy)),
15841
- useWordStyleLineHeight,
15441
+ paragraphStyle: _applyBlockRangeLayoutParagraphStyle((_viewModel$getBody = (_viewModel$getBody2 = viewModel.getBody) === null || _viewModel$getBody2 === void 0 ? void 0 : _viewModel$getBody2.call(viewModel)) !== null && _viewModel$getBody !== void 0 ? _viewModel$getBody : null, paragraph, paragraphStyle, _shouldApplyDocumentDefaultParagraphStyle(viewModel)),
15842
15442
  paragraphNonInlineSkeDrawings,
15843
15443
  paragraphInlineSkeDrawings,
15844
15444
  skeTablesInParagraph: tableSkeleton ? [{
@@ -15871,60 +15471,36 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
15871
15471
  if (customBlock == null) continue;
15872
15472
  const { blockId } = customBlock;
15873
15473
  const drawingOrigin = drawings[blockId];
15874
- if (drawingOrigin == null) continue;
15875
- if (drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE) paragraphInlineSkeDrawingsByBlockId.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
15876
- else paragraphNonInlineSkeDrawingsByBlockId.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
15474
+ if (drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE) paragraphInlineSkeDrawings.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
15475
+ else paragraphNonInlineSkeDrawings.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
15877
15476
  }
15878
15477
  segmentParagraphCache.set(endIndex, paragraphConfig);
15879
15478
  let allPages = [curPage];
15880
15479
  let isParagraphFirstShapedText = true;
15881
- let shapedTextOffset = 0;
15882
- for (const [_index, { text, glyphs, breakPointType }] of _mergeAdjacentCustomBlockShapedTexts(shapedTextList).entries()) {
15883
- const textStartIndex = paragraphNode.startIndex + shapedTextOffset;
15884
- const textGlyphCount = _glyphCount(glyphs);
15885
- const textEndIndex = textStartIndex + textGlyphCount;
15480
+ for (const [_index, { text, glyphs, breakPointType }] of shapedTextList.entries()) {
15886
15481
  const pushPending = () => {
15887
15482
  if (glyphs.length === 0) return;
15888
- syncActiveParagraphDrawings(glyphs, paragraphNonInlineSkeDrawings, paragraphInlineSkeDrawings, paragraphNonInlineSkeDrawingsByBlockId, paragraphInlineSkeDrawingsByBlockId);
15889
- allPages = layoutParagraph(ctx, glyphs, allPages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText || hasOnlyFloatingCustomBlockGlyphs(glyphs, paragraphNonInlineSkeDrawingsByBlockId), breakPointType);
15483
+ allPages = layoutParagraph(ctx, glyphs, allPages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
15890
15484
  isParagraphFirstShapedText = false;
15891
15485
  };
15892
- if (_endsWithToken(text, glyphs, DataStreamTreeTokenType.PAGE_BREAK)) {
15486
+ if (text.endsWith(DataStreamTreeTokenType.PAGE_BREAK)) {
15893
15487
  pushPending();
15894
15488
  allPages.push(createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, _getNextPageNumber(allPages[allPages.length - 1]), 1));
15895
15489
  paragraphNonInlineSkeDrawings.clear();
15896
- isParagraphFirstShapedText = true;
15897
- shapedTextOffset += textGlyphCount;
15490
+ paragraphInlineSkeDrawings.clear();
15898
15491
  continue;
15899
- } else if (_endsWithToken(text, glyphs, DataStreamTreeTokenType.COLUMN_BREAK) && (!isTraditionalDocumentCompatibility(documentCompatibilityPolicy) || _isMarkedDocxColumnBreak(viewModel, textEndIndex - 1))) {
15492
+ } else if (text.endsWith(DataStreamTreeTokenType.COLUMN_BREAK)) {
15900
15493
  pushPending();
15901
15494
  const lastPage = allPages[allPages.length - 1];
15902
15495
  const columnInfo = getLastNotFullColumnInfo(lastPage);
15903
15496
  if (columnInfo && !columnInfo.isLast) setColumnFullState(columnInfo.column, true);
15904
15497
  else allPages.push(createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, _getNextPageNumber(lastPage), 2));
15905
- shapedTextOffset += textGlyphCount;
15906
15498
  continue;
15907
15499
  }
15908
15500
  pushPending();
15909
- shapedTextOffset += textGlyphCount;
15910
15501
  }
15911
15502
  return allPages;
15912
15503
  }
15913
- function syncActiveParagraphDrawings(glyphs, paragraphNonInlineSkeDrawings, paragraphInlineSkeDrawings, paragraphNonInlineSkeDrawingsByBlockId, paragraphInlineSkeDrawingsByBlockId) {
15914
- for (const glyph of glyphs) {
15915
- if (glyph.streamType !== DataStreamTreeTokenType.CUSTOM_BLOCK || glyph.drawingId == null) continue;
15916
- const inlineDrawing = paragraphInlineSkeDrawingsByBlockId.get(glyph.drawingId);
15917
- if (inlineDrawing != null) {
15918
- paragraphInlineSkeDrawings.set(glyph.drawingId, inlineDrawing);
15919
- continue;
15920
- }
15921
- const nonInlineDrawing = paragraphNonInlineSkeDrawingsByBlockId.get(glyph.drawingId);
15922
- if (nonInlineDrawing != null) paragraphNonInlineSkeDrawings.set(glyph.drawingId, nonInlineDrawing);
15923
- }
15924
- }
15925
- function hasOnlyFloatingCustomBlockGlyphs(glyphs, paragraphNonInlineSkeDrawingsByBlockId) {
15926
- return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.drawingId != null && paragraphNonInlineSkeDrawingsByBlockId.has(glyph.drawingId));
15927
- }
15928
15504
 
15929
15505
  //#endregion
15930
15506
  //#region src/components/docs/layout/line-breaker/enhancers/hyphen-enhancer.ts
@@ -16248,26 +15824,6 @@ function prepareTextChunks(body) {
16248
15824
  //#region src/components/docs/layout/shaping-engine/text-shaping.ts
16249
15825
  const fontCache = /* @__PURE__ */ new Map();
16250
15826
  const glyphCache = /* @__PURE__ */ new Map();
16251
- const fontFamilyCache = /* @__PURE__ */ new Map();
16252
- function trimOuterQuotes(value) {
16253
- const firstChar = value.charCodeAt(0);
16254
- const lastChar = value.charCodeAt(value.length - 1);
16255
- const hasLeadingQuote = firstChar === 34 || firstChar === 39;
16256
- const hasTrailingQuote = lastChar === 34 || lastChar === 39;
16257
- if (hasLeadingQuote && hasTrailingQuote) return value.slice(1, -1);
16258
- if (hasLeadingQuote) return value.slice(1);
16259
- if (hasTrailingQuote) return value.slice(0, -1);
16260
- return value;
16261
- }
16262
- function expandFontFamilies(fontFamily) {
16263
- if (!(fontFamily === null || fontFamily === void 0 ? void 0 : fontFamily.trim())) return [];
16264
- let families = fontFamilyCache.get(fontFamily);
16265
- if (families) return families;
16266
- families = fontFamily.split(",").map((family) => trimOuterQuotes(family.trim())).filter(Boolean);
16267
- fontFamilyCache.set(fontFamily, families);
16268
- return families;
16269
- }
16270
- const defaultFontFamilies = expandFontFamilies(DEFAULT_FONTFACE_PLANE);
16271
15827
  function shapeChunk(content, charPosition, used, families, style) {
16272
15828
  var _style$bl, _style$it, _content$match;
16273
15829
  let fi = 0;
@@ -16370,7 +15926,8 @@ function textShape(body) {
16370
15926
  for (const chunk of chunks) {
16371
15927
  var _style$ff;
16372
15928
  const { content, style = {} } = chunk;
16373
- let fontFamilies = [...expandFontFamilies((_style$ff = style.ff) !== null && _style$ff !== void 0 ? _style$ff : "Arial"), ...defaultFontFamilies];
15929
+ let fontFamilies = DEFAULT_FONTFACE_PLANE.split(",").map((family) => family.trim().replace(/["']/g, ""));
15930
+ fontFamilies.unshift((_style$ff = style.ff) !== null && _style$ff !== void 0 ? _style$ff : "Arial");
16374
15931
  fontFamilies = fontLibrary.getValidFontFamilies(fontFamilies);
16375
15932
  glyphs.push(...shapeChunk(content, charPosition, /* @__PURE__ */ new Set(), fontFamilies, style));
16376
15933
  charPosition += content.length;
@@ -16408,7 +15965,7 @@ function ArabicHandler(index, charArray, viewModel, paragraphNode, sectionBreakC
16408
15965
  for (let i = 0; i < charArray.length; i++) {
16409
15966
  const newChar = charArray[i];
16410
15967
  if (hasArabic(newChar)) {
16411
- glyph.push(newChar);
15968
+ glyph.unshift(newChar);
16412
15969
  step++;
16413
15970
  } else break;
16414
15971
  }
@@ -16505,10 +16062,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
16505
16062
  const shapedTextList = [];
16506
16063
  let breaker = new LineBreaker(content);
16507
16064
  const { endIndex } = paragraphNode;
16508
- const paragraph = viewModel.getParagraph(endIndex) || {
16509
- startIndex: 0,
16510
- paragraphId: "para_render_fallback"
16511
- };
16065
+ const paragraph = viewModel.getParagraph(endIndex) || { startIndex: 0 };
16512
16066
  const { paragraphStyle = {} } = paragraph;
16513
16067
  const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
16514
16068
  let last = 0;
@@ -16567,12 +16121,12 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
16567
16121
  if (customBlock != null) {
16568
16122
  const { blockId } = customBlock;
16569
16123
  const drawingOrigin = drawings[blockId];
16570
- if ((drawingOrigin === null || drawingOrigin === void 0 ? void 0 : drawingOrigin.layoutType) === PositionedObjectLayoutType.INLINE) {
16124
+ if (drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE) {
16571
16125
  const { angle } = drawingOrigin.docTransform;
16572
16126
  const { width = 0, height = 0 } = drawingOrigin.docTransform.size;
16573
16127
  const boundingBox = getBoundingBox(angle, 0, width, 0, height);
16574
16128
  newGlyph = createSkeletonCustomBlockGlyph(config, boundingBox.width, boundingBox.height, drawingOrigin.drawingId);
16575
- } else if (drawingOrigin != null) newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
16129
+ } else newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
16576
16130
  }
16577
16131
  if (newGlyph == null) newGlyph = createSkeletonLetterGlyph(char, config);
16578
16132
  shapedGlyphs.push(newGlyph);
@@ -17514,9 +17068,9 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17514
17068
  const viewport = getDocsTableRenderViewport(unitId, sourceTableId);
17515
17069
  (_this$_findLiquid = this._findLiquid) === null || _this$_findLiquid === void 0 || _this$_findLiquid.translateSave();
17516
17070
  (_this$_findLiquid2 = this._findLiquid) === null || _this$_findLiquid2 === void 0 || _this$_findLiquid2.translate(tableLeft, tableTop);
17517
- if (hasDocsTableHorizontalViewport(viewport)) {
17518
- var _viewport$leadingInse, _this$_findLiquid4;
17519
- const visibleLeft = this._findLiquid.x + page.marginLeft - ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0);
17071
+ if (viewport && viewport.contentWidth > viewport.viewportWidth) {
17072
+ var _this$_findLiquid4;
17073
+ const visibleLeft = this._findLiquid.x;
17520
17074
  const visibleRight = visibleLeft + viewport.viewportWidth;
17521
17075
  if (x < visibleLeft || x > visibleRight) {
17522
17076
  var _this$_findLiquid3;
@@ -17612,7 +17166,6 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17612
17166
  lists,
17613
17167
  drawings,
17614
17168
  localeService: this._localeService,
17615
- documentCompatibilityPolicy: getDocumentCompatibilityPolicy(documentStyle.documentFlavor),
17616
17169
  paragraphLineGapDefault,
17617
17170
  defaultTabStop,
17618
17171
  documentTextStyle: textStyle
@@ -17687,7 +17240,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
17687
17240
  let curSkeletonPage = getLastPage(allSkeletonPages);
17688
17241
  let isContinuous = false;
17689
17242
  ctx.sectionBreakConfigCache.set(sectionNode.endIndex, sectionBreakConfig);
17690
- if (sectionType === SectionType.CONTINUOUS && curSkeletonPage != null) {
17243
+ if (sectionType === SectionType.CONTINUOUS) {
17691
17244
  updateBlockIndex(allSkeletonPages);
17692
17245
  this._addNewSectionByContinuous(curSkeletonPage, columnProperties, columnSeparatorType);
17693
17246
  isContinuous = true;
@@ -17819,7 +17372,6 @@ function createDocumentModelWithStyle(content, textStyle, config = {}) {
17819
17372
  }],
17820
17373
  paragraphs: [{
17821
17374
  startIndex: contentLength,
17822
- paragraphId: createParagraphId(/* @__PURE__ */ new Set()),
17823
17375
  paragraphStyle: { horizontalAlign }
17824
17376
  }],
17825
17377
  sectionBreaks: [{ startIndex: contentLength + 1 }]
@@ -17876,7 +17428,7 @@ function getFontFormat(format) {
17876
17428
  }
17877
17429
 
17878
17430
  //#endregion
17879
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
17431
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
17880
17432
  function __decorateParam(paramIndex, decorator) {
17881
17433
  return function(target, key) {
17882
17434
  decorator(target, key, paramIndex);
@@ -17884,7 +17436,7 @@ function __decorateParam(paramIndex, decorator) {
17884
17436
  }
17885
17437
 
17886
17438
  //#endregion
17887
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
17439
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
17888
17440
  function __decorate(decorators, target, key, desc) {
17889
17441
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17890
17442
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -18697,7 +18249,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
18697
18249
  this.makeDirty(true);
18698
18250
  }
18699
18251
  _setBorderStylesCache(row, col, style, options) {
18700
- if (Tools.isDefine(this._handleBorderMatrix.getValue(row, col)) && !(options === null || options === void 0 ? void 0 : options.mergeRange)) return;
18252
+ if (Tools.isDefine(this._handleBorderMatrix.getValue(row, col))) return;
18701
18253
  if (!((options === null || options === void 0 ? void 0 : options.cacheItem) || {
18702
18254
  bg: true,
18703
18255
  border: true
@@ -19836,56 +19388,6 @@ var docExtension = class extends ComponentExtension {
19836
19388
  }
19837
19389
  };
19838
19390
 
19839
- //#endregion
19840
- //#region src/components/docs/extensions/background-runs.ts
19841
- function collectBackgroundGlyphRuns(glyphGroup) {
19842
- const runs = [];
19843
- let activeGlyph = null;
19844
- let activeColor = "";
19845
- let activeLeft = 0;
19846
- let activeRight = 0;
19847
- const flush = () => {
19848
- if (!activeGlyph) return;
19849
- runs.push({
19850
- glyph: {
19851
- ...activeGlyph,
19852
- width: activeRight - activeLeft
19853
- },
19854
- left: activeLeft,
19855
- width: activeRight - activeLeft
19856
- });
19857
- activeGlyph = null;
19858
- activeColor = "";
19859
- activeLeft = 0;
19860
- activeRight = 0;
19861
- };
19862
- for (const glyph of glyphGroup) {
19863
- var _glyph$ts;
19864
- if (!glyph.content || glyph.content === "\r") {
19865
- flush();
19866
- continue;
19867
- }
19868
- const backgroundColor = ((_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.bg) ? getColorStyle(glyph.ts.bg) : "";
19869
- if (!backgroundColor) {
19870
- flush();
19871
- continue;
19872
- }
19873
- const glyphLeft = glyph.left;
19874
- const glyphRight = glyph.left + glyph.width;
19875
- if (activeGlyph && activeColor === backgroundColor) {
19876
- activeRight = Math.max(activeRight, glyphRight);
19877
- continue;
19878
- }
19879
- flush();
19880
- activeGlyph = glyph;
19881
- activeColor = backgroundColor;
19882
- activeLeft = glyphLeft;
19883
- activeRight = glyphRight;
19884
- }
19885
- flush();
19886
- return runs;
19887
- }
19888
-
19889
19391
  //#endregion
19890
19392
  //#region src/components/docs/extensions/background.ts
19891
19393
  const UNIQUE_KEY$3 = "DefaultDocsBackgroundExtension";
@@ -20301,6 +19803,7 @@ var Image$1 = class extends Shape {
20301
19803
  this.makeDirty(true);
20302
19804
  } else if (config.url) {
20303
19805
  this._native = document.createElement("img");
19806
+ this._native.src = config.url;
20304
19807
  this._native.crossOrigin = "anonymous";
20305
19808
  this._native.onload = () => {
20306
19809
  var _config$success, _this$getEngine;
@@ -20315,7 +19818,6 @@ var Image$1 = class extends Shape {
20315
19818
  this.makeDirty(true);
20316
19819
  }
20317
19820
  };
20318
- this._native.src = config.url;
20319
19821
  }
20320
19822
  this._init();
20321
19823
  }
@@ -20329,17 +19831,10 @@ var Image$1 = class extends Shape {
20329
19831
  var _this$_props$opacity;
20330
19832
  return (_this$_props$opacity = this._props.opacity) !== null && _this$_props$opacity !== void 0 ? _this$_props$opacity : 1;
20331
19833
  }
20332
- get clipBounds() {
20333
- return this._props.clipBounds;
20334
- }
20335
19834
  setOpacity(opacity) {
20336
19835
  this._props.opacity = opacity;
20337
19836
  this.makeDirty(true);
20338
19837
  }
20339
- setClipBounds(clipBounds) {
20340
- this._props.clipBounds = clipBounds;
20341
- this.makeDirty(true);
20342
- }
20343
19838
  setClipService(clipService) {
20344
19839
  this._clipService = clipService;
20345
19840
  }
@@ -20356,10 +19851,10 @@ var Image$1 = class extends Shape {
20356
19851
  }
20357
19852
  changeSource(url) {
20358
19853
  if (this._native == null) this._native = document.createElement("img");
19854
+ this._native.src = url;
20359
19855
  this._native.onload = () => {
20360
19856
  this.makeDirty(true);
20361
19857
  };
20362
- this._native.src = url;
20363
19858
  }
20364
19859
  resetSize() {
20365
19860
  if (this._native == null) return;
@@ -20465,12 +19960,6 @@ var Image$1 = class extends Shape {
20465
19960
  }
20466
19961
  const m = this.transform.getMatrix();
20467
19962
  mainCtx.save();
20468
- const { clipBounds } = this;
20469
- if (clipBounds) {
20470
- mainCtx.beginPath();
20471
- mainCtx.rect(clipBounds.left, clipBounds.top, clipBounds.width, clipBounds.height);
20472
- mainCtx.clip();
20473
- }
20474
19963
  const centerX = realLeft + realWidth / 2;
20475
19964
  const centerY = realTop + realHeight / 2;
20476
19965
  mainCtx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
@@ -22111,7 +21600,6 @@ var FontAndBaseLine = class extends docExtension {
22111
21600
  "actualFontMap",
22112
21601
  {}
22113
21602
  );
22114
- _defineProperty(this, "_textFillImageCache", /* @__PURE__ */ new Map());
22115
21603
  }
22116
21604
  draw(ctx, _parentScale, glyph, _, _more) {
22117
21605
  var _glyph$parent;
@@ -22130,162 +21618,13 @@ var FontAndBaseLine = class extends docExtension {
22130
21618
  this.actualFontMap[fontStringPxStr] = ctx.font;
22131
21619
  }
22132
21620
  }
22133
- const { cl: colorStyle, va: baselineOffset, textFill } = textStyle;
21621
+ const { cl: colorStyle, va: baselineOffset } = textStyle;
22134
21622
  const fontColor = getColorStyle(colorStyle) || "rgb(0,0,0)";
21623
+ if (fontColor && this._preFontColor !== fontColor) ctx.fillStyle = fontColor;
22135
21624
  if (baselineOffset === BaselineOffset.SUPERSCRIPT) spanPointWithFont.y += -bBox.spo;
22136
21625
  else if (baselineOffset === BaselineOffset.SUBSCRIPT) spanPointWithFont.y += bBox.sbo;
22137
- if (this._fillTextWithTextFill(ctx, glyph, spanPointWithFont, textFill, fontColor)) return;
22138
- if (fontColor && this._preFontColor !== fontColor) ctx.fillStyle = fontColor;
22139
21626
  this._fillText(ctx, glyph, spanPointWithFont);
22140
21627
  }
22141
- _fillTextWithTextFill(ctx, glyph, spanPointWithFont, textFill, fallbackColor) {
22142
- if (!textFill || textFill.type === "none") return (textFill === null || textFill === void 0 ? void 0 : textFill.type) === "none";
22143
- const { content, glyphType } = glyph;
22144
- if (content == null || glyphType === 2) return false;
22145
- const { renderConfig } = this.extensionOffset;
22146
- const { vertexAngle, centerAngle } = renderConfig !== null && renderConfig !== void 0 ? renderConfig : {};
22147
- const VERTICAL_DEG = 90;
22148
- if (vertexAngle === VERTICAL_DEG && centerAngle === VERTICAL_DEG) return false;
22149
- const bounds = this._getGlyphPaintBounds(glyph, spanPointWithFont);
22150
- if (bounds.width <= 0 || bounds.height <= 0) return false;
22151
- const color = this._colorWithOpacity(textFill.color || fallbackColor, textFill.opacity);
22152
- if (textFill.type === "solid") {
22153
- ctx.fillStyle = color;
22154
- this._fillText(ctx, glyph, spanPointWithFont);
22155
- return true;
22156
- }
22157
- if (textFill.type === "gradient") {
22158
- const gradient = this._createTextGradient(ctx, bounds, textFill, fallbackColor);
22159
- if (!gradient) return false;
22160
- ctx.fillStyle = gradient;
22161
- this._fillText(ctx, glyph, spanPointWithFont);
22162
- return true;
22163
- }
22164
- if (textFill.type === "picture") {
22165
- const pattern = this._createTextPicturePattern(ctx, bounds, textFill);
22166
- if (!pattern) return false;
22167
- ctx.fillStyle = pattern;
22168
- this._fillText(ctx, glyph, spanPointWithFont);
22169
- return true;
22170
- }
22171
- return false;
22172
- }
22173
- _getGlyphPaintBounds(glyph, spanPointWithFont) {
22174
- const { width, bBox } = glyph;
22175
- const textWidth = Math.max(width, bBox.width, 1);
22176
- const textHeight = Math.max(bBox.aba + bBox.abd, 1);
22177
- return {
22178
- left: spanPointWithFont.x,
22179
- top: spanPointWithFont.y - bBox.aba,
22180
- width: textWidth,
22181
- height: textHeight
22182
- };
22183
- }
22184
- _createTextGradient(ctx, bounds, textFill, fallbackColor) {
22185
- var _gradient$type, _gradient$angle, _context;
22186
- const gradient = textFill.gradient;
22187
- const type = (_gradient$type = gradient === null || gradient === void 0 ? void 0 : gradient.type) !== null && _gradient$type !== void 0 ? _gradient$type : "linear";
22188
- const angle = (_gradient$angle = gradient === null || gradient === void 0 ? void 0 : gradient.angle) !== null && _gradient$angle !== void 0 ? _gradient$angle : 0;
22189
- const stops = this._normalizeGradientStops(gradient === null || gradient === void 0 ? void 0 : gradient.stops, textFill.color || fallbackColor);
22190
- const centerX = bounds.left + bounds.width / 2;
22191
- const centerY = bounds.top + bounds.height / 2;
22192
- let canvasGradient;
22193
- if (type === "radial") {
22194
- const radius = Math.max(bounds.width, bounds.height) / 2;
22195
- canvasGradient = ctx.createRadialGradient(centerX, centerY, 0, centerX, centerY, radius);
22196
- } else if (type === "angular" && "createConicGradient" in ((_context = ctx._context) !== null && _context !== void 0 ? _context : ctx)) {
22197
- var _context2;
22198
- canvasGradient = ((_context2 = ctx._context) !== null && _context2 !== void 0 ? _context2 : ctx).createConicGradient((angle - 90) * Math.PI / 180, centerX, centerY);
22199
- } else if (type === "diamond") {
22200
- const radius = Math.max(bounds.width, bounds.height) / 2;
22201
- canvasGradient = ctx.createRadialGradient(centerX, centerY, 0, centerX, centerY, radius);
22202
- } else {
22203
- const line = this._getLinearGradientLine(bounds, angle);
22204
- canvasGradient = ctx.createLinearGradient(line.x0, line.y0, line.x1, line.y1);
22205
- }
22206
- for (const stop of stops) {
22207
- var _textFill$opacity, _stop$opacity;
22208
- const opacity = ((_textFill$opacity = textFill.opacity) !== null && _textFill$opacity !== void 0 ? _textFill$opacity : 1) * ((_stop$opacity = stop.opacity) !== null && _stop$opacity !== void 0 ? _stop$opacity : 1);
22209
- canvasGradient.addColorStop(stop.offset, this._colorWithOpacity(stop.color, opacity));
22210
- }
22211
- return canvasGradient;
22212
- }
22213
- _createTextPicturePattern(ctx, bounds, textFill) {
22214
- var _textFill$picture, _ref, _textFill$picture$opa, _textFill$picture2, _textFill$picture3, _pattern$setTransform;
22215
- const source = (_textFill$picture = textFill.picture) === null || _textFill$picture === void 0 ? void 0 : _textFill$picture.source;
22216
- if (!source) return null;
22217
- const image = this._getTextFillImage(source);
22218
- if (!image || !image.complete || !(image.naturalWidth || image.width)) return null;
22219
- const canvas = document.createElement("canvas");
22220
- canvas.width = Math.max(1, Math.ceil(bounds.width));
22221
- canvas.height = Math.max(1, Math.ceil(bounds.height));
22222
- const canvasContext = canvas.getContext("2d");
22223
- if (!canvasContext) return null;
22224
- canvasContext.globalAlpha = this._clamp((_ref = (_textFill$picture$opa = (_textFill$picture2 = textFill.picture) === null || _textFill$picture2 === void 0 ? void 0 : _textFill$picture2.opacity) !== null && _textFill$picture$opa !== void 0 ? _textFill$picture$opa : textFill.opacity) !== null && _ref !== void 0 ? _ref : 1, 0, 1);
22225
- if (((_textFill$picture3 = textFill.picture) === null || _textFill$picture3 === void 0 ? void 0 : _textFill$picture3.mode) === "tile") {
22226
- var _textFill$picture$sca, _textFill$picture$sca2, _textFill$picture$off, _textFill$picture$off2;
22227
- const scaleX = (_textFill$picture$sca = textFill.picture.scaleX) !== null && _textFill$picture$sca !== void 0 ? _textFill$picture$sca : 1;
22228
- const scaleY = (_textFill$picture$sca2 = textFill.picture.scaleY) !== null && _textFill$picture$sca2 !== void 0 ? _textFill$picture$sca2 : 1;
22229
- const cellWidth = Math.max(1, (image.naturalWidth || image.width) * scaleX);
22230
- const cellHeight = Math.max(1, (image.naturalHeight || image.height) * scaleY);
22231
- const offsetX = (_textFill$picture$off = textFill.picture.offsetX) !== null && _textFill$picture$off !== void 0 ? _textFill$picture$off : 0;
22232
- const offsetY = (_textFill$picture$off2 = textFill.picture.offsetY) !== null && _textFill$picture$off2 !== void 0 ? _textFill$picture$off2 : 0;
22233
- for (let x = (offsetX % cellWidth + cellWidth) % cellWidth - cellWidth; x < canvas.width; x += cellWidth) for (let y = (offsetY % cellHeight + cellHeight) % cellHeight - cellHeight; y < canvas.height; y += cellHeight) canvasContext.drawImage(image, x, y, cellWidth, cellHeight);
22234
- } else canvasContext.drawImage(image, 0, 0, canvas.width, canvas.height);
22235
- const pattern = ctx.createPattern(canvas, "no-repeat");
22236
- pattern === null || pattern === void 0 || (_pattern$setTransform = pattern.setTransform) === null || _pattern$setTransform === void 0 || _pattern$setTransform.call(pattern, new DOMMatrix().translate(bounds.left, bounds.top));
22237
- return pattern;
22238
- }
22239
- _getTextFillImage(source) {
22240
- const cached = this._textFillImageCache.get(source);
22241
- if (cached) return cached;
22242
- const image = new Image();
22243
- image.crossOrigin = "anonymous";
22244
- image.src = source;
22245
- this._textFillImageCache.set(source, image);
22246
- return image.complete ? image : null;
22247
- }
22248
- _normalizeGradientStops(stops, fallbackColor) {
22249
- return (stops && stops.length >= 2 ? stops : [{
22250
- offset: 0,
22251
- color: fallbackColor
22252
- }, {
22253
- offset: 100,
22254
- color: "#ffffff"
22255
- }]).map((stop) => ({
22256
- color: stop.color,
22257
- offset: this._clamp(stop.offset > 1 ? stop.offset / 100 : stop.offset, 0, 1),
22258
- opacity: stop.opacity
22259
- }));
22260
- }
22261
- _getLinearGradientLine(bounds, angle) {
22262
- const angleRad = angle * Math.PI / 180;
22263
- const centerX = bounds.left + bounds.width / 2;
22264
- const centerY = bounds.top + bounds.height / 2;
22265
- const cos = Math.cos(angleRad);
22266
- const sin = Math.sin(angleRad);
22267
- const halfDiagonal = (Math.abs(bounds.width * cos) + Math.abs(bounds.height * sin)) / 2;
22268
- return {
22269
- x0: centerX - cos * halfDiagonal,
22270
- y0: centerY - sin * halfDiagonal,
22271
- x1: centerX + cos * halfDiagonal,
22272
- y1: centerY + sin * halfDiagonal
22273
- };
22274
- }
22275
- _colorWithOpacity(color, opacity) {
22276
- if (opacity === void 0 || opacity >= 1) return color;
22277
- const alpha = this._clamp(opacity, 0, 1);
22278
- const hex = color.trim();
22279
- if (/^#[0-9a-f]{3}$/i.test(hex)) {
22280
- const [, r, g, b] = hex;
22281
- return `rgba(${Number.parseInt(r + r, 16)}, ${Number.parseInt(g + g, 16)}, ${Number.parseInt(b + b, 16)}, ${alpha})`;
22282
- }
22283
- if (/^#[0-9a-f]{6}$/i.test(hex)) return `rgba(${Number.parseInt(hex.slice(1, 3), 16)}, ${Number.parseInt(hex.slice(3, 5), 16)}, ${Number.parseInt(hex.slice(5, 7), 16)}, ${alpha})`;
22284
- return color;
22285
- }
22286
- _clamp(value, min, max) {
22287
- return Math.max(min, Math.min(max, value));
22288
- }
22289
21628
  _fillText(ctx, glyph, spanPointWithFont) {
22290
21629
  const { renderConfig, spanStartPoint, centerPoint } = this.extensionOffset;
22291
21630
  const { content, width, bBox } = glyph;
@@ -22633,14 +21972,24 @@ var Documents = class Documents extends DocComponent {
22633
21972
  this._drawLiquid.translateSave();
22634
21973
  this._drawLiquid.translateLine(line, true, true);
22635
21974
  rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i]);
22636
- this._drawLineBackground(ctx, page, line);
22637
21975
  const divideLength = divides.length;
22638
21976
  for (let i = 0; i < divideLength; i++) {
22639
21977
  const divide = divides[i];
22640
21978
  const { glyphGroup } = divide;
22641
21979
  this._drawLiquid.translateSave();
22642
21980
  this._drawLiquid.translateDivide(divide, isVertical && wrapStrategy === WrapStrategy.WRAP, verticalAlign, rotatedHeightStore);
22643
- this._drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension);
21981
+ for (const glyph of glyphGroup) {
21982
+ if (!glyph.content || glyph.content.length === 0) continue;
21983
+ const { width: spanWidth, left: spanLeft } = glyph;
21984
+ const { x: translateX, y: translateY } = this._drawLiquid;
21985
+ const originTranslate = Vector2.create(translateX, translateY);
21986
+ const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
21987
+ const extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
21988
+ if (backgroundExtension) {
21989
+ backgroundExtension.extensionOffset = extensionOffset;
21990
+ backgroundExtension.draw(ctx, parentScale, glyph);
21991
+ }
21992
+ }
22644
21993
  for (const glyph of glyphGroup) {
22645
21994
  if (!glyph.content || glyph.content.length === 0) continue;
22646
21995
  const { width: spanWidth, left: spanLeft, xOffset } = glyph;
@@ -22696,18 +22045,15 @@ var Documents = class Documents extends DocComponent {
22696
22045
  const viewport = this._getTableViewport(page, tableSkeleton, renderUnitId, sourceTableId);
22697
22046
  drawLiquid.translateSave();
22698
22047
  drawLiquid.translate(tableLeft, tableTop);
22699
- if (hasDocsTableHorizontalViewport(viewport)) {
22700
- var _viewport$leadingInse;
22048
+ if (viewport && viewport.contentWidth > viewport.viewportWidth) {
22701
22049
  const { x, y } = drawLiquid;
22702
- const clipLeft = x + page.marginLeft - ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0);
22703
22050
  ctx.save();
22704
22051
  ctx.beginPath();
22705
- ctx.rectByPrecision(clipLeft - TABLE_VIEWPORT_BORDER_CLIP_PADDING, y + page.marginTop - TABLE_VIEWPORT_BORDER_CLIP_PADDING, viewport.viewportWidth + TABLE_VIEWPORT_BORDER_CLIP_PADDING * 2, tableSkeleton.height + TABLE_VIEWPORT_BORDER_CLIP_PADDING * 2);
22052
+ ctx.rectByPrecision(x + page.marginLeft - TABLE_VIEWPORT_BORDER_CLIP_PADDING, y + page.marginTop - TABLE_VIEWPORT_BORDER_CLIP_PADDING, viewport.viewportWidth + TABLE_VIEWPORT_BORDER_CLIP_PADDING * 2, tableSkeleton.height + TABLE_VIEWPORT_BORDER_CLIP_PADDING * 2);
22706
22053
  ctx.closePath();
22707
22054
  ctx.clip();
22708
22055
  drawLiquid.translate(-viewport.scrollLeft, 0);
22709
22056
  }
22710
- this._drawTableCellBackgrounds(ctx, page, tableSkeleton);
22711
22057
  for (const row of rows) {
22712
22058
  const { top: rowTop, cells } = row;
22713
22059
  drawLiquid.translateSave();
@@ -22722,49 +22068,16 @@ var Documents = class Documents extends DocComponent {
22722
22068
  }
22723
22069
  drawLiquid.translateRestore();
22724
22070
  }
22725
- if (hasDocsTableHorizontalViewport(viewport)) ctx.restore();
22071
+ if (viewport && viewport.contentWidth > viewport.viewportWidth) ctx.restore();
22726
22072
  drawLiquid.translateRestore();
22727
22073
  }
22728
22074
  }
22729
- _drawTableCellBackgrounds(ctx, page, tableSkeleton) {
22730
- if (this._drawLiquid == null) return;
22731
- const backgrounds = /* @__PURE__ */ new Map();
22732
- const tableX = this._drawLiquid.x + page.marginLeft;
22733
- const tableY = this._drawLiquid.y + page.marginTop;
22734
- for (const row of tableSkeleton.rows) row.cells.forEach((cell, index) => {
22735
- var _cellSource$backgroun, _backgrounds$get;
22736
- if (cell.isMergedCellCovered) return;
22737
- const cellSource = row.rowSource.tableCells[index];
22738
- if (!cellSource || cellSource.rowSpan === 0 || cellSource.columnSpan === 0) return;
22739
- const color = (_cellSource$backgroun = cellSource.backgroundColor) === null || _cellSource$backgroun === void 0 ? void 0 : _cellSource$backgroun.rgb;
22740
- if (!color) return;
22741
- const rects = (_backgrounds$get = backgrounds.get(color)) !== null && _backgrounds$get !== void 0 ? _backgrounds$get : [];
22742
- rects.push({
22743
- x: tableX + cell.left,
22744
- y: tableY + row.top,
22745
- width: cell.pageWidth,
22746
- height: cell.pageHeight
22747
- });
22748
- backgrounds.set(color, rects);
22749
- });
22750
- backgrounds.forEach((rects, color) => {
22751
- ctx.save();
22752
- ctx.fillStyle = color;
22753
- ctx.beginPath();
22754
- rects.forEach(({ x, y, width, height }) => {
22755
- rectByPrecisionBounds(ctx, x, y, width, height);
22756
- });
22757
- ctx.fill();
22758
- ctx.closePath();
22759
- ctx.restore();
22760
- });
22761
- }
22762
22075
  _getTableViewport(page, tableSkeleton, unitId, tableId) {
22763
22076
  const viewport = getDocsTableRenderViewport(unitId, tableId);
22764
22077
  if (viewport) return viewport;
22765
22078
  const { pageWidth, marginLeft = 0, marginRight = 0 } = page;
22766
22079
  if (!Number.isFinite(pageWidth)) return null;
22767
- const viewportWidth = shouldAllowImportedTableMarginOverflow(this._getDocumentCompatibilityPolicy(), tableSkeleton.tableSource) ? Math.max(0, pageWidth - Math.max(0, marginLeft + tableSkeleton.left)) : Math.max(0, pageWidth - marginLeft - marginRight - tableSkeleton.left);
22080
+ const viewportWidth = Math.max(0, pageWidth - marginLeft - marginRight - tableSkeleton.left);
22768
22081
  if (viewportWidth <= 0 || tableSkeleton.width <= viewportWidth) return null;
22769
22082
  return {
22770
22083
  contentWidth: tableSkeleton.width,
@@ -22779,26 +22092,6 @@ var Documents = class Documents extends DocComponent {
22779
22092
  const dataModel = viewModel === null || viewModel === void 0 || (_viewModel$getDataMod = viewModel.getDataModel) === null || _viewModel$getDataMod === void 0 ? void 0 : _viewModel$getDataMod.call(viewModel);
22780
22093
  return (_dataModel$getUnitId = dataModel === null || dataModel === void 0 || (_dataModel$getUnitId2 = dataModel.getUnitId) === null || _dataModel$getUnitId2 === void 0 ? void 0 : _dataModel$getUnitId2.call(dataModel)) !== null && _dataModel$getUnitId !== void 0 ? _dataModel$getUnitId : this.oKey;
22781
22094
  }
22782
- _getDocumentCompatibilityPolicy() {
22783
- var _skeleton$getViewMode2, _skeleton$getViewMode3;
22784
- const skeleton = this.getSkeleton();
22785
- return getDocumentCompatibilityPolicy(skeleton === null || skeleton === void 0 || (_skeleton$getViewMode2 = skeleton.getViewModel) === null || _skeleton$getViewMode2 === void 0 || (_skeleton$getViewMode2 = _skeleton$getViewMode2.call(skeleton)) === null || _skeleton$getViewMode2 === void 0 || (_skeleton$getViewMode3 = _skeleton$getViewMode2.getSnapshot) === null || _skeleton$getViewMode3 === void 0 || (_skeleton$getViewMode3 = _skeleton$getViewMode3.call(_skeleton$getViewMode2)) === null || _skeleton$getViewMode3 === void 0 || (_skeleton$getViewMode3 = _skeleton$getViewMode3.documentStyle) === null || _skeleton$getViewMode3 === void 0 ? void 0 : _skeleton$getViewMode3.documentFlavor);
22786
- }
22787
- _drawLineBackground(ctx, page, line, left = 0, top = 0) {
22788
- var _line$backgroundColor;
22789
- const color = (_line$backgroundColor = line.backgroundColor) === null || _line$backgroundColor === void 0 ? void 0 : _line$backgroundColor.rgb;
22790
- if (!color || this._drawLiquid == null) return;
22791
- let { x, y } = this._drawLiquid;
22792
- const { pageWidth, marginLeft, marginRight, marginTop } = page;
22793
- x += marginLeft + (left !== null && left !== void 0 ? left : 0);
22794
- y -= line.marginTop;
22795
- y -= line.paddingTop;
22796
- y += marginTop + top;
22797
- ctx.save();
22798
- ctx.fillStyle = color;
22799
- fillRectByPrecisionBounds(ctx, x, y, pageWidth - marginLeft - marginRight, line.lineHeight);
22800
- ctx.restore();
22801
- }
22802
22095
  _drawBorderBottom(ctx, page, line, left = 0, top = 0) {
22803
22096
  var _line$borderBottom$pa, _line$borderBottom, _line$borderBottom$co, _line$borderBottom2;
22804
22097
  if (this._drawLiquid == null) return;
@@ -22819,21 +22112,9 @@ var Documents = class Documents extends DocComponent {
22819
22112
  });
22820
22113
  ctx.restore();
22821
22114
  }
22822
- _drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension) {
22823
- if (!backgroundExtension || this._drawLiquid == null) return;
22824
- const backgroundRuns = collectBackgroundGlyphRuns(glyphGroup);
22825
- for (const backgroundRun of backgroundRuns) {
22826
- const { glyph, left: spanLeft, width: spanWidth } = backgroundRun;
22827
- const { x: translateX, y: translateY } = this._drawLiquid;
22828
- const originTranslate = Vector2.create(translateX, translateY);
22829
- const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
22830
- backgroundExtension.extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
22831
- backgroundExtension.draw(ctx, parentScale, glyph);
22832
- }
22833
- }
22834
22115
  _drawTableCell(ctx, page, cell, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale) {
22835
22116
  if (this._drawLiquid == null) return;
22836
- this._drawTableCellBordersAndBg(ctx, page, cell, false);
22117
+ this._drawTableCellBordersAndBg(ctx, page, cell);
22837
22118
  const { sections, marginLeft, marginTop } = cell;
22838
22119
  alignOffsetNoAngle = Vector2.create(alignOffsetNoAngle.x + marginLeft, alignOffsetNoAngle.y + marginTop);
22839
22120
  ctx.save();
@@ -22870,14 +22151,24 @@ var Documents = class Documents extends DocComponent {
22870
22151
  } else {
22871
22152
  this._drawLiquid.translateSave();
22872
22153
  this._drawLiquid.translateLine(line, true, true);
22873
- this._drawLineBackground(ctx, cell, line, page.marginLeft, page.marginTop);
22874
22154
  const divideLength = divides.length;
22875
22155
  for (let i = 0; i < divideLength; i++) {
22876
22156
  const divide = divides[i];
22877
22157
  const { glyphGroup } = divide;
22878
22158
  this._drawLiquid.translateSave();
22879
22159
  this._drawLiquid.translateDivide(divide);
22880
- this._drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension);
22160
+ for (const glyph of glyphGroup) {
22161
+ if (!glyph.content || glyph.content.length === 0) continue;
22162
+ const { width: spanWidth, left: spanLeft } = glyph;
22163
+ const { x: translateX, y: translateY } = this._drawLiquid;
22164
+ const originTranslate = Vector2.create(translateX, translateY);
22165
+ const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
22166
+ const extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
22167
+ if (backgroundExtension) {
22168
+ backgroundExtension.extensionOffset = extensionOffset;
22169
+ backgroundExtension.draw(ctx, parentScale, glyph);
22170
+ }
22171
+ }
22881
22172
  for (const glyph of glyphGroup) {
22882
22173
  if (!glyph.content || glyph.content.length === 0) continue;
22883
22174
  const { width: spanWidth, left: spanLeft, xOffset } = glyph;
@@ -22909,8 +22200,8 @@ var Documents = class Documents extends DocComponent {
22909
22200
  }
22910
22201
  ctx.restore();
22911
22202
  }
22912
- _drawTableCellBordersAndBg(ctx, page, cell, drawBackground = true) {
22913
- var _rowSke$index, _cellSource$backgroun2;
22203
+ _drawTableCellBordersAndBg(ctx, page, cell) {
22204
+ var _rowSke$index, _cellSource$backgroun;
22914
22205
  const { marginLeft, marginTop } = page;
22915
22206
  const { pageWidth, pageHeight } = cell;
22916
22207
  const rowSke = cell.parent;
@@ -22925,10 +22216,10 @@ var Documents = class Documents extends DocComponent {
22925
22216
  let { x, y } = this._drawLiquid;
22926
22217
  x += marginLeft;
22927
22218
  y += marginTop;
22928
- if (drawBackground && ((_cellSource$backgroun2 = cellSource.backgroundColor) === null || _cellSource$backgroun2 === void 0 ? void 0 : _cellSource$backgroun2.rgb)) {
22219
+ if ((_cellSource$backgroun = cellSource.backgroundColor) === null || _cellSource$backgroun === void 0 ? void 0 : _cellSource$backgroun.rgb) {
22929
22220
  ctx.save();
22930
22221
  ctx.fillStyle = cellSource.backgroundColor.rgb;
22931
- fillRectByPrecisionBounds(ctx, x, y, pageWidth, pageHeight);
22222
+ ctx.fillRectByPrecision(x, y, pageWidth, pageHeight);
22932
22223
  ctx.restore();
22933
22224
  }
22934
22225
  const position = {
@@ -22976,9 +22267,8 @@ var Documents = class Documents extends DocComponent {
22976
22267
  }
22977
22268
  _drawHeaderFooter(page, ctx, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale, parentPage, isHeader = true) {
22978
22269
  if (this._drawLiquid == null) return;
22979
- const { sections, skeTables } = page;
22270
+ const { sections } = page;
22980
22271
  const { y: originY } = this._drawLiquid;
22981
- if (skeTables.size > 0) this._drawTable(ctx, page, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
22982
22272
  for (const section of sections) {
22983
22273
  const { columns } = section;
22984
22274
  this._drawLiquid.translateSave();
@@ -23007,20 +22297,33 @@ var Documents = class Documents extends DocComponent {
23007
22297
  this._drawLiquid.translateSave();
23008
22298
  this._drawLiquid.translateLine(line, true, true);
23009
22299
  const { y } = this._drawLiquid;
23010
- if (!isHeader) {
23011
- if (y - originY + alignOffset.y + lineHeight < (parentPage.pageHeight - 100) / 2 + 100) {
22300
+ if (isHeader) {
22301
+ if (y - originY + alignOffset.y > (parentPage.pageHeight - 100) / 2) {
23012
22302
  this._drawLiquid.translateRestore();
23013
22303
  continue;
23014
22304
  }
22305
+ } else if (y - originY + alignOffset.y + lineHeight < (parentPage.pageHeight - 100) / 2 + 100) {
22306
+ this._drawLiquid.translateRestore();
22307
+ continue;
23015
22308
  }
23016
- this._drawLineBackground(ctx, page, line, parentPage.marginLeft);
23017
22309
  const divideLength = divides.length;
23018
22310
  for (let i = 0; i < divideLength; i++) {
23019
22311
  const divide = divides[i];
23020
22312
  const { glyphGroup } = divide;
23021
22313
  this._drawLiquid.translateSave();
23022
22314
  this._drawLiquid.translateDivide(divide);
23023
- this._drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension);
22315
+ for (const glyph of glyphGroup) {
22316
+ if (!glyph.content || glyph.content.length === 0) continue;
22317
+ const { width: spanWidth, left: spanLeft } = glyph;
22318
+ const { x: translateX, y: translateY } = this._drawLiquid;
22319
+ const originTranslate = Vector2.create(translateX, translateY);
22320
+ const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
22321
+ const extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
22322
+ if (backgroundExtension) {
22323
+ backgroundExtension.extensionOffset = extensionOffset;
22324
+ backgroundExtension.draw(ctx, parentScale, glyph);
22325
+ }
22326
+ }
23024
22327
  for (const glyph of glyphGroup) {
23025
22328
  if (!glyph.content || glyph.content.length === 0) continue;
23026
22329
  const { width: spanWidth, left: spanLeft, xOffset } = glyph;
@@ -23056,19 +22359,18 @@ var Documents = class Documents extends DocComponent {
23056
22359
  * In Excel, if horizontal alignment is not specified,
23057
22360
  * rotated text aligns to the right when rotated downwards and aligns to the left when rotated upwards.
23058
22361
  */
23059
- let resolvedHorizontalAlign = horizontalAlign;
23060
- if (resolvedHorizontalAlign === HorizontalAlign.UNSPECIFIED) if (centerAngleDeg === 90 && vertexAngleDeg === 90) resolvedHorizontalAlign = HorizontalAlign.CENTER;
22362
+ if (horizontalAlign === HorizontalAlign.UNSPECIFIED) if (centerAngleDeg === 90 && vertexAngleDeg === 90) horizontalAlign = HorizontalAlign.CENTER;
23061
22363
  else if (vertexAngleDeg > 0 && vertexAngleDeg !== 90 || vertexAngleDeg === -90)
23062
22364
  /**
23063
22365
  * https://github.com/dream-num/univer-pro/issues/334
23064
22366
  */
23065
- resolvedHorizontalAlign = HorizontalAlign.RIGHT;
23066
- else if (cellValueType === CellValueType.NUMBER) resolvedHorizontalAlign = HorizontalAlign.RIGHT;
23067
- else if (cellValueType === CellValueType.BOOLEAN) resolvedHorizontalAlign = HorizontalAlign.CENTER;
23068
- else resolvedHorizontalAlign = HorizontalAlign.LEFT;
22367
+ horizontalAlign = HorizontalAlign.RIGHT;
22368
+ else if (cellValueType === CellValueType.NUMBER) horizontalAlign = HorizontalAlign.RIGHT;
22369
+ else if (cellValueType === CellValueType.BOOLEAN) horizontalAlign = HorizontalAlign.CENTER;
22370
+ else horizontalAlign = HorizontalAlign.LEFT;
23069
22371
  let offsetLeft = 0;
23070
- if (resolvedHorizontalAlign === HorizontalAlign.CENTER) offsetLeft = (this.width - pageWidth) / 2;
23071
- else if (resolvedHorizontalAlign === HorizontalAlign.RIGHT) offsetLeft = this.width - pageWidth - pagePaddingRight;
22372
+ if (horizontalAlign === HorizontalAlign.CENTER) offsetLeft = (this.width - pageWidth) / 2;
22373
+ else if (horizontalAlign === HorizontalAlign.RIGHT) offsetLeft = this.width - pageWidth - pagePaddingRight;
23072
22374
  else offsetLeft = pagePaddingLeft;
23073
22375
  return offsetLeft;
23074
22376
  }
@@ -23102,22 +22404,6 @@ function setTableCellBorderDash(ctx, dashStyle) {
23102
22404
  }
23103
22405
  ctx.setLineDash([0]);
23104
22406
  }
23105
- function fillRectByPrecisionBounds(ctx, x, y, width, height) {
23106
- const { scaleX, scaleY } = ctx.getScale();
23107
- const startX = fixLineWidthByScale(x, scaleX);
23108
- const startY = fixLineWidthByScale(y, scaleY);
23109
- const endX = fixLineWidthByScale(x + width, scaleX);
23110
- const endY = fixLineWidthByScale(y + height, scaleY);
23111
- ctx.fillRect(startX, startY, endX - startX, endY - startY);
23112
- }
23113
- function rectByPrecisionBounds(ctx, x, y, width, height) {
23114
- const { scaleX, scaleY } = ctx.getScale();
23115
- const startX = fixLineWidthByScale(x, scaleX);
23116
- const startY = fixLineWidthByScale(y, scaleY);
23117
- const endX = fixLineWidthByScale(x + width, scaleX);
23118
- const endY = fixLineWidthByScale(y + height, scaleY);
23119
- ctx.rect(startX, startY, endX - startX, endY - startY);
23120
- }
23121
22407
 
23122
22408
  //#endregion
23123
22409
  //#region src/components/sheets/spreadsheet.ts
@@ -24330,8 +23616,6 @@ var DocBackground = class DocBackground extends DocComponent {
24330
23616
  _defineProperty(this, "_pageFillColor", void 0);
24331
23617
  _defineProperty(this, "_pageStrokeColor", void 0);
24332
23618
  _defineProperty(this, "_marginStrokeColor", void 0);
24333
- _defineProperty(this, "_pageBackgroundSource", void 0);
24334
- _defineProperty(this, "_pageBackgroundImage", void 0);
24335
23619
  this._drawLiquid = new Liquid();
24336
23620
  this._backgroundFillColor = config === null || config === void 0 ? void 0 : config.backgroundFillColor;
24337
23621
  this._pageFillColor = config === null || config === void 0 ? void 0 : config.pageFillColor;
@@ -24355,7 +23639,7 @@ var DocBackground = class DocBackground extends DocComponent {
24355
23639
  const skeletonData = (_this$getSkeleton = this.getSkeleton()) === null || _this$getSkeleton === void 0 ? void 0 : _this$getSkeleton.getSkeletonData();
24356
23640
  const docDataModel = (_this$getSkeleton2 = this.getSkeleton()) === null || _this$getSkeleton2 === void 0 ? void 0 : _this$getSkeleton2.getViewModel().getDataModel();
24357
23641
  if (skeletonData == null || docDataModel == null) return;
24358
- const { documentFlavor, background } = docDataModel.getSnapshot().documentStyle;
23642
+ const { documentFlavor } = docDataModel.getSnapshot().documentStyle;
24359
23643
  const workspaceFill = (_this$_backgroundFill = this._backgroundFillColor) !== null && _this$_backgroundFill !== void 0 ? _this$_backgroundFill : documentFlavor === DocumentFlavor.MODERN ? PAGE_FILL_COLOR : DOCS_WORKSPACE_FILL_COLOR;
24360
23644
  this._drawWorkspaceBackground(ctx, workspaceFill, bounds);
24361
23645
  if (documentFlavor === DocumentFlavor.MODERN) return;
@@ -24384,7 +23668,6 @@ var DocBackground = class DocBackground extends DocComponent {
24384
23668
  zIndex: 3
24385
23669
  };
24386
23670
  Rect.drawWith(ctx, backgroundOptions);
24387
- this._drawPageBackgroundImage(ctx, background === null || background === void 0 ? void 0 : background.source, pageWidth !== null && pageWidth !== void 0 ? pageWidth : width, pageHeight !== null && pageHeight !== void 0 ? pageHeight : height);
24388
23671
  const IDENTIFIER_WIDTH = 15;
24389
23672
  const marginIdentification = {
24390
23673
  dataArray: [
@@ -24465,22 +23748,6 @@ var DocBackground = class DocBackground extends DocComponent {
24465
23748
  });
24466
23749
  ctx.restore();
24467
23750
  }
24468
- _drawPageBackgroundImage(ctx, source, width, height) {
24469
- if (!source || width <= 0 || height <= 0) return;
24470
- const image = this._getPageBackgroundImage(source);
24471
- if (!image.complete) return;
24472
- ctx.drawImage(image, 0, 0, width, height);
24473
- }
24474
- _getPageBackgroundImage(source) {
24475
- if (this._pageBackgroundSource === source && this._pageBackgroundImage != null) return this._pageBackgroundImage;
24476
- const image = document.createElement("img");
24477
- image.crossOrigin = "anonymous";
24478
- image.onload = () => this.makeDirty(true);
24479
- image.src = source;
24480
- this._pageBackgroundSource = source;
24481
- this._pageBackgroundImage = image;
24482
- return image;
24483
- }
24484
23751
  changeSkeleton(newSkeleton) {
24485
23752
  this.setSkeleton(newSkeleton);
24486
23753
  return this;
@@ -24917,42 +24184,6 @@ var DumbCanvasColorService = class {
24917
24184
  return color;
24918
24185
  }
24919
24186
  };
24920
- const DARK_RENDER_COLOR_OVERRIDES = {
24921
- "#17212b": "#e2e8f0",
24922
- "#64748b": "#94a3b8",
24923
- "#d9e0e7": "#253044",
24924
- "#edf1f5": "#1b2535",
24925
- "#eef2f6": "#1b2535",
24926
- "#f2f5f8": "#101827",
24927
- "#f3f6fa": "#18243a",
24928
- "#f4f8ff": "#172a46",
24929
- "#f5f9ff": "#12233a",
24930
- "#f7f9fb": "#0d1422",
24931
- "#f7f9fc": "#0d1422",
24932
- "#f8fafc": "#0f172a",
24933
- "#fbfcfd": "#07111f",
24934
- "#fcfdff": "#050914",
24935
- "#e8f1ff": "#173a69",
24936
- "#eaf5ff": "#12315a",
24937
- "#dbeafe": "#1e3a8a",
24938
- "#bfdbfe": "#60a5fa",
24939
- "#93c5fd": "#60a5fa",
24940
- "#8eb6f5": "#60a5fa",
24941
- "#60a5fa": "#60a5fa",
24942
- "#2563eb": "#60a5fa",
24943
- "#1d64d8": "#93c5fd",
24944
- "#1d5cff": "#60a5fa",
24945
- "#0f766e": "#2dd4bf",
24946
- "#d7f4ef": "#134e4a",
24947
- "rgba(37,99,235,0.05)": "rgba(96,165,250,0.16)",
24948
- "rgba(37,99,235,0.06)": "rgba(96,165,250,0.18)",
24949
- "rgba(37,99,235,0.08)": "rgba(96,165,250,0.22)",
24950
- "rgba(37,99,235,0.12)": "rgba(96,165,250,0.26)",
24951
- "rgba(37,99,235,0.18)": "rgba(96,165,250,0.30)",
24952
- "rgba(37,99,235,0.28)": "rgba(96,165,250,0.38)",
24953
- "rgba(239,246,255,0.88)": "rgba(30,64,175,0.72)",
24954
- "rgba(148,163,184,0.45)": "rgba(148,163,184,0.52)"
24955
- };
24956
24187
  let CanvasColorService = class CanvasColorService extends Disposable {
24957
24188
  constructor(_themeService) {
24958
24189
  super();
@@ -24963,14 +24194,8 @@ let CanvasColorService = class CanvasColorService extends Disposable {
24963
24194
  getRenderColor(color) {
24964
24195
  if (!this._themeService.darkMode) return color;
24965
24196
  if (this._cache.has(color)) return this._cache.get(color);
24966
- if (normalizeRenderColor(color) === "transparent") {
24967
- this._cache.set(color, "transparent");
24968
- return "transparent";
24969
- }
24970
24197
  let cachedColor = "";
24971
- const mappedColor = getDarkRenderColorOverride(color);
24972
- if (mappedColor) cachedColor = mappedColor;
24973
- else if (color.startsWith("#")) {
24198
+ if (color.startsWith("#")) {
24974
24199
  cachedColor = rgbToHex(this._invertAlgo(hexToRgb(color)));
24975
24200
  if (color.length === 5) {
24976
24201
  const alpha = color.charAt(4);
@@ -25002,15 +24227,6 @@ let CanvasColorService = class CanvasColorService extends Disposable {
25002
24227
  }
25003
24228
  };
25004
24229
  CanvasColorService = __decorate([__decorateParam(0, Inject(ThemeService))], CanvasColorService);
25005
- function getDarkRenderColorOverride(color) {
25006
- var _DARK_RENDER_COLOR_OV;
25007
- return (_DARK_RENDER_COLOR_OV = DARK_RENDER_COLOR_OVERRIDES[normalizeRenderColor(color)]) !== null && _DARK_RENDER_COLOR_OV !== void 0 ? _DARK_RENDER_COLOR_OV : null;
25008
- }
25009
- function normalizeRenderColor(color) {
25010
- const trimmed = color.trim().toLowerCase();
25011
- if (trimmed.startsWith("rgb")) return trimmed.replace(/\s+/g, "");
25012
- return trimmed;
25013
- }
25014
24230
  function hexToRgb(_hex) {
25015
24231
  const hex = _hex.replace(/^#/, "");
25016
24232
  let r;
@@ -25684,7 +24900,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
25684
24900
  //#endregion
25685
24901
  //#region package.json
25686
24902
  var name = "@univerjs/engine-render";
25687
- var version = "0.25.0-insiders.20260623-012b5a8";
24903
+ var version = "0.25.1";
25688
24904
 
25689
24905
  //#endregion
25690
24906
  //#region src/config/config.ts
@@ -26156,47 +25372,7 @@ const DEFAULT_TRANSFORMER_LAYER_INDEX = 2;
26156
25372
  const MINI_WIDTH_LIMIT = 20;
26157
25373
  const MINI_HEIGHT_LIMIT = 20;
26158
25374
  const DEFAULT_CONTROL_PLUS_INDEX = 5e3;
26159
- const SINGLE_ACTIVE_OBJECT_TYPE_MAP = /* @__PURE__ */ new Set([6]);
26160
- const ROTATE_ICON_SIZE = 14;
26161
- var TransformerRotateIcon = class extends Rect {
26162
- _draw(ctx) {
26163
- const iconWidth = this.width || ROTATE_ICON_SIZE;
26164
- const iconHeight = this.height || ROTATE_ICON_SIZE;
26165
- const scaleX = iconWidth / 24;
26166
- const scaleY = iconHeight / 24;
26167
- ctx.save();
26168
- ctx.scale(scaleX, scaleY);
26169
- ctx.beginPath();
26170
- ctx.lineWidth = (this.strokeWidth || 2) / Math.max(scaleX, scaleY);
26171
- ctx.lineCap = "round";
26172
- ctx.lineJoin = "round";
26173
- ctx.strokeStyle = this.stroke || "currentColor";
26174
- ctx.moveTo(21, 12);
26175
- ctx.arc(12, 12, 9, 0, Math.PI * 1.5, false);
26176
- ctx.bezierCurveTo(14.52, 3, 16.93, 4, 18.74, 5.74);
26177
- ctx.lineTo(21, 8);
26178
- ctx.moveTo(21, 3);
26179
- ctx.lineTo(21, 8);
26180
- ctx.lineTo(16, 8);
26181
- ctx.stroke();
26182
- ctx.restore();
26183
- }
26184
- };
26185
- var TransformerAnchor = class extends Rect {
26186
- _draw(ctx) {
26187
- if (!this.shadowColor || !this.shadowBlur && !this.shadowOffsetX && !this.shadowOffsetY) {
26188
- Rect.drawWith(ctx, this);
26189
- return;
26190
- }
26191
- ctx.save();
26192
- ctx.shadowColor = this.shadowColor;
26193
- ctx.shadowBlur = this.shadowBlur;
26194
- ctx.shadowOffsetX = this.shadowOffsetX;
26195
- ctx.shadowOffsetY = this.shadowOffsetY;
26196
- Rect.drawWith(ctx, this);
26197
- ctx.restore();
26198
- }
26199
- };
25375
+ const SINGLE_ACTIVE_OBJECT_TYPE_MAP = new Set([6]);
26200
25376
  /**
26201
25377
  * Transformer constructor. Transformer is a special type of group that allow you transform
26202
25378
  * primitives and shapes. Transforming tool is not changing `width` and `height` properties of nodes
@@ -26215,16 +25391,8 @@ var Transformer = class extends Disposable {
26215
25391
  _defineProperty(this, "rotationSnaps", []);
26216
25392
  _defineProperty(this, "rotationSnapTolerance", 5);
26217
25393
  _defineProperty(this, "rotateAnchorOffset", 50);
26218
- _defineProperty(this, "rotateAnchorPosition", "top");
26219
- _defineProperty(this, "rotateLineEnabled", true);
26220
25394
  _defineProperty(this, "rotateSize", 10);
26221
25395
  _defineProperty(this, "rotateCornerRadius", 10);
26222
- _defineProperty(this, "rotateFill", void 0);
26223
- _defineProperty(this, "rotateStroke", void 0);
26224
- _defineProperty(this, "rotateStrokeWidth", void 0);
26225
- _defineProperty(this, "rotateIconEnabled", false);
26226
- _defineProperty(this, "rotateIconStroke", void 0);
26227
- _defineProperty(this, "rotateIconStrokeWidth", 1.5);
26228
25396
  _defineProperty(this, "borderEnabled", true);
26229
25397
  _defineProperty(this, "borderStroke", "rgb(97, 97, 97)");
26230
25398
  _defineProperty(this, "borderStrokeWidth", 1);
@@ -26235,19 +25403,10 @@ var Transformer = class extends Disposable {
26235
25403
  _defineProperty(this, "anchorStrokeWidth", 1);
26236
25404
  _defineProperty(this, "anchorSize", 10);
26237
25405
  _defineProperty(this, "anchorCornerRadius", 10);
26238
- _defineProperty(this, "anchorStyle", "default");
26239
- _defineProperty(this, "anchorSideLongSize", 16);
26240
- _defineProperty(this, "anchorSideShortSize", 5);
26241
- _defineProperty(this, "anchorSideCornerRadius", 2.5);
26242
- _defineProperty(this, "anchorShadowColor", void 0);
26243
- _defineProperty(this, "anchorShadowBlur", 0);
26244
- _defineProperty(this, "anchorShadowOffsetX", 0);
26245
- _defineProperty(this, "anchorShadowOffsetY", 0);
26246
25406
  _defineProperty(this, "keepRatio", true);
26247
25407
  _defineProperty(this, "centeredScaling", false);
26248
25408
  _defineProperty(this, "zeroLeft", 0);
26249
25409
  _defineProperty(this, "zeroTop", 0);
26250
- _defineProperty(this, "moveBoundaryEnabled", true);
26251
25410
  _defineProperty(
26252
25411
  this,
26253
25412
  /**
@@ -26361,9 +25520,9 @@ var Transformer = class extends Disposable {
26361
25520
  }
26362
25521
  _getConfig(applyObject) {
26363
25522
  const objectTransformerConfig = applyObject.transformerConfig;
26364
- let { isCropper, hoverEnabled, hoverEnterFunc, hoverLeaveFunc, resizeEnabled, rotateEnabled, rotationSnaps, rotationSnapTolerance, rotateAnchorOffset, rotateAnchorPosition, rotateLineEnabled, rotateSize, rotateCornerRadius, rotateFill, rotateStroke, rotateStrokeWidth, rotateIconEnabled, rotateIconStroke, rotateIconStrokeWidth, borderEnabled, borderStroke, borderStrokeWidth, borderDash, borderSpacing, anchorFill, anchorStroke, anchorStrokeWidth, anchorSize, anchorCornerRadius, anchorStyle, anchorSideLongSize, anchorSideShortSize, anchorSideCornerRadius, anchorShadowColor, anchorShadowBlur, anchorShadowOffsetX, anchorShadowOffsetY, keepRatio, centeredScaling, enabledAnchors, flipEnabled, ignoreStroke, boundBoxFunc, useSingleNodeRotation, shouldOverdrawWholeArea, moveBoundaryEnabled } = this;
25523
+ let { isCropper, hoverEnabled, hoverEnterFunc, hoverLeaveFunc, resizeEnabled, rotateEnabled, rotationSnaps, rotationSnapTolerance, rotateAnchorOffset, rotateSize, rotateCornerRadius, borderEnabled, borderStroke, borderStrokeWidth, borderDash, borderSpacing, anchorFill, anchorStroke, anchorStrokeWidth, anchorSize, anchorCornerRadius, keepRatio, centeredScaling, enabledAnchors, flipEnabled, ignoreStroke, boundBoxFunc, useSingleNodeRotation, shouldOverdrawWholeArea } = this;
26365
25524
  if (objectTransformerConfig != null) {
26366
- var _objectTransformerCon, _objectTransformerCon2, _objectTransformerCon3, _objectTransformerCon4, _objectTransformerCon5, _objectTransformerCon6, _objectTransformerCon7, _objectTransformerCon8, _objectTransformerCon9, _objectTransformerCon10, _objectTransformerCon11, _objectTransformerCon12, _objectTransformerCon13, _objectTransformerCon14, _objectTransformerCon15, _objectTransformerCon16, _objectTransformerCon17, _objectTransformerCon18, _objectTransformerCon19, _objectTransformerCon20, _objectTransformerCon21, _objectTransformerCon22, _objectTransformerCon23, _objectTransformerCon24, _objectTransformerCon25, _objectTransformerCon26, _objectTransformerCon27, _objectTransformerCon28, _objectTransformerCon29, _objectTransformerCon30, _objectTransformerCon31, _objectTransformerCon32, _objectTransformerCon33, _objectTransformerCon34, _objectTransformerCon35, _objectTransformerCon36, _objectTransformerCon37, _objectTransformerCon38, _objectTransformerCon39, _objectTransformerCon40, _objectTransformerCon41, _objectTransformerCon42, _objectTransformerCon43, _objectTransformerCon44, _objectTransformerCon45, _objectTransformerCon46;
25525
+ var _objectTransformerCon, _objectTransformerCon2, _objectTransformerCon3, _objectTransformerCon4, _objectTransformerCon5, _objectTransformerCon6, _objectTransformerCon7, _objectTransformerCon8, _objectTransformerCon9, _objectTransformerCon10, _objectTransformerCon11, _objectTransformerCon12, _objectTransformerCon13, _objectTransformerCon14, _objectTransformerCon15, _objectTransformerCon16, _objectTransformerCon17, _objectTransformerCon18, _objectTransformerCon19, _objectTransformerCon20, _objectTransformerCon21, _objectTransformerCon22, _objectTransformerCon23, _objectTransformerCon24, _objectTransformerCon25, _objectTransformerCon26, _objectTransformerCon27, _objectTransformerCon28, _objectTransformerCon29;
26367
25526
  isCropper = (_objectTransformerCon = objectTransformerConfig.isCropper) !== null && _objectTransformerCon !== void 0 ? _objectTransformerCon : isCropper;
26368
25527
  hoverEnabled = (_objectTransformerCon2 = objectTransformerConfig.hoverEnabled) !== null && _objectTransformerCon2 !== void 0 ? _objectTransformerCon2 : hoverEnabled;
26369
25528
  hoverEnterFunc = (_objectTransformerCon3 = objectTransformerConfig.hoverEnterFunc) !== null && _objectTransformerCon3 !== void 0 ? _objectTransformerCon3 : hoverEnterFunc;
@@ -26373,43 +25532,26 @@ var Transformer = class extends Disposable {
26373
25532
  rotationSnaps = (_objectTransformerCon7 = objectTransformerConfig.rotationSnaps) !== null && _objectTransformerCon7 !== void 0 ? _objectTransformerCon7 : rotationSnaps;
26374
25533
  rotationSnapTolerance = (_objectTransformerCon8 = objectTransformerConfig.rotationSnapTolerance) !== null && _objectTransformerCon8 !== void 0 ? _objectTransformerCon8 : rotationSnapTolerance;
26375
25534
  rotateAnchorOffset = (_objectTransformerCon9 = objectTransformerConfig.rotateAnchorOffset) !== null && _objectTransformerCon9 !== void 0 ? _objectTransformerCon9 : rotateAnchorOffset;
26376
- rotateAnchorPosition = (_objectTransformerCon10 = objectTransformerConfig.rotateAnchorPosition) !== null && _objectTransformerCon10 !== void 0 ? _objectTransformerCon10 : rotateAnchorPosition;
26377
- rotateLineEnabled = (_objectTransformerCon11 = objectTransformerConfig.rotateLineEnabled) !== null && _objectTransformerCon11 !== void 0 ? _objectTransformerCon11 : rotateLineEnabled;
26378
- rotateSize = (_objectTransformerCon12 = objectTransformerConfig.rotateSize) !== null && _objectTransformerCon12 !== void 0 ? _objectTransformerCon12 : rotateSize;
26379
- rotateCornerRadius = (_objectTransformerCon13 = objectTransformerConfig.rotateCornerRadius) !== null && _objectTransformerCon13 !== void 0 ? _objectTransformerCon13 : rotateCornerRadius;
26380
- rotateFill = (_objectTransformerCon14 = objectTransformerConfig.rotateFill) !== null && _objectTransformerCon14 !== void 0 ? _objectTransformerCon14 : rotateFill;
26381
- rotateStroke = (_objectTransformerCon15 = objectTransformerConfig.rotateStroke) !== null && _objectTransformerCon15 !== void 0 ? _objectTransformerCon15 : rotateStroke;
26382
- rotateStrokeWidth = (_objectTransformerCon16 = objectTransformerConfig.rotateStrokeWidth) !== null && _objectTransformerCon16 !== void 0 ? _objectTransformerCon16 : rotateStrokeWidth;
26383
- rotateIconEnabled = (_objectTransformerCon17 = objectTransformerConfig.rotateIconEnabled) !== null && _objectTransformerCon17 !== void 0 ? _objectTransformerCon17 : rotateIconEnabled;
26384
- rotateIconStroke = (_objectTransformerCon18 = objectTransformerConfig.rotateIconStroke) !== null && _objectTransformerCon18 !== void 0 ? _objectTransformerCon18 : rotateIconStroke;
26385
- rotateIconStrokeWidth = (_objectTransformerCon19 = objectTransformerConfig.rotateIconStrokeWidth) !== null && _objectTransformerCon19 !== void 0 ? _objectTransformerCon19 : rotateIconStrokeWidth;
26386
- borderEnabled = (_objectTransformerCon20 = objectTransformerConfig.borderEnabled) !== null && _objectTransformerCon20 !== void 0 ? _objectTransformerCon20 : borderEnabled;
26387
- borderStroke = (_objectTransformerCon21 = objectTransformerConfig.borderStroke) !== null && _objectTransformerCon21 !== void 0 ? _objectTransformerCon21 : borderStroke;
26388
- borderStrokeWidth = (_objectTransformerCon22 = objectTransformerConfig.borderStrokeWidth) !== null && _objectTransformerCon22 !== void 0 ? _objectTransformerCon22 : borderStrokeWidth;
26389
- borderDash = (_objectTransformerCon23 = objectTransformerConfig.borderDash) !== null && _objectTransformerCon23 !== void 0 ? _objectTransformerCon23 : borderDash;
26390
- borderSpacing = (_objectTransformerCon24 = objectTransformerConfig.borderSpacing) !== null && _objectTransformerCon24 !== void 0 ? _objectTransformerCon24 : borderSpacing;
26391
- anchorFill = (_objectTransformerCon25 = objectTransformerConfig.anchorFill) !== null && _objectTransformerCon25 !== void 0 ? _objectTransformerCon25 : anchorFill;
26392
- anchorStroke = (_objectTransformerCon26 = objectTransformerConfig.anchorStroke) !== null && _objectTransformerCon26 !== void 0 ? _objectTransformerCon26 : anchorStroke;
26393
- anchorStrokeWidth = (_objectTransformerCon27 = objectTransformerConfig.anchorStrokeWidth) !== null && _objectTransformerCon27 !== void 0 ? _objectTransformerCon27 : anchorStrokeWidth;
26394
- anchorSize = (_objectTransformerCon28 = objectTransformerConfig.anchorSize) !== null && _objectTransformerCon28 !== void 0 ? _objectTransformerCon28 : anchorSize;
26395
- anchorCornerRadius = (_objectTransformerCon29 = objectTransformerConfig.anchorCornerRadius) !== null && _objectTransformerCon29 !== void 0 ? _objectTransformerCon29 : anchorCornerRadius;
26396
- anchorStyle = (_objectTransformerCon30 = objectTransformerConfig.anchorStyle) !== null && _objectTransformerCon30 !== void 0 ? _objectTransformerCon30 : anchorStyle;
26397
- anchorSideLongSize = (_objectTransformerCon31 = objectTransformerConfig.anchorSideLongSize) !== null && _objectTransformerCon31 !== void 0 ? _objectTransformerCon31 : anchorSideLongSize;
26398
- anchorSideShortSize = (_objectTransformerCon32 = objectTransformerConfig.anchorSideShortSize) !== null && _objectTransformerCon32 !== void 0 ? _objectTransformerCon32 : anchorSideShortSize;
26399
- anchorSideCornerRadius = (_objectTransformerCon33 = objectTransformerConfig.anchorSideCornerRadius) !== null && _objectTransformerCon33 !== void 0 ? _objectTransformerCon33 : anchorSideCornerRadius;
26400
- anchorShadowColor = (_objectTransformerCon34 = objectTransformerConfig.anchorShadowColor) !== null && _objectTransformerCon34 !== void 0 ? _objectTransformerCon34 : anchorShadowColor;
26401
- anchorShadowBlur = (_objectTransformerCon35 = objectTransformerConfig.anchorShadowBlur) !== null && _objectTransformerCon35 !== void 0 ? _objectTransformerCon35 : anchorShadowBlur;
26402
- anchorShadowOffsetX = (_objectTransformerCon36 = objectTransformerConfig.anchorShadowOffsetX) !== null && _objectTransformerCon36 !== void 0 ? _objectTransformerCon36 : anchorShadowOffsetX;
26403
- anchorShadowOffsetY = (_objectTransformerCon37 = objectTransformerConfig.anchorShadowOffsetY) !== null && _objectTransformerCon37 !== void 0 ? _objectTransformerCon37 : anchorShadowOffsetY;
26404
- keepRatio = (_objectTransformerCon38 = objectTransformerConfig.keepRatio) !== null && _objectTransformerCon38 !== void 0 ? _objectTransformerCon38 : keepRatio;
26405
- centeredScaling = (_objectTransformerCon39 = objectTransformerConfig.centeredScaling) !== null && _objectTransformerCon39 !== void 0 ? _objectTransformerCon39 : centeredScaling;
26406
- enabledAnchors = (_objectTransformerCon40 = objectTransformerConfig.enabledAnchors) !== null && _objectTransformerCon40 !== void 0 ? _objectTransformerCon40 : enabledAnchors;
26407
- flipEnabled = (_objectTransformerCon41 = objectTransformerConfig.flipEnabled) !== null && _objectTransformerCon41 !== void 0 ? _objectTransformerCon41 : flipEnabled;
26408
- ignoreStroke = (_objectTransformerCon42 = objectTransformerConfig.ignoreStroke) !== null && _objectTransformerCon42 !== void 0 ? _objectTransformerCon42 : ignoreStroke;
26409
- boundBoxFunc = (_objectTransformerCon43 = objectTransformerConfig.boundBoxFunc) !== null && _objectTransformerCon43 !== void 0 ? _objectTransformerCon43 : boundBoxFunc;
26410
- useSingleNodeRotation = (_objectTransformerCon44 = objectTransformerConfig.useSingleNodeRotation) !== null && _objectTransformerCon44 !== void 0 ? _objectTransformerCon44 : useSingleNodeRotation;
26411
- shouldOverdrawWholeArea = (_objectTransformerCon45 = objectTransformerConfig.shouldOverdrawWholeArea) !== null && _objectTransformerCon45 !== void 0 ? _objectTransformerCon45 : shouldOverdrawWholeArea;
26412
- moveBoundaryEnabled = (_objectTransformerCon46 = objectTransformerConfig.moveBoundaryEnabled) !== null && _objectTransformerCon46 !== void 0 ? _objectTransformerCon46 : moveBoundaryEnabled;
25535
+ rotateSize = (_objectTransformerCon10 = objectTransformerConfig.rotateSize) !== null && _objectTransformerCon10 !== void 0 ? _objectTransformerCon10 : rotateSize;
25536
+ rotateCornerRadius = (_objectTransformerCon11 = objectTransformerConfig.rotateCornerRadius) !== null && _objectTransformerCon11 !== void 0 ? _objectTransformerCon11 : rotateCornerRadius;
25537
+ borderEnabled = (_objectTransformerCon12 = objectTransformerConfig.borderEnabled) !== null && _objectTransformerCon12 !== void 0 ? _objectTransformerCon12 : borderEnabled;
25538
+ borderStroke = (_objectTransformerCon13 = objectTransformerConfig.borderStroke) !== null && _objectTransformerCon13 !== void 0 ? _objectTransformerCon13 : borderStroke;
25539
+ borderStrokeWidth = (_objectTransformerCon14 = objectTransformerConfig.borderStrokeWidth) !== null && _objectTransformerCon14 !== void 0 ? _objectTransformerCon14 : borderStrokeWidth;
25540
+ borderDash = (_objectTransformerCon15 = objectTransformerConfig.borderDash) !== null && _objectTransformerCon15 !== void 0 ? _objectTransformerCon15 : borderDash;
25541
+ borderSpacing = (_objectTransformerCon16 = objectTransformerConfig.borderSpacing) !== null && _objectTransformerCon16 !== void 0 ? _objectTransformerCon16 : borderSpacing;
25542
+ anchorFill = (_objectTransformerCon17 = objectTransformerConfig.anchorFill) !== null && _objectTransformerCon17 !== void 0 ? _objectTransformerCon17 : anchorFill;
25543
+ anchorStroke = (_objectTransformerCon18 = objectTransformerConfig.anchorStroke) !== null && _objectTransformerCon18 !== void 0 ? _objectTransformerCon18 : anchorStroke;
25544
+ anchorStrokeWidth = (_objectTransformerCon19 = objectTransformerConfig.anchorStrokeWidth) !== null && _objectTransformerCon19 !== void 0 ? _objectTransformerCon19 : anchorStrokeWidth;
25545
+ anchorSize = (_objectTransformerCon20 = objectTransformerConfig.anchorSize) !== null && _objectTransformerCon20 !== void 0 ? _objectTransformerCon20 : anchorSize;
25546
+ anchorCornerRadius = (_objectTransformerCon21 = objectTransformerConfig.anchorCornerRadius) !== null && _objectTransformerCon21 !== void 0 ? _objectTransformerCon21 : anchorCornerRadius;
25547
+ keepRatio = (_objectTransformerCon22 = objectTransformerConfig.keepRatio) !== null && _objectTransformerCon22 !== void 0 ? _objectTransformerCon22 : keepRatio;
25548
+ centeredScaling = (_objectTransformerCon23 = objectTransformerConfig.centeredScaling) !== null && _objectTransformerCon23 !== void 0 ? _objectTransformerCon23 : centeredScaling;
25549
+ enabledAnchors = (_objectTransformerCon24 = objectTransformerConfig.enabledAnchors) !== null && _objectTransformerCon24 !== void 0 ? _objectTransformerCon24 : enabledAnchors;
25550
+ flipEnabled = (_objectTransformerCon25 = objectTransformerConfig.flipEnabled) !== null && _objectTransformerCon25 !== void 0 ? _objectTransformerCon25 : flipEnabled;
25551
+ ignoreStroke = (_objectTransformerCon26 = objectTransformerConfig.ignoreStroke) !== null && _objectTransformerCon26 !== void 0 ? _objectTransformerCon26 : ignoreStroke;
25552
+ boundBoxFunc = (_objectTransformerCon27 = objectTransformerConfig.boundBoxFunc) !== null && _objectTransformerCon27 !== void 0 ? _objectTransformerCon27 : boundBoxFunc;
25553
+ useSingleNodeRotation = (_objectTransformerCon28 = objectTransformerConfig.useSingleNodeRotation) !== null && _objectTransformerCon28 !== void 0 ? _objectTransformerCon28 : useSingleNodeRotation;
25554
+ shouldOverdrawWholeArea = (_objectTransformerCon29 = objectTransformerConfig.shouldOverdrawWholeArea) !== null && _objectTransformerCon29 !== void 0 ? _objectTransformerCon29 : shouldOverdrawWholeArea;
26413
25555
  }
26414
25556
  return {
26415
25557
  isCropper,
@@ -26421,16 +25563,8 @@ var Transformer = class extends Disposable {
26421
25563
  rotationSnaps,
26422
25564
  rotationSnapTolerance,
26423
25565
  rotateAnchorOffset,
26424
- rotateAnchorPosition,
26425
- rotateLineEnabled,
26426
25566
  rotateSize,
26427
25567
  rotateCornerRadius,
26428
- rotateFill,
26429
- rotateStroke,
26430
- rotateStrokeWidth,
26431
- rotateIconEnabled,
26432
- rotateIconStroke,
26433
- rotateIconStrokeWidth,
26434
25568
  borderEnabled,
26435
25569
  borderStroke,
26436
25570
  borderStrokeWidth,
@@ -26441,14 +25575,6 @@ var Transformer = class extends Disposable {
26441
25575
  anchorStrokeWidth,
26442
25576
  anchorSize,
26443
25577
  anchorCornerRadius,
26444
- anchorStyle,
26445
- anchorSideLongSize,
26446
- anchorSideShortSize,
26447
- anchorSideCornerRadius,
26448
- anchorShadowColor,
26449
- anchorShadowBlur,
26450
- anchorShadowOffsetX,
26451
- anchorShadowOffsetY,
26452
25578
  keepRatio,
26453
25579
  centeredScaling,
26454
25580
  enabledAnchors,
@@ -26456,8 +25582,7 @@ var Transformer = class extends Disposable {
26456
25582
  ignoreStroke,
26457
25583
  boundBoxFunc,
26458
25584
  useSingleNodeRotation,
26459
- shouldOverdrawWholeArea,
26460
- moveBoundaryEnabled
25585
+ shouldOverdrawWholeArea
26461
25586
  };
26462
25587
  }
26463
25588
  attachTo(applyObject) {
@@ -26491,7 +25616,7 @@ var Transformer = class extends Disposable {
26491
25616
  this._copperSelectedObject = applyObject;
26492
25617
  this._changeStart$.next({
26493
25618
  target: applyObject,
26494
- objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
25619
+ objects: new Map([[applyObject.oKey, applyObject]]),
26495
25620
  type: 0
26496
25621
  });
26497
25622
  }
@@ -26519,7 +25644,7 @@ var Transformer = class extends Disposable {
26519
25644
  event
26520
25645
  });
26521
25646
  else this._changeEnd$.next({
26522
- objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
25647
+ objects: new Map([[applyObject.oKey, applyObject]]),
26523
25648
  type: 2,
26524
25649
  offsetX,
26525
25650
  offsetY,
@@ -26566,10 +25691,6 @@ var Transformer = class extends Disposable {
26566
25691
  });
26567
25692
  }
26568
25693
  _checkMoveBoundary(moveObject, moveLeft, moveTop, ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight) {
26569
- if (this._getConfig(moveObject).moveBoundaryEnabled === false) return {
26570
- moveLeft,
26571
- moveTop
26572
- };
26573
25694
  const { left, top, width, height } = moveObject;
26574
25695
  let resultMoveLeft = moveLeft;
26575
25696
  let resultMoveTop = moveTop;
@@ -26619,7 +25740,7 @@ var Transformer = class extends Disposable {
26619
25740
  moveTop = boundary.moveTop;
26620
25741
  cropper.translate(moveLeft + cropper.left, moveTop + cropper.top);
26621
25742
  this._changing$.next({
26622
- objects: /* @__PURE__ */ new Map([[cropper.oKey, cropper]]),
25743
+ objects: new Map([[cropper.oKey, cropper]]),
26623
25744
  moveX: moveLeft,
26624
25745
  moveY: moveTop,
26625
25746
  type: 1,
@@ -26654,7 +25775,7 @@ var Transformer = class extends Disposable {
26654
25775
  } else {
26655
25776
  this._moveFunc(applyObject, type, x, y, keepRatio, isCropper, isGroup);
26656
25777
  this._changing$.next({
26657
- objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
25778
+ objects: new Map([[applyObject.oKey, applyObject]]),
26658
25779
  type: 1,
26659
25780
  offsetX: moveOffsetX,
26660
25781
  offsetY: moveOffsetY
@@ -26901,7 +26022,7 @@ var Transformer = class extends Disposable {
26901
26022
  });
26902
26023
  } else {
26903
26024
  this._changeStart$.next({
26904
- objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
26025
+ objects: new Map([[applyObject.oKey, applyObject]]),
26905
26026
  type: 0
26906
26027
  });
26907
26028
  const { width, height, left, top } = applyObject.getState();
@@ -26942,7 +26063,7 @@ var Transformer = class extends Disposable {
26942
26063
  } else {
26943
26064
  this._recoverySizeBoundary([applyObject], ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight);
26944
26065
  this._changeEnd$.next({
26945
- objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
26066
+ objects: new Map([[applyObject.oKey, applyObject]]),
26946
26067
  type: 2,
26947
26068
  offsetX,
26948
26069
  offsetY,
@@ -27017,11 +26138,7 @@ var Transformer = class extends Disposable {
27017
26138
  _rotateMoving(moveOffsetX, moveOffsetY, centerX, centerY, agentOrigin) {
27018
26139
  const { ancestorScaleX, ancestorScaleY } = this._scene;
27019
26140
  if (this._moveBufferBlocker(moveOffsetX, moveOffsetY)) return;
27020
- const moveSceneX = moveOffsetX / ancestorScaleX + this._viewportScrollX;
27021
- const moveSceneY = moveOffsetY / ancestorScaleY + this._viewportScrollY;
27022
- const startSceneX = this._startOffsetX / ancestorScaleX + this._viewportScrollX;
27023
- const startSceneY = this._startOffsetY / ancestorScaleY + this._viewportScrollY;
27024
- let angle = agentOrigin + radToDeg(Math.atan2(moveSceneY - centerY, moveSceneX - centerX) - Math.atan2(startSceneY - centerY, startSceneX - centerX));
26141
+ let angle = agentOrigin + radToDeg(Math.atan2((moveOffsetY - centerY) / ancestorScaleY + this._viewportScrollY, (moveOffsetX - centerX) / ancestorScaleX + this._viewportScrollX) - Math.atan2((this._startOffsetY - centerY) / ancestorScaleY + this._viewportScrollY, (this._startOffsetX - centerX) / ancestorScaleX + this._viewportScrollX));
27025
26142
  if (angle < 0) angle = 360 + angle;
27026
26143
  angle %= 360;
27027
26144
  angle = this._smoothAccuracy(angle);
@@ -27078,23 +26195,6 @@ var Transformer = class extends Disposable {
27078
26195
  }
27079
26196
  return cursor;
27080
26197
  }
27081
- _createRotateIcon(applyObject, zIndex, left, top) {
27082
- const { rotateSize, rotateIconStroke, rotateIconStrokeWidth, borderStroke } = this._getConfig(applyObject);
27083
- const iconOffset = (rotateSize - ROTATE_ICON_SIZE) / 2;
27084
- return new TransformerRotateIcon(`__SpreadsheetTransformerRotate___ICON_${zIndex}`, {
27085
- zIndex,
27086
- evented: false,
27087
- left: left + iconOffset,
27088
- top: top + iconOffset,
27089
- width: ROTATE_ICON_SIZE,
27090
- height: ROTATE_ICON_SIZE,
27091
- fill: null,
27092
- stroke: rotateIconStroke !== null && rotateIconStroke !== void 0 ? rotateIconStroke : borderStroke,
27093
- strokeWidth: rotateIconStrokeWidth,
27094
- strokeLineCap: "round",
27095
- strokeLineJoin: "round"
27096
- });
27097
- }
27098
26198
  _getCopperAnchorPosition(type, height, width, applyObject) {
27099
26199
  const { borderStrokeWidth, borderSpacing, anchorSize } = this._getConfig(applyObject);
27100
26200
  let left = 0;
@@ -27141,18 +26241,17 @@ var Transformer = class extends Disposable {
27141
26241
  };
27142
26242
  }
27143
26243
  _getRotateAnchorPosition(type, height, width, applyObject) {
27144
- const { rotateAnchorOffset, rotateAnchorPosition, rotateSize, borderStrokeWidth, borderSpacing, anchorSize } = this._getConfig(applyObject);
27145
- const isBottomRotateAnchor = rotateAnchorPosition === "bottom";
26244
+ const { rotateAnchorOffset, rotateSize, borderStrokeWidth, borderSpacing, anchorSize } = this._getConfig(applyObject);
27146
26245
  let left = -anchorSize / 2;
27147
26246
  let top = -anchorSize / 2;
27148
26247
  switch (type) {
27149
26248
  case "__SpreadsheetTransformerRotate__":
27150
26249
  left = width / 2 - rotateSize / 2;
27151
- top = isBottomRotateAnchor ? height + rotateAnchorOffset + borderSpacing + borderStrokeWidth * 2 : -rotateAnchorOffset - borderSpacing - borderStrokeWidth * 2 - rotateSize;
26250
+ top = -rotateAnchorOffset - borderSpacing - borderStrokeWidth * 2 - rotateSize;
27152
26251
  break;
27153
26252
  case "__SpreadsheetTransformerRotateLine__":
27154
26253
  left = width / 2;
27155
- top = isBottomRotateAnchor ? height + borderSpacing + borderStrokeWidth : -rotateAnchorOffset - borderSpacing - borderStrokeWidth;
26254
+ top = -rotateAnchorOffset - borderSpacing - borderStrokeWidth;
27156
26255
  break;
27157
26256
  case "__SpreadsheetTransformerResizeLT__":
27158
26257
  left += -borderSpacing - borderStrokeWidth;
@@ -27192,43 +26291,21 @@ var Transformer = class extends Disposable {
27192
26291
  top
27193
26292
  };
27194
26293
  }
27195
- _isMiddleAnchor(type) {
27196
- return type === "__SpreadsheetTransformerResizeCT__" || type === "__SpreadsheetTransformerResizeLM__" || type === "__SpreadsheetTransformerResizeRM__" || type === "__SpreadsheetTransformerResizeCB__";
27197
- }
27198
- _getResizeAnchorProps(type, applyObject) {
27199
- const { anchorSize, anchorCornerRadius, anchorStyle, anchorSideLongSize, anchorSideShortSize, anchorSideCornerRadius } = this._getConfig(applyObject);
27200
- if (anchorStyle !== "canva" || !this._isMiddleAnchor(type)) return {
27201
- width: anchorSize,
27202
- height: anchorSize,
27203
- radius: anchorStyle === "canva" ? anchorSize / 2 : anchorCornerRadius
27204
- };
27205
- const isHorizontal = type === "__SpreadsheetTransformerResizeCT__" || type === "__SpreadsheetTransformerResizeCB__";
27206
- return {
27207
- width: isHorizontal ? anchorSideLongSize : anchorSideShortSize,
27208
- height: isHorizontal ? anchorSideShortSize : anchorSideLongSize,
27209
- radius: anchorSideCornerRadius
27210
- };
27211
- }
27212
26294
  _createResizeAnchor(type, applyObject, zIndex) {
27213
26295
  const { height = 0, width = 0, scaleX = 1, scaleY = 1 } = applyObject.getState();
27214
- const { anchorFill, anchorStroke, anchorStrokeWidth, anchorSize, anchorShadowColor, anchorShadowBlur, anchorShadowOffsetX, anchorShadowOffsetY } = this._getConfig(applyObject);
26296
+ const { anchorFill, anchorStroke, anchorStrokeWidth, anchorCornerRadius, anchorSize } = this._getConfig(applyObject);
27215
26297
  const { left, top } = this._getRotateAnchorPosition(type, height, width, applyObject);
27216
- const anchorProps = this._getResizeAnchorProps(type, applyObject);
27217
26298
  const cursor = this._getRotateAnchorCursor(type);
27218
- const anchor = new TransformerAnchor(`${type}_${zIndex}`, {
26299
+ const anchor = new Rect(`${type}_${zIndex}`, {
27219
26300
  zIndex: zIndex - 1,
27220
26301
  fill: anchorFill,
27221
26302
  stroke: anchorStroke,
27222
26303
  strokeWidth: anchorStrokeWidth,
27223
- width: anchorProps.width,
27224
- height: anchorProps.height,
27225
- radius: anchorProps.radius,
27226
- left: left + (anchorSize - anchorProps.width) / 2,
27227
- top: top + (anchorSize - anchorProps.height) / 2,
27228
- shadowColor: anchorShadowColor,
27229
- shadowBlur: anchorShadowBlur,
27230
- shadowOffsetX: anchorShadowOffsetX,
27231
- shadowOffsetY: anchorShadowOffsetY
26304
+ width: anchorSize,
26305
+ height: anchorSize,
26306
+ radius: anchorCornerRadius,
26307
+ left,
26308
+ top
27232
26309
  });
27233
26310
  this._attachHover(anchor, cursor, "default");
27234
26311
  return anchor;
@@ -27476,7 +26553,7 @@ var Transformer = class extends Disposable {
27476
26553
  _createControl(applyObject, isSkipOnCropper = true) {
27477
26554
  const { left = 0, top = 0, height = 0, width = 0 } = applyObject.getState();
27478
26555
  const angle = applyObject.angle;
27479
- const { isCropper, resizeEnabled, rotateEnabled, rotateAnchorOffset, rotateLineEnabled, rotateSize, rotateCornerRadius, rotateFill, rotateStroke, rotateStrokeWidth, rotateIconEnabled, anchorShadowColor, anchorShadowBlur, anchorShadowOffsetX, anchorShadowOffsetY, borderEnabled, borderStroke, borderStrokeWidth, borderSpacing, enabledAnchors } = this._getConfig(applyObject);
26556
+ const { isCropper, resizeEnabled, rotateEnabled, rotateAnchorOffset, rotateSize, rotateCornerRadius, borderEnabled, borderStroke, borderStrokeWidth, borderSpacing, enabledAnchors } = this._getConfig(applyObject);
27480
26557
  if (isSkipOnCropper && isCropper) return;
27481
26558
  const oKey = applyObject.oKey;
27482
26559
  const zIndex = this._selectedObjectMap.size + applyObject.maxZIndex + DEFAULT_CONTROL_PLUS_INDEX;
@@ -27507,26 +26584,19 @@ var Transformer = class extends Disposable {
27507
26584
  });
27508
26585
  const { left: rotateLeft, top: rotateTop } = this._getRotateAnchorPosition("__SpreadsheetTransformerRotate__", height, width, applyObject);
27509
26586
  const cursor = this._getRotateAnchorCursor("__SpreadsheetTransformerRotate__");
27510
- const rotate = new TransformerAnchor(`__SpreadsheetTransformerRotate___${zIndex}`, {
26587
+ const rotate = new Rect(`__SpreadsheetTransformerRotate___${zIndex}`, {
27511
26588
  zIndex: zIndex - 1,
27512
26589
  left: rotateLeft,
27513
26590
  top: rotateTop,
27514
26591
  height: rotateSize,
27515
26592
  width: rotateSize,
27516
26593
  radius: rotateCornerRadius,
27517
- fill: rotateFill,
27518
- strokeWidth: rotateStrokeWidth !== null && rotateStrokeWidth !== void 0 ? rotateStrokeWidth : borderStrokeWidth * 2,
27519
- stroke: rotateStroke !== null && rotateStroke !== void 0 ? rotateStroke : borderStroke,
27520
- shadowColor: anchorShadowColor,
27521
- shadowBlur: anchorShadowBlur,
27522
- shadowOffsetX: anchorShadowOffsetX,
27523
- shadowOffsetY: anchorShadowOffsetY
26594
+ strokeWidth: borderStrokeWidth * 2,
26595
+ stroke: borderStroke
27524
26596
  });
27525
26597
  this._attachEventToRotate(rotate, applyObject);
27526
26598
  this._attachHover(rotate, cursor, "default");
27527
- if (rotateLineEnabled) groupElements.push(rotateLine);
27528
- groupElements.push(rotate);
27529
- if (rotateIconEnabled) groupElements.push(this._createRotateIcon(applyObject, zIndex, rotateLeft, rotateTop));
26599
+ groupElements.push(rotateLine, rotate);
27530
26600
  }
27531
26601
  }
27532
26602
  if (resizeEnabled) for (let i = 0, len = enabledAnchors.length; i < len; i++) {