@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/cjs/index.js CHANGED
@@ -665,7 +665,7 @@ function getSystemHighlightColor() {
665
665
  }
666
666
 
667
667
  //#endregion
668
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
668
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
669
669
  function _typeof(o) {
670
670
  "@babel/helpers - typeof";
671
671
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -676,7 +676,7 @@ function _typeof(o) {
676
676
  }
677
677
 
678
678
  //#endregion
679
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
679
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
680
680
  function toPrimitive(t, r) {
681
681
  if ("object" != _typeof(t) || !t) return t;
682
682
  var e = t[Symbol.toPrimitive];
@@ -689,14 +689,14 @@ function toPrimitive(t, r) {
689
689
  }
690
690
 
691
691
  //#endregion
692
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
692
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
693
693
  function toPropertyKey(t) {
694
694
  var i = toPrimitive(t, "string");
695
695
  return "symbol" == _typeof(i) ? i : i + "";
696
696
  }
697
697
 
698
698
  //#endregion
699
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
699
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
700
700
  function _defineProperty(e, r, t) {
701
701
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
702
702
  value: t,
@@ -2313,8 +2313,8 @@ var Path2 = class {
2313
2313
  const from = this._lines[o - 1];
2314
2314
  const to = this._lines[o];
2315
2315
  for (let n = 1; n < lines.length; n++) {
2316
- const contrastFrom = lines[n - 1];
2317
- const contrastTo = lines[n];
2316
+ const contrastFrom = this._lines[o - 1];
2317
+ const contrastTo = this._lines[o];
2318
2318
  const point = this._intersection({
2319
2319
  from,
2320
2320
  to
@@ -10878,8 +10878,8 @@ const TINF_OK = 0;
10878
10878
  const TINF_DATA_ERROR = -3;
10879
10879
  var Tree = class {
10880
10880
  constructor() {
10881
- _defineProperty(this, "table", /* @__PURE__ */ new Uint16Array(16));
10882
- _defineProperty(this, "trans", /* @__PURE__ */ new Uint16Array(288));
10881
+ _defineProperty(this, "table", new Uint16Array(16));
10882
+ _defineProperty(this, "trans", new Uint16Array(288));
10883
10883
  }
10884
10884
  };
10885
10885
  var Data = class {
@@ -10904,10 +10904,10 @@ var Data = class {
10904
10904
  };
10905
10905
  const sltree = new Tree();
10906
10906
  const sdtree = new Tree();
10907
- const length_bits = /* @__PURE__ */ new Uint8Array(30);
10908
- const length_base = /* @__PURE__ */ new Uint16Array(30);
10909
- const dist_bits = /* @__PURE__ */ new Uint8Array(30);
10910
- const dist_base = /* @__PURE__ */ new Uint16Array(30);
10907
+ const length_bits = new Uint8Array(30);
10908
+ const length_base = new Uint16Array(30);
10909
+ const dist_bits = new Uint8Array(30);
10910
+ const dist_base = new Uint16Array(30);
10911
10911
  const clcidx = new Uint8Array([
10912
10912
  16,
10913
10913
  17,
@@ -10930,7 +10930,7 @@ const clcidx = new Uint8Array([
10930
10930
  15
10931
10931
  ]);
10932
10932
  const code_tree = new Tree();
10933
- const lengths = /* @__PURE__ */ new Uint8Array(320);
10933
+ const lengths = new Uint8Array(320);
10934
10934
  function tinf_build_bits_base(bits, base, delta, first) {
10935
10935
  let i;
10936
10936
  let sum;
@@ -10955,7 +10955,7 @@ function tinf_build_fixed_trees(lt, dt) {
10955
10955
  dt.table[5] = 32;
10956
10956
  for (i = 0; i < 32; ++i) dt.trans[i] = i;
10957
10957
  }
10958
- const offs = /* @__PURE__ */ new Uint16Array(16);
10958
+ const offs = new Uint16Array(16);
10959
10959
  function tinf_build_tree(t, lengths, off, num) {
10960
10960
  let i;
10961
10961
  let sum;
@@ -12111,13 +12111,6 @@ function getDocsTableRenderViewport(unitId, tableId) {
12111
12111
  var _docsTableRenderViewp;
12112
12112
  return (_docsTableRenderViewp = docsTableRenderViewportProvider === null || docsTableRenderViewportProvider === void 0 ? void 0 : docsTableRenderViewportProvider(unitId, tableId)) !== null && _docsTableRenderViewp !== void 0 ? _docsTableRenderViewp : null;
12113
12113
  }
12114
- function getDocsTableVirtualContentWidth(viewport) {
12115
- var _viewport$leadingInse, _viewport$trailingIns;
12116
- 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);
12117
- }
12118
- function hasDocsTableHorizontalViewport(viewport) {
12119
- return viewport != null && getDocsTableVirtualContentWidth(viewport) > viewport.viewportWidth;
12120
- }
12121
12114
 
12122
12115
  //#endregion
12123
12116
  //#region src/components/docs/view-model/data-stream-tree-node.ts
@@ -12588,68 +12581,6 @@ var DocumentViewModel = class DocumentViewModel {
12588
12581
  }
12589
12582
  };
12590
12583
 
12591
- //#endregion
12592
- //#region src/components/docs/document-compatibility.ts
12593
- const MODERN_DOCUMENT_COMPATIBILITY_POLICY = {
12594
- mode: "modern",
12595
- applyDocumentDefaultParagraphStyle: true,
12596
- useWordStyleLineHeight: true,
12597
- font: { metricScaleRules: [] },
12598
- table: {
12599
- currentPageOverflowTolerance: 0,
12600
- rowOverflowTolerance: 0,
12601
- allowImportedTableMarginOverflow: false
12602
- }
12603
- };
12604
- const TRADITIONAL_DOCUMENT_COMPATIBILITY_POLICY = {
12605
- mode: "traditional",
12606
- applyDocumentDefaultParagraphStyle: false,
12607
- useWordStyleLineHeight: true,
12608
- font: { metricScaleRules: [{
12609
- fontFamily: /^calibri$/i,
12610
- minFontSize: 20,
12611
- fontString: /\bbold\b/i,
12612
- content: /^[\d/]+$/u,
12613
- widthScale: .92
12614
- }] },
12615
- table: {
12616
- currentPageOverflowTolerance: 12,
12617
- rowOverflowTolerance: 4,
12618
- allowImportedTableMarginOverflow: true
12619
- }
12620
- };
12621
- const UNSPECIFIED_DOCUMENT_COMPATIBILITY_POLICY = {
12622
- mode: "unspecified",
12623
- applyDocumentDefaultParagraphStyle: false,
12624
- useWordStyleLineHeight: false,
12625
- font: { metricScaleRules: [] },
12626
- table: {
12627
- currentPageOverflowTolerance: 0,
12628
- rowOverflowTolerance: 0,
12629
- allowImportedTableMarginOverflow: false
12630
- }
12631
- };
12632
- function getDocumentCompatibilityPolicy(documentFlavor) {
12633
- if (documentFlavor === _univerjs_core.DocumentFlavor.MODERN) return MODERN_DOCUMENT_COMPATIBILITY_POLICY;
12634
- if (documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL) return TRADITIONAL_DOCUMENT_COMPATIBILITY_POLICY;
12635
- return UNSPECIFIED_DOCUMENT_COMPATIBILITY_POLICY;
12636
- }
12637
- function applyFontMetricCompatibility(content, fontStyle, bBox, policy) {
12638
- const fontFamilies = fontStyle.fontFamily.split(",").map((item) => item.trim().replace(/^['"]|['"]$/g, ""));
12639
- 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)));
12640
- if ((rule === null || rule === void 0 ? void 0 : rule.widthScale) == null) return bBox;
12641
- return {
12642
- ...bBox,
12643
- width: bBox.width * rule.widthScale
12644
- };
12645
- }
12646
- function isTraditionalDocumentCompatibility(policy) {
12647
- return policy.mode === "traditional";
12648
- }
12649
- function shouldAllowImportedTableMarginOverflow(policy, tableSource) {
12650
- return policy.table.allowImportedTableMarginOverflow && tableSource != null && typeof tableSource === "object" && "docxWidth" in tableSource;
12651
- }
12652
-
12653
12584
  //#endregion
12654
12585
  //#region src/components/docs/layout/model/glyph.ts
12655
12586
  function isSpace(char) {
@@ -12730,7 +12661,6 @@ function createSkeletonCustomBlockGlyph(config, glyphWidth = 0, glyphHeight = 0,
12730
12661
  };
12731
12662
  }
12732
12663
  function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, glyphInfo) {
12733
- var _config$documentCompa;
12734
12664
  const { fontStyle, textStyle, charSpace = 1, gridType = _univerjs_core.GridType.LINES, snapToGrid = _univerjs_core.BooleanNumber.FALSE } = config;
12735
12665
  const skipWidthList = [
12736
12666
  _univerjs_core.DataStreamTreeTokenType.SECTION_BREAK,
@@ -12781,7 +12711,6 @@ function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, gly
12781
12711
  let xOffset = 0;
12782
12712
  if (glyphInfo && glyphInfo.boundingBox && glyphInfo.font) bBox = FontCache.getBBoxFromGlyphInfo(glyphInfo, fontStyle);
12783
12713
  else bBox = FontCache.getTextSize(content, fontStyle);
12784
- bBox = applyFontMetricCompatibility(content, fontStyle, bBox, (_config$documentCompa = config.documentCompatibilityPolicy) !== null && _config$documentCompa !== void 0 ? _config$documentCompa : getDocumentCompatibilityPolicy());
12785
12714
  const { width: contentWidth = 0 } = bBox;
12786
12715
  let width = glyphWidth !== null && glyphWidth !== void 0 ? glyphWidth : contentWidth;
12787
12716
  if (validationGrid(gridType, snapToGrid)) {
@@ -12902,11 +12831,11 @@ function createSkeletonLine(paragraphIndex, lineType, lineBoundingBox, columnWid
12902
12831
  lineSke.isBehindTable = true;
12903
12832
  lineSke.tableId = tableId;
12904
12833
  }
12905
- lineSke.divides = _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, new Map(Array.from(pageSkeDrawings).filter(([_, drawing]) => drawing.drawingOrigin.layoutType !== _univerjs_core.PositionedObjectLayoutType.INLINE && drawing.drawingOrigin.layoutType !== _univerjs_core.PositionedObjectLayoutType.WRAP_NONE)), headersDrawings, footersDrawings, new Map(Array.from(pageSkeTables).filter(([_, table]) => table.tableSource.textWrap === _univerjs_core.TableTextWrapType.WRAP)));
12834
+ lineSke.divides = _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, new Map(Array.from(pageSkeDrawings).filter(([_, drawing]) => drawing.drawingOrigin.layoutType !== _univerjs_core.PositionedObjectLayoutType.INLINE)), headersDrawings, footersDrawings, new Map(Array.from(pageSkeTables).filter(([_, table]) => table.tableSource.textWrap === _univerjs_core.TableTextWrapType.WRAP)));
12906
12835
  for (const divide of lineSke.divides) divide.parent = lineSke;
12907
12836
  return lineSke;
12908
12837
  }
12909
- function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, headerPage, footerPage, columnLeft = 0, columnWidth = 0) {
12838
+ function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, headerPage, footerPage) {
12910
12839
  let maxTop = lineTop;
12911
12840
  const pageSkeDrawings = page.skeDrawings;
12912
12841
  const skeNonWrapTables = new Map(Array.from(page.skeTables).filter(([_, table]) => table.tableSource.textWrap === _univerjs_core.TableTextWrapType.NONE));
@@ -12923,8 +12852,6 @@ function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, header
12923
12852
  pageSkeDrawings === null || pageSkeDrawings === void 0 || pageSkeDrawings.forEach((drawing) => {
12924
12853
  const top = _getLineTopWidthWrapTopBottom(drawing, lineHeight, lineTop);
12925
12854
  if (top) maxTop = Math.max(maxTop, top);
12926
- const blockingWrapTop = _getLineTopWithFullColumnWrap(drawing, lineHeight, lineTop, columnLeft, columnWidth);
12927
- if (blockingWrapTop) maxTop = Math.max(maxTop, blockingWrapTop);
12928
12855
  });
12929
12856
  skeNonWrapTables === null || skeNonWrapTables === void 0 || skeNonWrapTables.forEach((table) => {
12930
12857
  const top = _getLineTopWidthWrapNone(table, lineHeight, lineTop);
@@ -12932,37 +12859,6 @@ function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, header
12932
12859
  });
12933
12860
  return maxTop;
12934
12861
  }
12935
- function _getLineTopWithFullColumnWrap(drawing, lineHeight, lineTop, columnLeft, columnWidth) {
12936
- if (columnWidth <= 0) return;
12937
- const { aTop, height, aLeft, width, angle = 0, drawingOrigin } = drawing;
12938
- const { layoutType, distL = 0, distT = 0, distB = 0, distR = 0, wrapText } = drawingOrigin;
12939
- if (layoutType === _univerjs_core.PositionedObjectLayoutType.INLINE || layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_NONE || layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) return;
12940
- let top = aTop;
12941
- let drawingHeight = height;
12942
- let left = aLeft - columnLeft;
12943
- let drawingWidth = width;
12944
- if (angle !== 0) {
12945
- var _boundingBox$top, _boundingBox$height, _boundingBox$left, _boundingBox$width;
12946
- const boundingBox = getBoundingBox(angle, left, width, top, height);
12947
- top = (_boundingBox$top = boundingBox.top) !== null && _boundingBox$top !== void 0 ? _boundingBox$top : top;
12948
- drawingHeight = (_boundingBox$height = boundingBox.height) !== null && _boundingBox$height !== void 0 ? _boundingBox$height : drawingHeight;
12949
- left = (_boundingBox$left = boundingBox.left) !== null && _boundingBox$left !== void 0 ? _boundingBox$left : left;
12950
- drawingWidth = (_boundingBox$width = boundingBox.width) !== null && _boundingBox$width !== void 0 ? _boundingBox$width : drawingWidth;
12951
- }
12952
- const newTop = top - (layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_SQUARE ? distT : 0);
12953
- const newHeight = drawingHeight + (layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_SQUARE ? distB + distT : 0);
12954
- const bottom = newTop + newHeight;
12955
- if (bottom <= lineTop) return;
12956
- const split = __getSplitWidthNoAngle(top, drawingHeight, left, drawingWidth, newTop, Math.max(1, newHeight), columnWidth, {
12957
- distL,
12958
- distT,
12959
- distB,
12960
- distR
12961
- }, layoutType, wrapText);
12962
- if (!split) return;
12963
- if (split.left > 0 || split.left + split.width < columnWidth) return;
12964
- return bottom;
12965
- }
12966
12862
  function _getLineTopWidthWrapNone(table, lineHeight, lineTop) {
12967
12863
  const { top, height } = table;
12968
12864
  if (top + height < lineTop || top > lineHeight + lineTop) return;
@@ -13162,7 +13058,6 @@ function _calculateDivideByDrawings(columnWidth, drawingSplit) {
13162
13058
  divideSkeleton.push(divide);
13163
13059
  }
13164
13060
  }
13165
- if (divideSkeleton.length === 0 && columnWidth > 0) return [__getDivideSKe(0, columnWidth)];
13166
13061
  return divideSkeleton;
13167
13062
  }
13168
13063
  function __getDivideSKe(left, width) {
@@ -13219,11 +13114,17 @@ function createSkeletonSection(columnProperties = [], columnSeparatorType = _uni
13219
13114
  let colWidth = 0;
13220
13115
  let spaceWidth = 0;
13221
13116
  if (columnProperties.length === 0) columns.push(_getSkeletonColumn(left, sectionWidth, 0, _univerjs_core.ColumnSeparatorType.NONE));
13222
- else for (const { width, paddingEnd } of _fitColumnProperties(columnProperties, sectionWidth)) {
13117
+ else for (let i = 0; i < columnProperties.length; i++) {
13118
+ const { width, paddingEnd } = columnProperties[i];
13223
13119
  spaceWidth = paddingEnd;
13224
13120
  colWidth = width;
13225
13121
  columns.push(_getSkeletonColumn(left, colWidth, spaceWidth, columnSeparatorType));
13226
13122
  left += colWidth + spaceWidth;
13123
+ if (i === columnProperties.length - 1) {
13124
+ colWidth = sectionWidth !== Number.POSITIVE_INFINITY ? sectionWidth - colWidth : width;
13125
+ spaceWidth = 0;
13126
+ columns.push(_getSkeletonColumn(left, colWidth, spaceWidth, columnSeparatorType));
13127
+ }
13227
13128
  }
13228
13129
  const newSection = {
13229
13130
  columns,
@@ -13238,42 +13139,6 @@ function createSkeletonSection(columnProperties = [], columnSeparatorType = _uni
13238
13139
  });
13239
13140
  return newSection;
13240
13141
  }
13241
- function _fitColumnProperties(columnProperties, sectionWidth) {
13242
- if (sectionWidth === Number.POSITIVE_INFINITY || columnProperties.length === 0) return columnProperties;
13243
- const safeSectionWidth = Math.max(0, sectionWidth);
13244
- const widths = columnProperties.map(({ width }) => Math.max(0, width));
13245
- const spaces = columnProperties.map(({ paddingEnd }, index) => index === columnProperties.length - 1 ? 0 : Math.max(0, paddingEnd));
13246
- const totalWidth = widths.reduce((sum, width) => sum + width, 0);
13247
- if (safeSectionWidth === 0) return columnProperties.map((columnProperty) => ({
13248
- ...columnProperty,
13249
- width: 0,
13250
- paddingEnd: 0
13251
- }));
13252
- if (totalWidth <= 0) {
13253
- const equalWidth = safeSectionWidth / columnProperties.length;
13254
- return columnProperties.map((columnProperty, index) => ({
13255
- ...columnProperty,
13256
- width: equalWidth,
13257
- paddingEnd: 0
13258
- }));
13259
- }
13260
- if (totalWidth > safeSectionWidth) {
13261
- const scale = safeSectionWidth / totalWidth;
13262
- return columnProperties.map((columnProperty, index) => ({
13263
- ...columnProperty,
13264
- width: widths[index] * scale,
13265
- paddingEnd: 0
13266
- }));
13267
- }
13268
- const spaceBudget = safeSectionWidth - totalWidth;
13269
- const totalSpace = spaces.reduce((sum, space) => sum + space, 0);
13270
- const fittedSpaces = totalSpace > spaceBudget && totalSpace > 0 ? spaces.map((space) => space / totalSpace * spaceBudget) : spaces;
13271
- return columnProperties.map((columnProperty, index) => ({
13272
- ...columnProperty,
13273
- width: widths[index],
13274
- paddingEnd: fittedSpaces[index]
13275
- }));
13276
- }
13277
13142
  function setColumnFullState(column, state) {
13278
13143
  column.isFull = state;
13279
13144
  }
@@ -13374,13 +13239,12 @@ function createTableSkeleton(ctx, curPage, viewModel, tableNode, sectionBreakCon
13374
13239
  function rollbackListCache(listLevel, table) {
13375
13240
  const { startIndex, endIndex } = table;
13376
13241
  for (const paragraphLists of listLevel.values()) for (const paragraphList of paragraphLists) {
13377
- if (paragraphList == null) continue;
13378
13242
  const paragraphListIndex = paragraphList.findIndex((p) => p.paragraph.startIndex > startIndex && p.paragraph.startIndex < endIndex);
13379
13243
  if (paragraphListIndex > -1) paragraphList.splice(paragraphListIndex);
13380
13244
  }
13381
13245
  }
13382
13246
  function createTableSkeletons(ctx, curPage, viewModel, tableNode, sectionBreakConfig, availableHeight) {
13383
- var _viewModel$getTableBy2, _sectionBreakConfig$d;
13247
+ var _viewModel$getTableBy2;
13384
13248
  const skeTables = [];
13385
13249
  const { startIndex, endIndex, children: rowNodes } = tableNode;
13386
13250
  const table = (_viewModel$getTableBy2 = viewModel.getTableByStartIndex(startIndex)) === null || _viewModel$getTableBy2 === void 0 ? void 0 : _viewModel$getTableBy2.tableSource;
@@ -13403,10 +13267,9 @@ function createTableSkeletons(ctx, curPage, viewModel, tableNode, sectionBreakCo
13403
13267
  skeTables.push(curTableSkeleton);
13404
13268
  for (const rowNode of rowNodes) dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig, rowNode, rowNodes.indexOf(rowNode), table, createCache);
13405
13269
  updateTableSkeletonsPosition(createCache, curPage, skeTables, table);
13406
- const documentCompatibilityPolicy = (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy();
13407
13270
  return {
13408
13271
  skeTables,
13409
- fromCurrentPage: skeTables[0].height <= availableHeight + documentCompatibilityPolicy.table.currentPageOverflowTolerance
13272
+ fromCurrentPage: skeTables[0].height <= availableHeight
13410
13273
  };
13411
13274
  }
13412
13275
  function updateTableSkeletonsPosition(cache, curPage, skeTables, table) {
@@ -13436,16 +13299,14 @@ function getAvailableHeight(curPage, cache, hasRepeatHeader) {
13436
13299
  return pageContentHeight;
13437
13300
  }
13438
13301
  function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig, rowNode, row, table, cache, isRepeatRow = false) {
13439
- var _sectionBreakConfig$d2;
13440
13302
  const pageContentHeight = getAvailableHeight(curPage, cache, false);
13441
13303
  const availableHeight = getAvailableHeight(curPage, cache, true);
13442
- const documentCompatibilityPolicy = (_sectionBreakConfig$d2 = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d2 !== void 0 ? _sectionBreakConfig$d2 : getDocumentCompatibilityPolicy();
13443
13304
  const { children: cellNodes, startIndex, endIndex } = rowNode;
13444
13305
  const rowSource = table.tableRows[row];
13445
13306
  const { trHeight, cantSplit } = rowSource;
13446
13307
  const rowSkeletons = [];
13447
13308
  const { hRule, val } = trHeight;
13448
- const canRowSplit = cantSplit !== _univerjs_core.BooleanNumber.TRUE && trHeight.hRule === _univerjs_core.TableRowHeightRule.AUTO;
13309
+ const canRowSplit = cantSplit === _univerjs_core.BooleanNumber.TRUE && trHeight.hRule === _univerjs_core.TableRowHeightRule.AUTO;
13449
13310
  const MAX_FONT_SIZE = 72;
13450
13311
  const needOpenNewTable = cache.remainHeight <= MAX_FONT_SIZE;
13451
13312
  let curTableSkeleton = getCurTableSkeleton(skeTables);
@@ -13491,8 +13352,7 @@ function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig
13491
13352
  while (rowSkeletons.length > 0) {
13492
13353
  const rowSkeleton = rowSkeletons.shift();
13493
13354
  const lastRow = curTableSkeleton.rows[curTableSkeleton.rows.length - 1];
13494
- const rowOverflowHeight = rowSkeleton.height - cache.remainHeight;
13495
- if (cache.remainHeight < MAX_FONT_SIZE || rowOverflowHeight > documentCompatibilityPolicy.table.rowOverflowTolerance) {
13355
+ if (cache.remainHeight < MAX_FONT_SIZE || cache.remainHeight < rowSkeleton.height) {
13496
13356
  cache.remainHeight = getAvailableHeight(curPage, cache, row !== 0 && rowSkeleton.index !== lastRow.index);
13497
13357
  cache.rowTop = 0;
13498
13358
  if (curTableSkeleton.rows.length > 0) {
@@ -13668,22 +13528,18 @@ function getTableIdAndSliceIndex(tableSliceId) {
13668
13528
 
13669
13529
  //#endregion
13670
13530
  //#region src/components/docs/layout/block/paragraph/layout-ruler.ts
13671
- const LINE_LAYOUT_OVERFLOW_TOLERANCE = 2;
13672
- const FLOAT_OBJECT_RELAYOUT_LIMIT = 5;
13673
13531
  function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal") {
13674
13532
  if (isParagraphFirstShapedText) if (paragraphConfig.bulletSkeleton) {
13675
- var _paragraphProperties$;
13676
13533
  const { bulletSkeleton, paragraphStyle = {} } = paragraphConfig;
13677
13534
  const { gridType = _univerjs_core.GridType.LINES, charSpace = 0, defaultTabStop = 10.5 } = sectionBreakConfig;
13678
13535
  const { snapToGrid = _univerjs_core.BooleanNumber.TRUE } = paragraphStyle;
13679
13536
  const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
13680
13537
  const bulletGlyph = createSkeletonBulletGlyph(glyphGroup[0], bulletSkeleton, charSpaceApply);
13681
13538
  const paragraphProperties = bulletSkeleton.paragraphProperties || {};
13682
- paragraphConfig.paragraphStyle = {
13539
+ paragraphConfig.paragraphStyle = mergeByV(paragraphConfig.paragraphStyle, {
13683
13540
  ...paragraphProperties,
13684
- hanging: (_paragraphProperties$ = paragraphProperties.hanging) !== null && _paragraphProperties$ !== void 0 ? _paragraphProperties$ : { v: bulletGlyph.width },
13685
- ...paragraphConfig.paragraphStyle
13686
- };
13541
+ hanging: { v: bulletGlyph.width }
13542
+ }, "max");
13687
13543
  _lineOperator(ctx, [bulletGlyph, ...glyphGroup], pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
13688
13544
  } else _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
13689
13545
  else _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
@@ -13712,11 +13568,6 @@ function isGlyphGroupBeyondContentBox(glyphGroup, left, divideWidth) {
13712
13568
  }
13713
13569
  return isBeyondContentBox;
13714
13570
  }
13715
- function shouldKeepOverflowingTextOnLine(sectionBreakConfig) {
13716
- var _sectionBreakConfig$r;
13717
- const wrapStrategy = (_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.wrapStrategy;
13718
- return wrapStrategy === _univerjs_core.WrapStrategy.CLIP || wrapStrategy === _univerjs_core.WrapStrategy.OVERFLOW;
13719
- }
13720
13571
  function _getConsecutiveHyphenLineCount(divide) {
13721
13572
  var _divide$parent;
13722
13573
  const column = (_divide$parent = divide.parent) === null || _divide$parent === void 0 ? void 0 : _divide$parent.parent;
@@ -13752,20 +13603,12 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13752
13603
  const preOffsetLeft = ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.width) || 0) + ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.left) || 0);
13753
13604
  const { hyphenationZone } = sectionBreakConfig;
13754
13605
  if (preOffsetLeft + width > divide.width) {
13755
- if (shouldKeepOverflowingTextOnLine(sectionBreakConfig)) {
13756
- addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13757
- updateDivideInfo(divide, { breakType: breakPointType });
13758
- return;
13759
- }
13760
13606
  updateDivideInfo(divide, { isFull: true });
13761
13607
  const hyphenLineCount = _getConsecutiveHyphenLineCount(divideInfo.divide);
13762
13608
  const { consecutiveHyphenLimit = Number.POSITIVE_INFINITY } = sectionBreakConfig;
13763
13609
  if (divideInfo.isLast && glyphGroup.length === 1 && (glyphGroup[0].content === _univerjs_core.DataStreamTreeTokenType.SPACE || glyphGroup[0].content === _univerjs_core.DataStreamTreeTokenType.PARAGRAPH)) addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13764
13610
  else if (divideInfo.isLast && !isGlyphGroupBeyondContentBox(glyphGroup, preOffsetLeft, divide.width) && isGlyphGroupEndWithWhiteSpaces(glyphGroup)) addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13765
- else if (!isLast && (divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0 && glyphGroup.length === 1 && glyphGroup[0].streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK && glyphGroup[0].width > divide.width) {
13766
- updateDivideInfo(divide, { isFull: true });
13767
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
13768
- } else if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0) {
13611
+ else if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0) {
13769
13612
  const sliceGlyphGroup = [];
13770
13613
  while (glyphGroup.length) {
13771
13614
  sliceGlyphGroup.push(glyphGroup.shift());
@@ -13790,16 +13633,11 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13790
13633
  } else {
13791
13634
  const currentLine = divide.parent;
13792
13635
  const maxBox = __maxFontBoundingBoxByGlyphGroup(glyphGroup);
13793
- if (currentLine && __isZeroWidthNonFlowFloatingAnchorLine(__getGlyphGroupByLine(currentLine), paragraphConfig.paragraphNonInlineSkeDrawings) && __hasFlowGlyph(glyphGroup)) {
13794
- for (const lineDivide of currentLine.divides) updateDivideInfo(lineDivide, { isFull: true });
13795
- _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, false, breakPointType);
13796
- return;
13797
- }
13798
- if (currentLine && maxBox && !__isNullLine(currentLine) && __hasFlowGlyph(__getGlyphGroupByLine(currentLine)) && !__isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphConfig.paragraphNonInlineSkeDrawings)) {
13636
+ if (currentLine && maxBox && !__isNullLine(currentLine)) {
13799
13637
  const { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(sectionBreakConfig, paragraphConfig);
13800
13638
  const { boundingBoxAscent, boundingBoxDescent } = maxBox;
13801
- const { contentHeight } = getLineHeightMetrics(boundingBoxAscent + boundingBoxDescent, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid, paragraphConfig.useWordStyleLineHeight);
13802
- if (contentHeight - currentLine.contentHeight > LINE_LAYOUT_OVERFLOW_TOLERANCE) {
13639
+ const { contentHeight } = __getLineHeight(boundingBoxAscent + boundingBoxDescent, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid);
13640
+ if (currentLine.contentHeight < contentHeight) {
13803
13641
  const spanGroupCached = __getGlyphGroupByLine(currentLine);
13804
13642
  const spanGroupCachedLen = spanGroupCached.length;
13805
13643
  let newGlyphGroup = [];
@@ -13815,15 +13653,6 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13815
13653
  return;
13816
13654
  }
13817
13655
  }
13818
- if (currentLine === null || currentLine === void 0 ? void 0 : currentLine.parent) {
13819
- const anchorDrawings = __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphConfig.paragraphNonInlineSkeDrawings);
13820
- if (anchorDrawings.length > 0) {
13821
- var _paragraphConfig$para, _paragraphConfig$pDra;
13822
- const paragraphAnchorLeft = __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, (_paragraphConfig$para = paragraphConfig.paragraphStyle) === null || _paragraphConfig$para === void 0 ? void 0 : _paragraphConfig$para.indentStart);
13823
- 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);
13824
- __updateDrawingPosition(currentLine.parent, drawings);
13825
- }
13826
- }
13827
13656
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13828
13657
  updateDivideInfo(divide, { breakType: breakPointType });
13829
13658
  }
@@ -13849,7 +13678,6 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13849
13678
  const descent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.bd));
13850
13679
  const glyphLineHeight = defaultGlyphLineHeight || ascent + descent;
13851
13680
  const { paragraphStyle: originParagraphStyle = {}, paragraphNonInlineSkeDrawings, skeTablesInParagraph, skeHeaders, skeFooters, pDrawingAnchor, paragraphIndex } = paragraphConfig;
13852
- const isZeroWidthNonFlowFloatingAnchorLine = __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings);
13853
13681
  const { namedStyleType } = originParagraphStyle;
13854
13682
  const namedStyle = namedStyleType !== void 0 ? _univerjs_core.NAMED_STYLE_SPACE_MAP[namedStyleType] : null;
13855
13683
  const { spaceAbove, spaceBelow, indentFirstLine, hanging, indentStart, indentEnd } = {
@@ -13858,22 +13686,9 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13858
13686
  spaceBelow: (_originParagraphStyle2 = originParagraphStyle.spaceBelow) !== null && _originParagraphStyle2 !== void 0 ? _originParagraphStyle2 : namedStyle === null || namedStyle === void 0 ? void 0 : namedStyle.spaceBelow
13859
13687
  };
13860
13688
  const { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(sectionBreakConfig, paragraphConfig);
13861
- const hasInlineCustomBlock = glyphGroup.some((glyph) => glyph.streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0);
13862
- const glyphGroupCustomBlockIds = new Set(glyphGroup.filter((glyph) => glyph.streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.drawingId != null).map((glyph) => glyph.drawingId));
13863
- let { paddingTop, paddingBottom, contentHeight, lineSpacingApply } = getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid, paragraphConfig.useWordStyleLineHeight, !hasInlineCustomBlock);
13864
- let { marginTop, spaceBelowApply } = __getParagraphSpace(ctx, lineSpacingApply, spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine);
13865
- if (isZeroWidthNonFlowFloatingAnchorLine) {
13866
- paddingTop = 0;
13867
- paddingBottom = 0;
13868
- contentHeight = 0;
13869
- lineSpacingApply = 0;
13870
- marginTop = 0;
13871
- spaceBelowApply = 0;
13872
- }
13689
+ const { paddingTop, paddingBottom, contentHeight, lineSpacingApply } = __getLineHeight(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid);
13690
+ const { marginTop, spaceBelowApply } = __getParagraphSpace(ctx, lineSpacingApply, spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine);
13873
13691
  const lineHeight = marginTop + paddingTop + contentHeight + paddingBottom;
13874
- const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);
13875
- const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
13876
- const paragraphAnchorLeft = __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, indentStart);
13877
13692
  let section = column.parent;
13878
13693
  if (!section) section = getLastSection(lastPage);
13879
13694
  const lineTop = ((preLine === null || preLine === void 0 ? void 0 : preLine.lineHeight) || 0) + ((preLine === null || preLine === void 0 ? void 0 : preLine.top) || 0);
@@ -13890,22 +13705,16 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13890
13705
  if (relativeLineDrawings.length > 0) __updateAndPositionDrawings(ctx, preLine.top, preLine.lineHeight, column, relativeLineDrawings, preLine.paragraphIndex, isParagraphFirstShapedText);
13891
13706
  }
13892
13707
  }
13893
- let deferredInlineGroupAnchorDrawings = [];
13894
13708
  if (paragraphNonInlineSkeDrawings != null && paragraphNonInlineSkeDrawings.size > 0) {
13895
13709
  var _pDrawingAnchor$get;
13896
- let targetDrawings = [...paragraphNonInlineSkeDrawings.values()].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom !== _univerjs_core.ObjectRelativeFromV.LINE);
13897
- if (hasInlineCustomBlock) {
13898
- deferredInlineGroupAnchorDrawings = targetDrawings.filter((drawing) => glyphGroupCustomBlockIds.has(drawing.drawingId) && drawing.drawingOrigin.docTransform.positionV.relativeFrom === _univerjs_core.ObjectRelativeFromV.LINE);
13899
- targetDrawings = targetDrawings.filter((drawing) => !deferredInlineGroupAnchorDrawings.includes(drawing));
13900
- }
13901
- __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);
13710
+ __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, [...paragraphNonInlineSkeDrawings.values()].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom !== _univerjs_core.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);
13902
13711
  }
13903
13712
  if (skeTablesInParagraph != null && skeTablesInParagraph.length > 0) {
13904
13713
  var _pDrawingAnchor$get2;
13905
13714
  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);
13906
13715
  }
13907
13716
  const newLineTop = calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage);
13908
- if (lineHeight + newLineTop - section.height > LINE_LAYOUT_OVERFLOW_TOLERANCE && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
13717
+ if (lineHeight + newLineTop > section.height && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
13909
13718
  setColumnFullState(column, true);
13910
13719
  _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
13911
13720
  if (isParagraphFirstShapedText && paragraphNonInlineSkeDrawings && paragraphNonInlineSkeDrawings.size > 0) for (const drawing of paragraphNonInlineSkeDrawings.values()) {
@@ -13919,7 +13728,8 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13919
13728
  return;
13920
13729
  }
13921
13730
  const lineIndex = preLine ? preLine.lineIndex + 1 : 0;
13922
- let { paddingLeft, paddingRight } = __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, charSpaceApply, isParagraphFirstShapedText);
13731
+ const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);
13732
+ let { paddingLeft, paddingRight } = __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid), isParagraphFirstShapedText);
13923
13733
  if (paddingLeft + paddingRight >= column.width) {
13924
13734
  const leftPercent = paddingLeft / (paddingLeft + paddingRight);
13925
13735
  paddingLeft = column.width * leftPercent - .5;
@@ -13940,16 +13750,12 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13940
13750
  newLine.parent = column;
13941
13751
  createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor);
13942
13752
  _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
13943
- if (deferredInlineGroupAnchorDrawings.length > 0) {
13944
- var _pDrawingAnchor$get3;
13945
- __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);
13946
- }
13947
13753
  }
13948
- function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop, drawingAnchorLeft = 0, skipRelayoutCheck = false) {
13754
+ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop) {
13949
13755
  if (targetDrawings.length === 0) return;
13950
- const drawings = __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
13756
+ const drawings = __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings);
13951
13757
  if (drawings == null || drawings.size === 0) return;
13952
- const floatObjects = [...drawings.values()].filter((drawing) => {
13758
+ _reLayoutCheck(ctx, [...drawings.values()].filter((drawing) => {
13953
13759
  const layoutType = drawing.drawingOrigin.layoutType;
13954
13760
  return layoutType !== _univerjs_core.PositionedObjectLayoutType.INLINE && layoutType !== _univerjs_core.PositionedObjectLayoutType.WRAP_NONE;
13955
13761
  }).map((drawing) => {
@@ -13962,13 +13768,10 @@ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDra
13962
13768
  width,
13963
13769
  height,
13964
13770
  angle,
13965
- behindDoc: drawingOrigin.behindDoc,
13966
- layoutType: drawingOrigin.layoutType,
13967
13771
  type: "IMAGE",
13968
13772
  positionV
13969
13773
  };
13970
- });
13971
- if (!skipRelayoutCheck) _reLayoutCheck(ctx, floatObjects, column, paragraphIndex);
13774
+ }), column, paragraphIndex);
13972
13775
  __updateDrawingPosition(column, drawings);
13973
13776
  }
13974
13777
  function __updateWrapTablePosition(ctx, table, lineTop, lineHeight, column, paragraphIndex, drawingAnchorTop) {
@@ -14001,22 +13804,6 @@ function __getWrapTablePosition(table, column, lineTop, lineHeight, drawingAncho
14001
13804
  top: (_getPositionVertical = getPositionVertical(positionV, page, lineTop, lineHeight, height, drawingAnchorTop, isPageBreak)) !== null && _getPositionVertical !== void 0 ? _getPositionVertical : 0
14002
13805
  };
14003
13806
  }
14004
- function __avoidFlowAffectingDrawingsForTable(table, page, column) {
14005
- const tableTop = table.top;
14006
- const tableBottom = table.top + table.height;
14007
- const tableRight = table.left + table.width;
14008
- for (const drawing of page.skeDrawings.values()) {
14009
- var _drawingOrigin$distR;
14010
- const drawingOrigin = drawing.drawingOrigin;
14011
- if (drawingOrigin == null || drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.INLINE || drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_NONE || drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) continue;
14012
- const drawingTop = drawing.aTop;
14013
- const drawingBottom = drawing.aTop + drawing.height;
14014
- if (drawingTop >= tableBottom || drawingBottom <= tableTop) continue;
14015
- const drawingRight = drawing.aLeft + drawing.width + ((_drawingOrigin$distR = drawingOrigin.distR) !== null && _drawingOrigin$distR !== void 0 ? _drawingOrigin$distR : 0);
14016
- if (drawing.aLeft >= tableRight || drawingRight <= table.left) continue;
14017
- if (drawingRight + table.width <= column.width) table.left = Math.max(table.left, drawingRight);
14018
- }
14019
- }
14020
13807
  function _updateAndPositionTable(ctx, lineTop, lineHeight, page, column, section, skeTablesInParagraph, paragraphIndex, sectionBreakConfig, drawingAnchorTop) {
14021
13808
  if (skeTablesInParagraph.length === 0) return false;
14022
13809
  const firstUnPositionedTable = skeTablesInParagraph.find((table) => table.hasPositioned === false);
@@ -14026,7 +13813,6 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, column, section
14026
13813
  if (firstUnPositionedTable.isSlideTable === false) switch (tableSource.textWrap) {
14027
13814
  case _univerjs_core.TableTextWrapType.NONE:
14028
13815
  table.top = lineTop;
14029
- __avoidFlowAffectingDrawingsForTable(table, page, column);
14030
13816
  break;
14031
13817
  case _univerjs_core.TableTextWrapType.WRAP:
14032
13818
  __updateWrapTablePosition(ctx, table, lineTop, lineHeight, column, paragraphIndex, drawingAnchorTop);
@@ -14080,47 +13866,15 @@ function _getCustomBlockIdsInLine(line) {
14080
13866
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK) customBlockIds.push(glyph.drawingId);
14081
13867
  return customBlockIds;
14082
13868
  }
14083
- function __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings) {
14084
- return __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings).length > 0;
14085
- }
14086
- function __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings) {
14087
- const drawings = [];
14088
- for (const glyph of glyphGroup) {
14089
- if (__isStructuralTerminatorGlyph(glyph)) continue;
14090
- if (__isIgnorableZeroSizeGlyph(glyph)) continue;
14091
- if (glyph.streamType !== _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK || glyph.width !== 0 || glyph.drawingId == null) return [];
14092
- const drawing = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.get(glyph.drawingId);
14093
- const drawingOrigin = drawing === null || drawing === void 0 ? void 0 : drawing.drawingOrigin;
14094
- if (drawing == null || drawingOrigin == null) return [];
14095
- if (drawingOrigin.layoutType !== _univerjs_core.PositionedObjectLayoutType.WRAP_NONE) return [];
14096
- drawings.push(drawing);
14097
- }
14098
- return drawings;
14099
- }
14100
- function __isIgnorableZeroSizeGlyph(glyph) {
14101
- return glyph.content === "" && glyph.drawingId == null && glyph.width === 0 && glyph.bBox.ba + glyph.bBox.bd === 0;
14102
- }
14103
- function __isStructuralTerminatorGlyph(glyph) {
14104
- return glyph.streamType === _univerjs_core.DataStreamTreeTokenType.PARAGRAPH || glyph.streamType === _univerjs_core.DataStreamTreeTokenType.SECTION_BREAK || glyph.streamType === _univerjs_core.DataStreamTreeTokenType.DOCS_END;
14105
- }
14106
- function __hasFlowGlyph(glyphGroup) {
14107
- return glyphGroup.some((glyph) => {
14108
- if (__isStructuralTerminatorGlyph(glyph)) return false;
14109
- if (glyph.streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK) return glyph.width !== 0;
14110
- return glyph.content !== "" || glyph.width > 0 || glyph.bBox.ba + glyph.bBox.bd > 0;
14111
- });
14112
- }
14113
13869
  function _reLayoutCheck(ctx, floatObjects, column, paragraphIndex) {
14114
13870
  var _column$parent2;
14115
13871
  const page = (_column$parent2 = column.parent) === null || _column$parent2 === void 0 ? void 0 : _column$parent2.parent;
14116
- const flowAffectingFloatObjects = floatObjects.filter((floatObject) => floatObject.behindDoc !== _univerjs_core.BooleanNumber.TRUE || floatObject.layoutType != null && floatObject.layoutType !== _univerjs_core.PositionedObjectLayoutType.WRAP_NONE);
14117
- if (flowAffectingFloatObjects.length === 0 || page == null) return;
13872
+ if (floatObjects.length === 0 || page == null) return;
14118
13873
  let needBreakLineIterator = false;
14119
- for (const floatObject of flowAffectingFloatObjects) {
13874
+ for (const floatObject of floatObjects) {
14120
13875
  var _floatObjectCache$pag, _page$sections$;
14121
13876
  const floatObjectCache = ctx.floatObjectsCache.get(floatObject.id);
14122
13877
  if (floatObjectCache == null || floatObjectCache.page.segmentId !== page.segmentId) continue;
14123
- if (floatObjectCache.count >= FLOAT_OBJECT_RELAYOUT_LIMIT) continue;
14124
13878
  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;
14125
13879
  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;
14126
13880
  if (floatObjectCache.page && cachePageStartParagraphIndex && startIndex && cachePageStartParagraphIndex !== startIndex) {
@@ -14146,7 +13900,7 @@ function _reLayoutCheck(ctx, floatObjects, column, paragraphIndex) {
14146
13900
  const { lineHeight, top } = line;
14147
13901
  const { width: columnWidth, left: columnLeft } = column;
14148
13902
  if (needBreakLineIterator) return;
14149
- for (const floatObject of flowAffectingFloatObjects.values()) {
13903
+ for (const floatObject of floatObjects.values()) {
14150
13904
  let targetObject = floatObject;
14151
13905
  if (ctx.floatObjectsCache.has(floatObject.id)) {
14152
13906
  const drawingCache = ctx.floatObjectsCache.get(floatObject.id);
@@ -14184,7 +13938,7 @@ function checkRelativeDrawingNeedRePosition(ctx, floatObject) {
14184
13938
  if (drawingCache == null) return false;
14185
13939
  if (relativeFrom === _univerjs_core.ObjectRelativeFromV.PARAGRAPH || relativeFrom === _univerjs_core.ObjectRelativeFromV.LINE) {
14186
13940
  const { count, floatObject: prevObject } = drawingCache;
14187
- if (count < FLOAT_OBJECT_RELAYOUT_LIMIT && Math.abs(floatObject.top - prevObject.top) > 5) return true;
13941
+ if (count < 5 && Math.abs(floatObject.top - prevObject.top) > 5) return true;
14188
13942
  }
14189
13943
  return false;
14190
13944
  }
@@ -14241,87 +13995,43 @@ function __getParagraphSpace(ctx, lineSpacing = 0, spaceAbove, spaceBelow, isPar
14241
13995
  spaceBelowApply
14242
13996
  };
14243
13997
  }
14244
- function __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, indentStart) {
14245
- const { paragraphStyle = {} } = paragraphConfig;
14246
- const { snapToGrid = _univerjs_core.BooleanNumber.TRUE } = paragraphStyle;
14247
- const { gridType = _univerjs_core.GridType.LINES } = sectionBreakConfig;
14248
- const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);
14249
- const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
14250
- const paragraphAnchorLeft = getNumberUnitValue(indentStart, charSpaceApply);
14251
- if (paragraphAnchorLeft > 0) return paragraphAnchorLeft;
14252
- return getNumberUnitValue(paragraphConfig.docxFallbackAnchorLeft, charSpaceApply);
14253
- }
14254
- function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid, useWordStyleLineHeight = true, scaleAutoLineSpacingByGlyphHeight = true) {
14255
- if (!useWordStyleLineHeight) {
14256
- let paddingTop = paragraphLineGapDefault;
14257
- let paddingBottom = paragraphLineGapDefault;
14258
- if (gridType === _univerjs_core.GridType.DEFAULT || snapToGrid === _univerjs_core.BooleanNumber.FALSE) {
14259
- if (spacingRule === _univerjs_core.SpacingRule.AUTO) return {
14260
- paddingTop,
14261
- paddingBottom,
14262
- contentHeight: lineSpacing * glyphLineHeight,
14263
- lineSpacingApply: glyphLineHeight
14264
- };
14265
- return {
14266
- paddingTop,
14267
- paddingBottom,
14268
- contentHeight: Math.max(lineSpacing, glyphLineHeight),
14269
- lineSpacingApply: lineSpacing
14270
- };
14271
- }
14272
- let lineSpacingApply = 0;
14273
- if (spacingRule === _univerjs_core.SpacingRule.AUTO) lineSpacingApply = lineSpacing * linePitch;
14274
- else lineSpacingApply = lineSpacing;
14275
- if (glyphLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply) paddingTop = paddingBottom = (lineSpacingApply - glyphLineHeight) / 2;
14276
- else lineSpacingApply = glyphLineHeight;
14277
- return {
13998
+ function __getLineHeight(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid) {
13999
+ let paddingTop = paragraphLineGapDefault;
14000
+ let paddingBottom = paragraphLineGapDefault;
14001
+ if (gridType === _univerjs_core.GridType.DEFAULT || snapToGrid === _univerjs_core.BooleanNumber.FALSE) {
14002
+ if (spacingRule === _univerjs_core.SpacingRule.AUTO) return {
14278
14003
  paddingTop,
14279
14004
  paddingBottom,
14280
- contentHeight: glyphLineHeight,
14281
- lineSpacingApply
14005
+ contentHeight: lineSpacing * glyphLineHeight,
14006
+ lineSpacingApply: glyphLineHeight
14282
14007
  };
14283
- }
14284
- const usesDocumentGrid = spacingRule === _univerjs_core.SpacingRule.AUTO && snapToGrid === _univerjs_core.BooleanNumber.TRUE && gridType !== _univerjs_core.GridType.DEFAULT;
14285
- if (spacingRule === _univerjs_core.SpacingRule.AUTO) {
14286
- const lineSpacingApply = usesDocumentGrid ? lineSpacing * linePitch : scaleAutoLineSpacingByGlyphHeight ? lineSpacing * glyphLineHeight : glyphLineHeight;
14287
- const padding = (lineSpacingApply - glyphLineHeight) / 2;
14288
- return {
14289
- paddingTop: padding,
14290
- paddingBottom: padding,
14291
- contentHeight: glyphLineHeight,
14292
- lineSpacingApply
14293
- };
14294
- }
14295
- if (spacingRule === _univerjs_core.SpacingRule.AT_LEAST) {
14296
- const lineSpacingApply = Math.max(lineSpacing, glyphLineHeight);
14297
- const padding = (lineSpacingApply - glyphLineHeight) / 2;
14298
14008
  return {
14299
- paddingTop: padding,
14300
- paddingBottom: padding,
14301
- contentHeight: glyphLineHeight,
14302
- lineSpacingApply
14009
+ paddingTop,
14010
+ paddingBottom,
14011
+ contentHeight: Math.max(lineSpacing, glyphLineHeight),
14012
+ lineSpacingApply: lineSpacing
14303
14013
  };
14304
14014
  }
14305
- const exactLineSpacingApply = snapToGrid === _univerjs_core.BooleanNumber.TRUE && gridType !== _univerjs_core.GridType.DEFAULT ? Math.max(lineSpacing, linePitch) : lineSpacing;
14306
- const exactPadding = (exactLineSpacingApply - glyphLineHeight) / 2;
14015
+ let lineSpacingApply = 0;
14016
+ if (spacingRule === _univerjs_core.SpacingRule.AUTO) lineSpacingApply = lineSpacing * linePitch;
14017
+ else lineSpacingApply = lineSpacing;
14018
+ if (glyphLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply) paddingTop = paddingBottom = (lineSpacingApply - glyphLineHeight) / 2;
14019
+ else lineSpacingApply = glyphLineHeight;
14307
14020
  return {
14308
- paddingTop: exactPadding,
14309
- paddingBottom: exactPadding,
14021
+ paddingTop,
14022
+ paddingBottom,
14310
14023
  contentHeight: glyphLineHeight,
14311
- lineSpacingApply: exactLineSpacingApply
14024
+ lineSpacingApply
14312
14025
  };
14313
14026
  }
14314
- function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnchorTop, paragraphNonInlineSkeDrawings) {
14315
- var _line$parent, _section$top;
14027
+ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnchorTop) {
14028
+ var _line$parent;
14316
14029
  const column = line.parent;
14317
- const section = column === null || column === void 0 ? void 0 : column.parent;
14318
14030
  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;
14319
14031
  if (page == null || column == null) return;
14320
14032
  const isPageBreak = __checkPageBreak(column);
14321
14033
  const drawings = /* @__PURE__ */ new Map();
14322
14034
  const { top, lineHeight, marginBottom = 0 } = line;
14323
- const sectionTop = (_section$top = section === null || section === void 0 ? void 0 : section.top) !== null && _section$top !== void 0 ? _section$top : 0;
14324
- const lineTop = sectionTop + top;
14325
14035
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0) {
14326
14036
  const { drawingId } = glyph;
14327
14037
  if (drawingId == null) continue;
@@ -14332,37 +14042,21 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14332
14042
  const { size, angle } = docTransform;
14333
14043
  const { width = 0, height = 0 } = size;
14334
14044
  const glyphHeight = glyph.bBox.bd + glyph.bBox.ba;
14335
- drawing.aLeft = column.left + divide.left + divide.paddingLeft + glyph.left + .5 * glyph.width - .5 * width || 0;
14336
- if (glyph.width > divide.width) {
14337
- var _paragraphNonInlineSk;
14338
- for (const positionedDrawing of (_paragraphNonInlineSk = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.values()) !== null && _paragraphNonInlineSk !== void 0 ? _paragraphNonInlineSk : []) {
14339
- const positionedOrigin = positionedDrawing.drawingOrigin;
14340
- if (positionedOrigin == null || positionedOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.INLINE || positionedOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_NONE || positionedOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) continue;
14341
- const positionedBottom = positionedDrawing.aTop + positionedDrawing.height;
14342
- const lineBottom = lineTop + lineHeight;
14343
- if (positionedDrawing.aTop >= lineBottom || positionedBottom <= lineTop) continue;
14344
- const positionedRight = positionedDrawing.aLeft + positionedDrawing.width;
14345
- const drawingRight = drawing.aLeft + width;
14346
- if (positionedDrawing.aLeft < drawingRight && positionedRight > drawing.aLeft) {
14347
- var _positionedOrigin$dis;
14348
- drawing.aLeft = Math.max(drawing.aLeft, positionedDrawing.aLeft + positionedDrawing.width + ((_positionedOrigin$dis = positionedOrigin.distR) !== null && _positionedOrigin$dis !== void 0 ? _positionedOrigin$dis : 0));
14349
- }
14350
- }
14351
- }
14352
- drawing.aTop = lineTop + lineHeight - .5 * glyphHeight - .5 * height - marginBottom;
14045
+ drawing.aLeft = divide.left + divide.paddingLeft + glyph.left + .5 * glyph.width - .5 * width || 0;
14046
+ drawing.aTop = top + lineHeight - .5 * glyphHeight - .5 * height - marginBottom;
14353
14047
  drawing.width = width;
14354
14048
  drawing.height = height;
14355
14049
  drawing.angle = angle;
14356
14050
  drawing.isPageBreak = isPageBreak;
14357
- drawing.lineTop = lineTop;
14051
+ drawing.lineTop = top;
14358
14052
  drawing.columnLeft = column.left;
14359
- drawing.blockAnchorTop = blockAnchorTop == null ? lineTop : sectionTop + blockAnchorTop;
14053
+ drawing.blockAnchorTop = blockAnchorTop !== null && blockAnchorTop !== void 0 ? blockAnchorTop : top;
14360
14054
  drawing.lineHeight = line.lineHeight;
14361
14055
  drawings.set(drawing.drawingId, drawing);
14362
14056
  }
14363
14057
  page.skeDrawings = new Map([...page.skeDrawings, ...drawings]);
14364
14058
  }
14365
- function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = [], blockAnchorLeft = 0) {
14059
+ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = []) {
14366
14060
  var _column$parent3;
14367
14061
  const page = (_column$parent3 = column.parent) === null || _column$parent3 === void 0 ? void 0 : _column$parent3.parent;
14368
14062
  if (page == null || needPositionDrawings.length === 0) return;
@@ -14376,12 +14070,7 @@ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShape
14376
14070
  const { docTransform } = drawingOrigin;
14377
14071
  const { positionH, positionV, size, angle } = docTransform;
14378
14072
  const { width = 0, height = 0 } = size;
14379
- let aLeft = (_getPositionHorizon2 = getPositionHorizon(positionH, column, page, width, isPageBreak)) !== null && _getPositionHorizon2 !== void 0 ? _getPositionHorizon2 : 0;
14380
- if (positionH.relativeFrom === _univerjs_core.ObjectRelativeFromH.COLUMN && blockAnchorLeft > 0) {
14381
- const renderedColumnOrigin = isPageBreak ? 0 : column.left || page.marginLeft;
14382
- aLeft += blockAnchorLeft - renderedColumnOrigin;
14383
- }
14384
- drawing.aLeft = aLeft;
14073
+ drawing.aLeft = (_getPositionHorizon2 = getPositionHorizon(positionH, column, page, width, isPageBreak)) !== null && _getPositionHorizon2 !== void 0 ? _getPositionHorizon2 : 0;
14385
14074
  drawing.aTop = (_getPositionVertical2 = getPositionVertical(positionV, page, lineTop, lineHeight, height, blockAnchorTop, isPageBreak)) !== null && _getPositionVertical2 !== void 0 ? _getPositionVertical2 : 0;
14386
14075
  drawing.width = width;
14387
14076
  drawing.height = height;
@@ -14450,7 +14139,7 @@ function __getGlyphGroupByLine({ divides }) {
14450
14139
  return divides.flatMap((divide) => divide.glyphGroup);
14451
14140
  }
14452
14141
  function __isNullLine(line) {
14453
- return __getGlyphGroupByLine(line).every((glyph) => !glyph.content && !glyph.drawingId);
14142
+ return !line.divides[0].glyphGroup[0];
14454
14143
  }
14455
14144
 
14456
14145
  //#endregion
@@ -14533,7 +14222,6 @@ function isColumnFull(page) {
14533
14222
  function getNumberUnitValue(unitValue, benchMark) {
14534
14223
  if (!unitValue) return 0;
14535
14224
  const { v: value, u: unit } = unitValue;
14536
- if (typeof value !== "number" || !Number.isFinite(value)) return 0;
14537
14225
  if (!unit) return value;
14538
14226
  if (unit === _univerjs_core.NumberUnitType.PIXEL) return value;
14539
14227
  return value * benchMark;
@@ -14548,22 +14236,18 @@ function validationGrid(gridType = _univerjs_core.GridType.LINES, snapToGrid = _
14548
14236
  return snapToGrid === _univerjs_core.BooleanNumber.TRUE && (gridType === _univerjs_core.GridType.LINES_AND_CHARS || gridType === _univerjs_core.GridType.SNAP_TO_CHARS);
14549
14237
  }
14550
14238
  function getLineHeightConfig(sectionBreakConfig, paragraphConfig) {
14551
- const { paragraphStyle = {}, useWordStyleLineHeight = false } = paragraphConfig;
14239
+ const { paragraphStyle = {} } = paragraphConfig;
14552
14240
  const { linePitch = 15.6, gridType = _univerjs_core.GridType.LINES, paragraphLineGapDefault = 0 } = sectionBreakConfig;
14553
- const hasDocumentGrid = gridType === _univerjs_core.GridType.LINES_AND_CHARS || gridType === _univerjs_core.GridType.SNAP_TO_CHARS;
14554
- const defaultSnapToGrid = useWordStyleLineHeight && !hasDocumentGrid ? _univerjs_core.BooleanNumber.FALSE : _univerjs_core.BooleanNumber.TRUE;
14555
- const { lineSpacing = 0, spacingRule = _univerjs_core.SpacingRule.AUTO, snapToGrid = defaultSnapToGrid } = paragraphStyle;
14241
+ const { lineSpacing = 0, spacingRule = _univerjs_core.SpacingRule.AUTO, snapToGrid = _univerjs_core.BooleanNumber.TRUE } = paragraphStyle;
14556
14242
  let lineSpacingApply = lineSpacing;
14557
- if (useWordStyleLineHeight && lineSpacing === 0 && spacingRule === _univerjs_core.SpacingRule.AUTO) lineSpacingApply = 1;
14558
- else if (!useWordStyleLineHeight && (gridType === _univerjs_core.GridType.LINES || gridType === _univerjs_core.GridType.LINES_AND_CHARS) && lineSpacing === 0 && spacingRule === _univerjs_core.SpacingRule.AUTO) lineSpacingApply = 1;
14243
+ if ((gridType === _univerjs_core.GridType.LINES || gridType === _univerjs_core.GridType.LINES_AND_CHARS) && lineSpacing === 0 && spacingRule === _univerjs_core.SpacingRule.AUTO) lineSpacingApply = 1;
14559
14244
  return {
14560
14245
  paragraphLineGapDefault,
14561
14246
  linePitch,
14562
14247
  gridType,
14563
14248
  lineSpacing: lineSpacingApply,
14564
14249
  spacingRule,
14565
- snapToGrid,
14566
- useWordStyleLineHeight
14250
+ snapToGrid
14567
14251
  };
14568
14252
  }
14569
14253
  function getCharSpaceConfig(sectionBreakConfig, paragraphConfig) {
@@ -14670,16 +14354,13 @@ function updateBlockIndex(pages, start = -1) {
14670
14354
  }
14671
14355
  function updateInlineDrawingCoordsAndBorder(ctx, pages) {
14672
14356
  lineIterator(pages, (line, _, __, page) => {
14673
- var _ctx$paragraphConfigC, _ctx$skeletonResource, _paragraphStyle$shadi;
14357
+ var _ctx$paragraphConfigC, _ctx$skeletonResource;
14674
14358
  const { segmentId } = page;
14675
14359
  const paragraphConfig = (_ctx$paragraphConfigC = ctx.paragraphConfigCache.get(segmentId)) === null || _ctx$paragraphConfigC === void 0 ? void 0 : _ctx$paragraphConfigC.get(line.paragraphIndex);
14676
14360
  const affectInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphInlineSkeDrawings;
14677
- const affectNonInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphNonInlineSkeDrawings;
14678
14361
  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);
14679
- if (affectInlineDrawings && affectInlineDrawings.size > 0) updateInlineDrawingPosition(line, affectInlineDrawings, drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top, affectNonInlineDrawings);
14362
+ if (affectInlineDrawings && affectInlineDrawings.size > 0) updateInlineDrawingPosition(line, affectInlineDrawings, drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top);
14680
14363
  const paragraphStyle = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphStyle;
14681
- const paragraphBackgroundColor = paragraphStyle === null || paragraphStyle === void 0 || (_paragraphStyle$shadi = paragraphStyle.shading) === null || _paragraphStyle$shadi === void 0 ? void 0 : _paragraphStyle$shadi.backgroundColor;
14682
- if (paragraphBackgroundColor) line.backgroundColor = paragraphBackgroundColor;
14683
14364
  if (line.divides.length > 0) {
14684
14365
  const lastDivide = line.divides[line.divides.length - 1];
14685
14366
  const lastGlyph = lastDivide.glyphGroup[lastDivide.glyphGroup.length - 1];
@@ -14749,12 +14430,14 @@ function getPositionHorizon(positionH, column, page, objectWidth, isPageBreak =
14749
14430
  return absoluteLeft;
14750
14431
  }
14751
14432
  }
14752
- else if (posOffset != null) {
14433
+ else if (posOffset) {
14434
+ const { pageWidth, marginLeft, marginRight } = page;
14435
+ const boundaryRight = pageWidth - marginRight;
14753
14436
  let absoluteLeft = 0;
14754
- const { marginLeft } = page;
14755
14437
  if (relativeFrom === _univerjs_core.ObjectRelativeFromH.COLUMN) absoluteLeft = (isPageBreak ? 0 : (column === null || column === void 0 ? void 0 : column.left) || 0) + posOffset;
14756
14438
  else if (relativeFrom === _univerjs_core.ObjectRelativeFromH.LEFT_MARGIN) {} else if (relativeFrom === _univerjs_core.ObjectRelativeFromH.MARGIN) absoluteLeft = posOffset + marginLeft;
14757
14439
  else if (relativeFrom === _univerjs_core.ObjectRelativeFromH.RIGHT_MARGIN) {} else if (relativeFrom === _univerjs_core.ObjectRelativeFromH.INSIDE_MARGIN) {} else if (relativeFrom === _univerjs_core.ObjectRelativeFromH.OUTSIDE_MARGIN) {} else if (relativeFrom === _univerjs_core.ObjectRelativeFromH.PAGE) absoluteLeft = posOffset;
14440
+ if (absoluteLeft + objectWidth > boundaryRight) absoluteLeft = boundaryRight - objectWidth;
14758
14441
  return absoluteLeft;
14759
14442
  } else if (percent) {
14760
14443
  const { pageWidth, marginLeft, marginRight } = page;
@@ -14816,9 +14499,9 @@ function getFontConfigFromLastGlyph(glyph, sectionBreakConfig, paragraphStyle) {
14816
14499
  };
14817
14500
  }
14818
14501
  function getBulletParagraphTextStyle(bullet, viewModel) {
14819
- var _lists$listType;
14502
+ var _lists$listType$nesti;
14820
14503
  const { listType } = bullet;
14821
- 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;
14504
+ return (_lists$listType$nesti = viewModel.getDataModel().getBulletPresetList()[listType].nestingLevel[0].paragraphProperties) === null || _lists$listType$nesti === void 0 ? void 0 : _lists$listType$nesti.textStyle;
14822
14505
  }
14823
14506
  const DEFAULT_TEXT_RUN = {
14824
14507
  ts: {},
@@ -14826,7 +14509,6 @@ const DEFAULT_TEXT_RUN = {
14826
14509
  ed: 0
14827
14510
  };
14828
14511
  function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
14829
- var _sectionBreakConfig$d;
14830
14512
  const { gridType = _univerjs_core.GridType.LINES, charSpace = 0, documentTextStyle = {}, pageSize = {
14831
14513
  width: Number.POSITIVE_INFINITY,
14832
14514
  height: Number.POSITIVE_INFINITY
@@ -14858,20 +14540,16 @@ function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig
14858
14540
  ...customRangeStyle,
14859
14541
  ...bulletTextStyle
14860
14542
  };
14861
- const fontStyle = getFontStyleString(textStyle);
14862
- const mixTextStyle = {
14863
- ...documentTextStyle,
14864
- ...textStyle
14865
- };
14866
- const pageWidth = pageSize.width || Number.POSITIVE_INFINITY - marginLeft - marginRight;
14867
14543
  const result = {
14868
- fontStyle,
14869
- textStyle: mixTextStyle,
14544
+ fontStyle: getFontStyleString(textStyle),
14545
+ textStyle: {
14546
+ ...documentTextStyle,
14547
+ ...textStyle
14548
+ },
14870
14549
  charSpace,
14871
14550
  gridType,
14872
14551
  snapToGrid,
14873
- documentCompatibilityPolicy: (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy(),
14874
- pageWidth
14552
+ pageWidth: pageSize.width || Number.POSITIVE_INFINITY - marginLeft - marginRight
14875
14553
  };
14876
14554
  if (!hasAddonStyle && originTextRun) fontCreateConfigCache.setValue(st, ed, result);
14877
14555
  return result;
@@ -15006,6 +14684,17 @@ function resetContext(ctx) {
15006
14684
  ctx.isDirty = false;
15007
14685
  (_ctx$skeleton$drawing = ctx.skeleton.drawingAnchor) === null || _ctx$skeleton$drawing === void 0 || _ctx$skeleton$drawing.clear();
15008
14686
  }
14687
+ function mergeByV(object, originObject, type) {
14688
+ const mergeIterator = (obj, originObj, key) => {
14689
+ if (key !== "v") if (typeof originObj === "object") return (0, _univerjs_core.mergeWith)(obj, originObj, mergeIterator);
14690
+ else return originObj !== null && originObj !== void 0 ? originObj : obj;
14691
+ if (typeof originObj === "number") {
14692
+ if (typeof obj === "number") return type === "max" ? Math.max(originObj, obj) : Math.min(originObj, obj);
14693
+ }
14694
+ return originObj !== null && originObj !== void 0 ? originObj : obj;
14695
+ };
14696
+ return (0, _univerjs_core.mergeWith)(object, originObject, mergeIterator);
14697
+ }
15009
14698
  function getPageFromPath(skeletonData, path) {
15010
14699
  const pathCopy = [...path];
15011
14700
  let page = null;
@@ -15071,7 +14760,7 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
15071
14760
  header = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(pageWidth);
15072
14761
  } else if (headerTreeMap && headerTreeMap.has(headerId)) {
15073
14762
  header = _createSkeletonHeaderFooter(ctx, headerTreeMap.get(headerId), sectionBreakConfig, skeletonResourceReference, headerId, true);
15074
- skeHeaders.set(headerId, /* @__PURE__ */ new Map([[pageWidth, header]]));
14763
+ skeHeaders.set(headerId, new Map([[pageWidth, header]]));
15075
14764
  }
15076
14765
  page.headerId = headerId;
15077
14766
  }
@@ -15082,7 +14771,7 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
15082
14771
  footer = (_skeFooters$get2 = skeFooters.get(footerId)) === null || _skeFooters$get2 === void 0 ? void 0 : _skeFooters$get2.get(pageWidth);
15083
14772
  } else if (footerTreeMap && footerTreeMap.has(footerId)) {
15084
14773
  footer = _createSkeletonHeaderFooter(ctx, footerTreeMap.get(footerId), sectionBreakConfig, skeletonResourceReference, footerId, false);
15085
- skeFooters.set(footerId, /* @__PURE__ */ new Map([[pageWidth, footer]]));
14774
+ skeFooters.set(footerId, new Map([[pageWidth, footer]]));
15086
14775
  }
15087
14776
  page.footerId = footerId;
15088
14777
  }
@@ -15177,22 +14866,9 @@ function createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, avai
15177
14866
  const { skeletonResourceReference } = ctx;
15178
14867
  const { cellMargin, tableRows, tableColumns, tableId } = tableConfig;
15179
14868
  const cellConfig = tableRows[row].tableCells[col];
15180
- 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 : {};
14869
+ 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 : {};
15181
14870
  const columnSpan = Math.max(1, (_cellConfig$columnSpa = cellConfig.columnSpan) !== null && _cellConfig$columnSpa !== void 0 ? _cellConfig$columnSpa : 1);
15182
14871
  const pageWidth = tableColumns.slice(col, col + columnSpan).reduce((sum, column) => sum + column.size.width.v, 0);
15183
- if (start.v + end.v >= pageWidth) {
15184
- const marginWidth = start.v + end.v;
15185
- const availableMarginWidth = Math.max(0, pageWidth - 1);
15186
- const startRatio = marginWidth > 0 ? start.v / marginWidth : .5;
15187
- start = {
15188
- ...start,
15189
- v: availableMarginWidth * startRatio
15190
- };
15191
- end = {
15192
- ...end,
15193
- v: availableMarginWidth - start.v
15194
- };
15195
- }
15196
14872
  const pageHeight = maxCellPageHeight;
15197
14873
  const cellSectionBreakConfig = {
15198
14874
  lists,
@@ -15260,8 +14936,11 @@ function applyTrailingCellBlockRangeSpaceBelow(pages, body, cellEndIndex) {
15260
14936
  page.height += lastLine.spaceBelowApply || trailingBlockRangeSpace;
15261
14937
  }
15262
14938
  }
15263
- function _getVerticalMargin(marginTB, _headerOrFooter, _pageHeight) {
15264
- return marginTB;
14939
+ function _getVerticalMargin(marginTB, headerOrFooter, pageHeight) {
14940
+ if (!headerOrFooter || headerOrFooter.sections[0].columns[0].lines.length === 0) return marginTB;
14941
+ const HeaderFooterPageHeight = headerOrFooter.height + headerOrFooter.marginTop + headerOrFooter.marginBottom;
14942
+ const maxMargin = getHeaderFooterMaxHeight(pageHeight);
14943
+ return Math.min(maxMargin, Math.max(marginTB, HeaderFooterPageHeight));
15265
14944
  }
15266
14945
 
15267
14946
  //#endregion
@@ -15374,26 +15053,7 @@ function adjustGlyphsInDivide(divide, justificationRatio, extraJustification) {
15374
15053
  * Therefore, multiple calculations are performed, which may impact performance.
15375
15054
  * Needs optimization for efficiency.
15376
15055
  */
15377
- function shouldAllowOverflowHorizontalOffset(sectionBreakConfig) {
15378
- var _sectionBreakConfig$r;
15379
- return ((_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.wrapStrategy) === _univerjs_core.WrapStrategy.OVERFLOW;
15380
- }
15381
- function getGlyphGroupInkBounds(divide) {
15382
- if (divide.glyphGroup.length === 0) return null;
15383
- let left = Infinity;
15384
- let right = -Infinity;
15385
- for (const glyph of divide.glyphGroup) {
15386
- const glyphLeft = glyph.left + glyph.xOffset;
15387
- left = Math.min(left, glyphLeft);
15388
- right = Math.max(right, glyphLeft + glyph.bBox.width);
15389
- }
15390
- if (!Number.isFinite(left) || !Number.isFinite(right)) return null;
15391
- return {
15392
- left,
15393
- right
15394
- };
15395
- }
15396
- function horizontalAlignHandler(line, horizontalAlign, allowOverflowHorizontalOffset = false) {
15056
+ function horizontalAlignHandler(line, horizontalAlign) {
15397
15057
  const { divides } = line;
15398
15058
  for (let i = 0; i < divides.length; i++) {
15399
15059
  const divide = divides[i];
@@ -15432,12 +15092,9 @@ function horizontalAlignHandler(line, horizontalAlign, allowOverflowHorizontalOf
15432
15092
  divide.glyphGroupWidth = glyphGroupWidth;
15433
15093
  }
15434
15094
  }
15435
- const inkBounds = allowOverflowHorizontalOffset ? getGlyphGroupInkBounds(divide) : null;
15436
- if (horizontalAlign === _univerjs_core.HorizontalAlign.CENTER && inkBounds) divide.paddingLeft = width / 2 - (inkBounds.left + inkBounds.right) / 2;
15437
- else if (horizontalAlign === _univerjs_core.HorizontalAlign.RIGHT && inkBounds) divide.paddingLeft = width - inkBounds.right;
15438
- else if (horizontalAlign === _univerjs_core.HorizontalAlign.CENTER) divide.paddingLeft = (width - glyphGroupWidth) / 2;
15095
+ if (horizontalAlign === _univerjs_core.HorizontalAlign.CENTER) divide.paddingLeft = (width - glyphGroupWidth) / 2;
15439
15096
  else if (horizontalAlign === _univerjs_core.HorizontalAlign.RIGHT) divide.paddingLeft = width - glyphGroupWidth;
15440
- if (!allowOverflowHorizontalOffset) divide.paddingLeft = Math.max(divide.paddingLeft, 0);
15097
+ divide.paddingLeft = Math.max(divide.paddingLeft, 0);
15441
15098
  }
15442
15099
  }
15443
15100
  function restoreLastCJKGlyphWidth(line) {
@@ -15482,10 +15139,7 @@ function addHyphenDash(line, viewModel, paragraphNode, sectionBreakConfig, parag
15482
15139
  }
15483
15140
  function lineAdjustment(pages, viewModel, paragraphNode, sectionBreakConfig) {
15484
15141
  const { endIndex } = paragraphNode;
15485
- const paragraph = viewModel.getParagraph(endIndex) || {
15486
- startIndex: 0,
15487
- paragraphId: "para_render_fallback"
15488
- };
15142
+ const paragraph = viewModel.getParagraph(endIndex) || { startIndex: 0 };
15489
15143
  lineIterator(pages, (line) => {
15490
15144
  if (line.paragraphIndex !== paragraph.startIndex) return;
15491
15145
  const { paragraphStyle = {} } = paragraph;
@@ -15493,7 +15147,7 @@ function lineAdjustment(pages, viewModel, paragraphNode, sectionBreakConfig) {
15493
15147
  shrinkStartAndEndCJKPunctuation(line);
15494
15148
  restoreLastCJKGlyphWidth(line);
15495
15149
  addHyphenDash(line, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
15496
- horizontalAlignHandler(line, horizontalAlign, shouldAllowOverflowHorizontalOffset(sectionBreakConfig));
15150
+ horizontalAlignHandler(line, horizontalAlign);
15497
15151
  });
15498
15152
  }
15499
15153
 
@@ -15688,43 +15342,11 @@ function ___getLevelAndSuffix(levelAndSuffixPre) {
15688
15342
 
15689
15343
  //#endregion
15690
15344
  //#region src/components/docs/layout/block/paragraph/linebreaking.ts
15691
- const BLOCK_LAYOUT_OUTER_SPACING_MAP = /* @__PURE__ */ new Map([
15692
- [_univerjs_core.DocumentBlockRangeType.CALLOUT, 34],
15693
- [_univerjs_core.DocumentBlockRangeType.CODE, 32],
15694
- [_univerjs_core.DocumentBlockRangeType.QUOTE, 24]
15345
+ const BLOCK_LAYOUT_OUTER_SPACING_MAP = new Map([
15346
+ ["callout", 34],
15347
+ ["code", 32],
15348
+ ["quote", 24]
15695
15349
  ]);
15696
- function _endsWithToken(text, glyphs, token) {
15697
- var _glyphs, _glyphs2;
15698
- 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;
15699
- }
15700
- function _isMarkedDocxColumnBreak(viewModel, absoluteIndex) {
15701
- const customRange = viewModel.getCustomRange(absoluteIndex);
15702
- const properties = customRange === null || customRange === void 0 ? void 0 : customRange.properties;
15703
- return (properties === null || properties === void 0 ? void 0 : properties.docxBreakType) === "column";
15704
- }
15705
- function _glyphCount(glyphs) {
15706
- return glyphs.reduce((count, glyph) => count + glyph.count, 0);
15707
- }
15708
- function _hasOnlyCustomBlockGlyphs(glyphs) {
15709
- return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK);
15710
- }
15711
- function _mergeAdjacentCustomBlockShapedTexts(shapedTextList) {
15712
- const mergedShapedTextList = [];
15713
- for (const shapedText of shapedTextList) {
15714
- const lastShapedText = mergedShapedTextList[mergedShapedTextList.length - 1];
15715
- if (lastShapedText && _hasOnlyCustomBlockGlyphs(lastShapedText.glyphs) && _hasOnlyCustomBlockGlyphs(shapedText.glyphs)) {
15716
- lastShapedText.text += shapedText.text;
15717
- lastShapedText.glyphs.push(...shapedText.glyphs);
15718
- lastShapedText.breakPointType = shapedText.breakPointType;
15719
- continue;
15720
- }
15721
- mergedShapedTextList.push({
15722
- ...shapedText,
15723
- glyphs: [...shapedText.glyphs]
15724
- });
15725
- }
15726
- return mergedShapedTextList;
15727
- }
15728
15350
  function _getListLevelAncestors(bullet, listLevel) {
15729
15351
  if (!bullet || !listLevel) return;
15730
15352
  const { listId, nestingLevel } = bullet;
@@ -15795,23 +15417,12 @@ function _applyBlockRangeLayoutParagraphStyle(body, paragraph, paragraphStyle, s
15795
15417
  if ((lastParagraph === null || lastParagraph === void 0 ? void 0 : lastParagraph.startIndex) === paragraph.startIndex && !_hasNextAdjacentLayoutBlockRange(blockRanges, blockRange)) _withMinSpacing(style, "spaceBelow", outerSpacing);
15796
15418
  return style;
15797
15419
  }
15798
- function _isOnlyFloatingCustomBlockParagraph(viewModel, paragraphNode, drawings) {
15799
- var _paragraphNode$blocks, _paragraphNode$conten;
15800
- if (!((_paragraphNode$blocks = paragraphNode.blocks) === null || _paragraphNode$blocks === void 0 ? void 0 : _paragraphNode$blocks.length)) return false;
15801
- if (!((_paragraphNode$conten = paragraphNode.content) !== null && _paragraphNode$conten !== void 0 ? _paragraphNode$conten : "").split("").every((char) => char === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK || char === _univerjs_core.DataStreamTreeTokenType.PARAGRAPH || char === _univerjs_core.DataStreamTreeTokenType.SECTION_BREAK)) return false;
15802
- return paragraphNode.blocks.every((charIndex) => {
15803
- const customBlock = viewModel.getCustomBlock(charIndex);
15804
- const drawing = customBlock == null ? null : drawings[customBlock.blockId];
15805
- return drawing != null && drawing.layoutType !== _univerjs_core.PositionedObjectLayoutType.INLINE;
15806
- });
15807
- }
15808
- function _getFollowingIndentedParagraphAnchorLeft(viewModel, paragraph, paragraphNode, drawings, isTraditionalDocument) {
15809
- var _paragraph$paragraphS, _paragraph$paragraphS2, _viewModel$getBody$pa, _viewModel$getBody, _paragraphs$0$paragra, _paragraphs$, _paragraphs$0$paragra2;
15810
- if (!isTraditionalDocument) return;
15811
- 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;
15812
- if (!_isOnlyFloatingCustomBlockParagraph(viewModel, paragraphNode, drawings)) return;
15813
- 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);
15814
- 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;
15420
+ function _shouldApplyDocumentDefaultParagraphStyle(viewModel) {
15421
+ var _viewModel$getSnapsho;
15422
+ const snapshot = (_viewModel$getSnapsho = viewModel.getSnapshot) === null || _viewModel$getSnapsho === void 0 ? void 0 : _viewModel$getSnapsho.call(viewModel);
15423
+ const documentFlavor = snapshot === null || snapshot === void 0 ? void 0 : snapshot.documentStyle.documentFlavor;
15424
+ if (snapshot == null) return true;
15425
+ return documentFlavor != null && documentFlavor !== _univerjs_core.DocumentFlavor.UNSPECIFIED;
15815
15426
  }
15816
15427
  function _getDrawingSkeletonFormat(drawingOrigin) {
15817
15428
  const { drawingId } = drawingOrigin;
@@ -15835,24 +15446,16 @@ function _getNextPageNumber(lastPage) {
15835
15446
  return lastPage.pageNumber + 1;
15836
15447
  }
15837
15448
  function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, sectionBreakConfig, tableSkeleton) {
15838
- var _sectionBreakConfig$d, _viewModel$getSnapsho, _viewModel$getBody2, _viewModel$getBody3;
15449
+ var _viewModel$getBody, _viewModel$getBody2;
15839
15450
  const { skeletonResourceReference } = ctx;
15840
15451
  const { lists, drawings = {}, localeService } = sectionBreakConfig;
15841
15452
  const { endIndex, blocks = [], children } = paragraphNode;
15842
15453
  const { segmentId } = curPage;
15843
- const paragraph = viewModel.getParagraph(endIndex) || {
15844
- startIndex: 0,
15845
- paragraphId: "para_render_fallback"
15846
- };
15454
+ const paragraph = viewModel.getParagraph(endIndex) || { startIndex: 0 };
15847
15455
  const { paragraphStyle = {}, bullet } = paragraph;
15848
- 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);
15849
- const shouldApplyDocumentDefaults = documentCompatibilityPolicy.applyDocumentDefaultParagraphStyle;
15850
- const useWordStyleLineHeight = documentCompatibilityPolicy.useWordStyleLineHeight;
15851
15456
  const { skeHeaders, skeFooters, skeListLevel, drawingAnchor } = skeletonResourceReference;
15852
15457
  const paragraphNonInlineSkeDrawings = /* @__PURE__ */ new Map();
15853
15458
  const paragraphInlineSkeDrawings = /* @__PURE__ */ new Map();
15854
- const paragraphNonInlineSkeDrawingsByBlockId = /* @__PURE__ */ new Map();
15855
- const paragraphInlineSkeDrawingsByBlockId = /* @__PURE__ */ new Map();
15856
15459
  let segmentDrawingAnchorCache = drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.get(segmentId);
15857
15460
  if (segmentDrawingAnchorCache == null) {
15858
15461
  segmentDrawingAnchorCache = /* @__PURE__ */ new Map();
@@ -15860,10 +15463,7 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
15860
15463
  }
15861
15464
  const paragraphConfig = {
15862
15465
  paragraphIndex: endIndex,
15863
- documentCompatibilityPolicy,
15864
- 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),
15865
- docxFallbackAnchorLeft: _getFollowingIndentedParagraphAnchorLeft(viewModel, paragraph, paragraphNode, drawings, isTraditionalDocumentCompatibility(documentCompatibilityPolicy)),
15866
- useWordStyleLineHeight,
15466
+ 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)),
15867
15467
  paragraphNonInlineSkeDrawings,
15868
15468
  paragraphInlineSkeDrawings,
15869
15469
  skeTablesInParagraph: tableSkeleton ? [{
@@ -15896,60 +15496,36 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
15896
15496
  if (customBlock == null) continue;
15897
15497
  const { blockId } = customBlock;
15898
15498
  const drawingOrigin = drawings[blockId];
15899
- if (drawingOrigin == null) continue;
15900
- if (drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.INLINE) paragraphInlineSkeDrawingsByBlockId.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
15901
- else paragraphNonInlineSkeDrawingsByBlockId.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
15499
+ if (drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.INLINE) paragraphInlineSkeDrawings.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
15500
+ else paragraphNonInlineSkeDrawings.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
15902
15501
  }
15903
15502
  segmentParagraphCache.set(endIndex, paragraphConfig);
15904
15503
  let allPages = [curPage];
15905
15504
  let isParagraphFirstShapedText = true;
15906
- let shapedTextOffset = 0;
15907
- for (const [_index, { text, glyphs, breakPointType }] of _mergeAdjacentCustomBlockShapedTexts(shapedTextList).entries()) {
15908
- const textStartIndex = paragraphNode.startIndex + shapedTextOffset;
15909
- const textGlyphCount = _glyphCount(glyphs);
15910
- const textEndIndex = textStartIndex + textGlyphCount;
15505
+ for (const [_index, { text, glyphs, breakPointType }] of shapedTextList.entries()) {
15911
15506
  const pushPending = () => {
15912
15507
  if (glyphs.length === 0) return;
15913
- syncActiveParagraphDrawings(glyphs, paragraphNonInlineSkeDrawings, paragraphInlineSkeDrawings, paragraphNonInlineSkeDrawingsByBlockId, paragraphInlineSkeDrawingsByBlockId);
15914
- allPages = layoutParagraph(ctx, glyphs, allPages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText || hasOnlyFloatingCustomBlockGlyphs(glyphs, paragraphNonInlineSkeDrawingsByBlockId), breakPointType);
15508
+ allPages = layoutParagraph(ctx, glyphs, allPages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
15915
15509
  isParagraphFirstShapedText = false;
15916
15510
  };
15917
- if (_endsWithToken(text, glyphs, _univerjs_core.DataStreamTreeTokenType.PAGE_BREAK)) {
15511
+ if (text.endsWith(_univerjs_core.DataStreamTreeTokenType.PAGE_BREAK)) {
15918
15512
  pushPending();
15919
15513
  allPages.push(createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, _getNextPageNumber(allPages[allPages.length - 1]), 1));
15920
15514
  paragraphNonInlineSkeDrawings.clear();
15921
- isParagraphFirstShapedText = true;
15922
- shapedTextOffset += textGlyphCount;
15515
+ paragraphInlineSkeDrawings.clear();
15923
15516
  continue;
15924
- } else if (_endsWithToken(text, glyphs, _univerjs_core.DataStreamTreeTokenType.COLUMN_BREAK) && (!isTraditionalDocumentCompatibility(documentCompatibilityPolicy) || _isMarkedDocxColumnBreak(viewModel, textEndIndex - 1))) {
15517
+ } else if (text.endsWith(_univerjs_core.DataStreamTreeTokenType.COLUMN_BREAK)) {
15925
15518
  pushPending();
15926
15519
  const lastPage = allPages[allPages.length - 1];
15927
15520
  const columnInfo = getLastNotFullColumnInfo(lastPage);
15928
15521
  if (columnInfo && !columnInfo.isLast) setColumnFullState(columnInfo.column, true);
15929
15522
  else allPages.push(createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, _getNextPageNumber(lastPage), 2));
15930
- shapedTextOffset += textGlyphCount;
15931
15523
  continue;
15932
15524
  }
15933
15525
  pushPending();
15934
- shapedTextOffset += textGlyphCount;
15935
15526
  }
15936
15527
  return allPages;
15937
15528
  }
15938
- function syncActiveParagraphDrawings(glyphs, paragraphNonInlineSkeDrawings, paragraphInlineSkeDrawings, paragraphNonInlineSkeDrawingsByBlockId, paragraphInlineSkeDrawingsByBlockId) {
15939
- for (const glyph of glyphs) {
15940
- if (glyph.streamType !== _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK || glyph.drawingId == null) continue;
15941
- const inlineDrawing = paragraphInlineSkeDrawingsByBlockId.get(glyph.drawingId);
15942
- if (inlineDrawing != null) {
15943
- paragraphInlineSkeDrawings.set(glyph.drawingId, inlineDrawing);
15944
- continue;
15945
- }
15946
- const nonInlineDrawing = paragraphNonInlineSkeDrawingsByBlockId.get(glyph.drawingId);
15947
- if (nonInlineDrawing != null) paragraphNonInlineSkeDrawings.set(glyph.drawingId, nonInlineDrawing);
15948
- }
15949
- }
15950
- function hasOnlyFloatingCustomBlockGlyphs(glyphs, paragraphNonInlineSkeDrawingsByBlockId) {
15951
- return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.drawingId != null && paragraphNonInlineSkeDrawingsByBlockId.has(glyph.drawingId));
15952
- }
15953
15529
 
15954
15530
  //#endregion
15955
15531
  //#region src/components/docs/layout/line-breaker/enhancers/hyphen-enhancer.ts
@@ -16273,26 +15849,6 @@ function prepareTextChunks(body) {
16273
15849
  //#region src/components/docs/layout/shaping-engine/text-shaping.ts
16274
15850
  const fontCache = /* @__PURE__ */ new Map();
16275
15851
  const glyphCache = /* @__PURE__ */ new Map();
16276
- const fontFamilyCache = /* @__PURE__ */ new Map();
16277
- function trimOuterQuotes(value) {
16278
- const firstChar = value.charCodeAt(0);
16279
- const lastChar = value.charCodeAt(value.length - 1);
16280
- const hasLeadingQuote = firstChar === 34 || firstChar === 39;
16281
- const hasTrailingQuote = lastChar === 34 || lastChar === 39;
16282
- if (hasLeadingQuote && hasTrailingQuote) return value.slice(1, -1);
16283
- if (hasLeadingQuote) return value.slice(1);
16284
- if (hasTrailingQuote) return value.slice(0, -1);
16285
- return value;
16286
- }
16287
- function expandFontFamilies(fontFamily) {
16288
- if (!(fontFamily === null || fontFamily === void 0 ? void 0 : fontFamily.trim())) return [];
16289
- let families = fontFamilyCache.get(fontFamily);
16290
- if (families) return families;
16291
- families = fontFamily.split(",").map((family) => trimOuterQuotes(family.trim())).filter(Boolean);
16292
- fontFamilyCache.set(fontFamily, families);
16293
- return families;
16294
- }
16295
- const defaultFontFamilies = expandFontFamilies(DEFAULT_FONTFACE_PLANE);
16296
15852
  function shapeChunk(content, charPosition, used, families, style) {
16297
15853
  var _style$bl, _style$it, _content$match;
16298
15854
  let fi = 0;
@@ -16395,7 +15951,8 @@ function textShape(body) {
16395
15951
  for (const chunk of chunks) {
16396
15952
  var _style$ff;
16397
15953
  const { content, style = {} } = chunk;
16398
- let fontFamilies = [...expandFontFamilies((_style$ff = style.ff) !== null && _style$ff !== void 0 ? _style$ff : "Arial"), ...defaultFontFamilies];
15954
+ let fontFamilies = DEFAULT_FONTFACE_PLANE.split(",").map((family) => family.trim().replace(/["']/g, ""));
15955
+ fontFamilies.unshift((_style$ff = style.ff) !== null && _style$ff !== void 0 ? _style$ff : "Arial");
16399
15956
  fontFamilies = fontLibrary.getValidFontFamilies(fontFamilies);
16400
15957
  glyphs.push(...shapeChunk(content, charPosition, /* @__PURE__ */ new Set(), fontFamilies, style));
16401
15958
  charPosition += content.length;
@@ -16433,7 +15990,7 @@ function ArabicHandler(index, charArray, viewModel, paragraphNode, sectionBreakC
16433
15990
  for (let i = 0; i < charArray.length; i++) {
16434
15991
  const newChar = charArray[i];
16435
15992
  if (hasArabic(newChar)) {
16436
- glyph.push(newChar);
15993
+ glyph.unshift(newChar);
16437
15994
  step++;
16438
15995
  } else break;
16439
15996
  }
@@ -16530,10 +16087,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
16530
16087
  const shapedTextList = [];
16531
16088
  let breaker = new LineBreaker(content);
16532
16089
  const { endIndex } = paragraphNode;
16533
- const paragraph = viewModel.getParagraph(endIndex) || {
16534
- startIndex: 0,
16535
- paragraphId: "para_render_fallback"
16536
- };
16090
+ const paragraph = viewModel.getParagraph(endIndex) || { startIndex: 0 };
16537
16091
  const { paragraphStyle = {} } = paragraph;
16538
16092
  const { snapToGrid = _univerjs_core.BooleanNumber.TRUE } = paragraphStyle;
16539
16093
  let last = 0;
@@ -16592,12 +16146,12 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
16592
16146
  if (customBlock != null) {
16593
16147
  const { blockId } = customBlock;
16594
16148
  const drawingOrigin = drawings[blockId];
16595
- if ((drawingOrigin === null || drawingOrigin === void 0 ? void 0 : drawingOrigin.layoutType) === _univerjs_core.PositionedObjectLayoutType.INLINE) {
16149
+ if (drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.INLINE) {
16596
16150
  const { angle } = drawingOrigin.docTransform;
16597
16151
  const { width = 0, height = 0 } = drawingOrigin.docTransform.size;
16598
16152
  const boundingBox = getBoundingBox(angle, 0, width, 0, height);
16599
16153
  newGlyph = createSkeletonCustomBlockGlyph(config, boundingBox.width, boundingBox.height, drawingOrigin.drawingId);
16600
- } else if (drawingOrigin != null) newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
16154
+ } else newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
16601
16155
  }
16602
16156
  if (newGlyph == null) newGlyph = createSkeletonLetterGlyph(char, config);
16603
16157
  shapedGlyphs.push(newGlyph);
@@ -17539,9 +17093,9 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
17539
17093
  const viewport = getDocsTableRenderViewport(unitId, sourceTableId);
17540
17094
  (_this$_findLiquid = this._findLiquid) === null || _this$_findLiquid === void 0 || _this$_findLiquid.translateSave();
17541
17095
  (_this$_findLiquid2 = this._findLiquid) === null || _this$_findLiquid2 === void 0 || _this$_findLiquid2.translate(tableLeft, tableTop);
17542
- if (hasDocsTableHorizontalViewport(viewport)) {
17543
- var _viewport$leadingInse, _this$_findLiquid4;
17544
- const visibleLeft = this._findLiquid.x + page.marginLeft - ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0);
17096
+ if (viewport && viewport.contentWidth > viewport.viewportWidth) {
17097
+ var _this$_findLiquid4;
17098
+ const visibleLeft = this._findLiquid.x;
17545
17099
  const visibleRight = visibleLeft + viewport.viewportWidth;
17546
17100
  if (x < visibleLeft || x > visibleRight) {
17547
17101
  var _this$_findLiquid3;
@@ -17637,7 +17191,6 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
17637
17191
  lists,
17638
17192
  drawings,
17639
17193
  localeService: this._localeService,
17640
- documentCompatibilityPolicy: getDocumentCompatibilityPolicy(documentStyle.documentFlavor),
17641
17194
  paragraphLineGapDefault,
17642
17195
  defaultTabStop,
17643
17196
  documentTextStyle: textStyle
@@ -17712,7 +17265,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
17712
17265
  let curSkeletonPage = getLastPage(allSkeletonPages);
17713
17266
  let isContinuous = false;
17714
17267
  ctx.sectionBreakConfigCache.set(sectionNode.endIndex, sectionBreakConfig);
17715
- if (sectionType === _univerjs_core.SectionType.CONTINUOUS && curSkeletonPage != null) {
17268
+ if (sectionType === _univerjs_core.SectionType.CONTINUOUS) {
17716
17269
  updateBlockIndex(allSkeletonPages);
17717
17270
  this._addNewSectionByContinuous(curSkeletonPage, columnProperties, columnSeparatorType);
17718
17271
  isContinuous = true;
@@ -17844,7 +17397,6 @@ function createDocumentModelWithStyle(content, textStyle, config = {}) {
17844
17397
  }],
17845
17398
  paragraphs: [{
17846
17399
  startIndex: contentLength,
17847
- paragraphId: (0, _univerjs_core.createParagraphId)(/* @__PURE__ */ new Set()),
17848
17400
  paragraphStyle: { horizontalAlign }
17849
17401
  }],
17850
17402
  sectionBreaks: [{ startIndex: contentLength + 1 }]
@@ -17901,7 +17453,7 @@ function getFontFormat(format) {
17901
17453
  }
17902
17454
 
17903
17455
  //#endregion
17904
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
17456
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
17905
17457
  function __decorateParam(paramIndex, decorator) {
17906
17458
  return function(target, key) {
17907
17459
  decorator(target, key, paramIndex);
@@ -17909,7 +17461,7 @@ function __decorateParam(paramIndex, decorator) {
17909
17461
  }
17910
17462
 
17911
17463
  //#endregion
17912
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
17464
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
17913
17465
  function __decorate(decorators, target, key, desc) {
17914
17466
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17915
17467
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -18722,7 +18274,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
18722
18274
  this.makeDirty(true);
18723
18275
  }
18724
18276
  _setBorderStylesCache(row, col, style, options) {
18725
- if (_univerjs_core.Tools.isDefine(this._handleBorderMatrix.getValue(row, col)) && !(options === null || options === void 0 ? void 0 : options.mergeRange)) return;
18277
+ if (_univerjs_core.Tools.isDefine(this._handleBorderMatrix.getValue(row, col))) return;
18726
18278
  if (!((options === null || options === void 0 ? void 0 : options.cacheItem) || {
18727
18279
  bg: true,
18728
18280
  border: true
@@ -19861,56 +19413,6 @@ var docExtension = class extends ComponentExtension {
19861
19413
  }
19862
19414
  };
19863
19415
 
19864
- //#endregion
19865
- //#region src/components/docs/extensions/background-runs.ts
19866
- function collectBackgroundGlyphRuns(glyphGroup) {
19867
- const runs = [];
19868
- let activeGlyph = null;
19869
- let activeColor = "";
19870
- let activeLeft = 0;
19871
- let activeRight = 0;
19872
- const flush = () => {
19873
- if (!activeGlyph) return;
19874
- runs.push({
19875
- glyph: {
19876
- ...activeGlyph,
19877
- width: activeRight - activeLeft
19878
- },
19879
- left: activeLeft,
19880
- width: activeRight - activeLeft
19881
- });
19882
- activeGlyph = null;
19883
- activeColor = "";
19884
- activeLeft = 0;
19885
- activeRight = 0;
19886
- };
19887
- for (const glyph of glyphGroup) {
19888
- var _glyph$ts;
19889
- if (!glyph.content || glyph.content === "\r") {
19890
- flush();
19891
- continue;
19892
- }
19893
- const backgroundColor = ((_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.bg) ? (0, _univerjs_core.getColorStyle)(glyph.ts.bg) : "";
19894
- if (!backgroundColor) {
19895
- flush();
19896
- continue;
19897
- }
19898
- const glyphLeft = glyph.left;
19899
- const glyphRight = glyph.left + glyph.width;
19900
- if (activeGlyph && activeColor === backgroundColor) {
19901
- activeRight = Math.max(activeRight, glyphRight);
19902
- continue;
19903
- }
19904
- flush();
19905
- activeGlyph = glyph;
19906
- activeColor = backgroundColor;
19907
- activeLeft = glyphLeft;
19908
- activeRight = glyphRight;
19909
- }
19910
- flush();
19911
- return runs;
19912
- }
19913
-
19914
19416
  //#endregion
19915
19417
  //#region src/components/docs/extensions/background.ts
19916
19418
  const UNIQUE_KEY$3 = "DefaultDocsBackgroundExtension";
@@ -20326,6 +19828,7 @@ var Image$1 = class extends Shape {
20326
19828
  this.makeDirty(true);
20327
19829
  } else if (config.url) {
20328
19830
  this._native = document.createElement("img");
19831
+ this._native.src = config.url;
20329
19832
  this._native.crossOrigin = "anonymous";
20330
19833
  this._native.onload = () => {
20331
19834
  var _config$success, _this$getEngine;
@@ -20340,7 +19843,6 @@ var Image$1 = class extends Shape {
20340
19843
  this.makeDirty(true);
20341
19844
  }
20342
19845
  };
20343
- this._native.src = config.url;
20344
19846
  }
20345
19847
  this._init();
20346
19848
  }
@@ -20354,17 +19856,10 @@ var Image$1 = class extends Shape {
20354
19856
  var _this$_props$opacity;
20355
19857
  return (_this$_props$opacity = this._props.opacity) !== null && _this$_props$opacity !== void 0 ? _this$_props$opacity : 1;
20356
19858
  }
20357
- get clipBounds() {
20358
- return this._props.clipBounds;
20359
- }
20360
19859
  setOpacity(opacity) {
20361
19860
  this._props.opacity = opacity;
20362
19861
  this.makeDirty(true);
20363
19862
  }
20364
- setClipBounds(clipBounds) {
20365
- this._props.clipBounds = clipBounds;
20366
- this.makeDirty(true);
20367
- }
20368
19863
  setClipService(clipService) {
20369
19864
  this._clipService = clipService;
20370
19865
  }
@@ -20381,10 +19876,10 @@ var Image$1 = class extends Shape {
20381
19876
  }
20382
19877
  changeSource(url) {
20383
19878
  if (this._native == null) this._native = document.createElement("img");
19879
+ this._native.src = url;
20384
19880
  this._native.onload = () => {
20385
19881
  this.makeDirty(true);
20386
19882
  };
20387
- this._native.src = url;
20388
19883
  }
20389
19884
  resetSize() {
20390
19885
  if (this._native == null) return;
@@ -20490,12 +19985,6 @@ var Image$1 = class extends Shape {
20490
19985
  }
20491
19986
  const m = this.transform.getMatrix();
20492
19987
  mainCtx.save();
20493
- const { clipBounds } = this;
20494
- if (clipBounds) {
20495
- mainCtx.beginPath();
20496
- mainCtx.rect(clipBounds.left, clipBounds.top, clipBounds.width, clipBounds.height);
20497
- mainCtx.clip();
20498
- }
20499
19988
  const centerX = realLeft + realWidth / 2;
20500
19989
  const centerY = realTop + realHeight / 2;
20501
19990
  mainCtx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
@@ -22136,7 +21625,6 @@ var FontAndBaseLine = class extends docExtension {
22136
21625
  "actualFontMap",
22137
21626
  {}
22138
21627
  );
22139
- _defineProperty(this, "_textFillImageCache", /* @__PURE__ */ new Map());
22140
21628
  }
22141
21629
  draw(ctx, _parentScale, glyph, _, _more) {
22142
21630
  var _glyph$parent;
@@ -22155,162 +21643,13 @@ var FontAndBaseLine = class extends docExtension {
22155
21643
  this.actualFontMap[fontStringPxStr] = ctx.font;
22156
21644
  }
22157
21645
  }
22158
- const { cl: colorStyle, va: baselineOffset, textFill } = textStyle;
21646
+ const { cl: colorStyle, va: baselineOffset } = textStyle;
22159
21647
  const fontColor = (0, _univerjs_core.getColorStyle)(colorStyle) || "rgb(0,0,0)";
21648
+ if (fontColor && this._preFontColor !== fontColor) ctx.fillStyle = fontColor;
22160
21649
  if (baselineOffset === _univerjs_core.BaselineOffset.SUPERSCRIPT) spanPointWithFont.y += -bBox.spo;
22161
21650
  else if (baselineOffset === _univerjs_core.BaselineOffset.SUBSCRIPT) spanPointWithFont.y += bBox.sbo;
22162
- if (this._fillTextWithTextFill(ctx, glyph, spanPointWithFont, textFill, fontColor)) return;
22163
- if (fontColor && this._preFontColor !== fontColor) ctx.fillStyle = fontColor;
22164
21651
  this._fillText(ctx, glyph, spanPointWithFont);
22165
21652
  }
22166
- _fillTextWithTextFill(ctx, glyph, spanPointWithFont, textFill, fallbackColor) {
22167
- if (!textFill || textFill.type === "none") return (textFill === null || textFill === void 0 ? void 0 : textFill.type) === "none";
22168
- const { content, glyphType } = glyph;
22169
- if (content == null || glyphType === 2) return false;
22170
- const { renderConfig } = this.extensionOffset;
22171
- const { vertexAngle, centerAngle } = renderConfig !== null && renderConfig !== void 0 ? renderConfig : {};
22172
- const VERTICAL_DEG = 90;
22173
- if (vertexAngle === VERTICAL_DEG && centerAngle === VERTICAL_DEG) return false;
22174
- const bounds = this._getGlyphPaintBounds(glyph, spanPointWithFont);
22175
- if (bounds.width <= 0 || bounds.height <= 0) return false;
22176
- const color = this._colorWithOpacity(textFill.color || fallbackColor, textFill.opacity);
22177
- if (textFill.type === "solid") {
22178
- ctx.fillStyle = color;
22179
- this._fillText(ctx, glyph, spanPointWithFont);
22180
- return true;
22181
- }
22182
- if (textFill.type === "gradient") {
22183
- const gradient = this._createTextGradient(ctx, bounds, textFill, fallbackColor);
22184
- if (!gradient) return false;
22185
- ctx.fillStyle = gradient;
22186
- this._fillText(ctx, glyph, spanPointWithFont);
22187
- return true;
22188
- }
22189
- if (textFill.type === "picture") {
22190
- const pattern = this._createTextPicturePattern(ctx, bounds, textFill);
22191
- if (!pattern) return false;
22192
- ctx.fillStyle = pattern;
22193
- this._fillText(ctx, glyph, spanPointWithFont);
22194
- return true;
22195
- }
22196
- return false;
22197
- }
22198
- _getGlyphPaintBounds(glyph, spanPointWithFont) {
22199
- const { width, bBox } = glyph;
22200
- const textWidth = Math.max(width, bBox.width, 1);
22201
- const textHeight = Math.max(bBox.aba + bBox.abd, 1);
22202
- return {
22203
- left: spanPointWithFont.x,
22204
- top: spanPointWithFont.y - bBox.aba,
22205
- width: textWidth,
22206
- height: textHeight
22207
- };
22208
- }
22209
- _createTextGradient(ctx, bounds, textFill, fallbackColor) {
22210
- var _gradient$type, _gradient$angle, _context;
22211
- const gradient = textFill.gradient;
22212
- const type = (_gradient$type = gradient === null || gradient === void 0 ? void 0 : gradient.type) !== null && _gradient$type !== void 0 ? _gradient$type : "linear";
22213
- const angle = (_gradient$angle = gradient === null || gradient === void 0 ? void 0 : gradient.angle) !== null && _gradient$angle !== void 0 ? _gradient$angle : 0;
22214
- const stops = this._normalizeGradientStops(gradient === null || gradient === void 0 ? void 0 : gradient.stops, textFill.color || fallbackColor);
22215
- const centerX = bounds.left + bounds.width / 2;
22216
- const centerY = bounds.top + bounds.height / 2;
22217
- let canvasGradient;
22218
- if (type === "radial") {
22219
- const radius = Math.max(bounds.width, bounds.height) / 2;
22220
- canvasGradient = ctx.createRadialGradient(centerX, centerY, 0, centerX, centerY, radius);
22221
- } else if (type === "angular" && "createConicGradient" in ((_context = ctx._context) !== null && _context !== void 0 ? _context : ctx)) {
22222
- var _context2;
22223
- canvasGradient = ((_context2 = ctx._context) !== null && _context2 !== void 0 ? _context2 : ctx).createConicGradient((angle - 90) * Math.PI / 180, centerX, centerY);
22224
- } else if (type === "diamond") {
22225
- const radius = Math.max(bounds.width, bounds.height) / 2;
22226
- canvasGradient = ctx.createRadialGradient(centerX, centerY, 0, centerX, centerY, radius);
22227
- } else {
22228
- const line = this._getLinearGradientLine(bounds, angle);
22229
- canvasGradient = ctx.createLinearGradient(line.x0, line.y0, line.x1, line.y1);
22230
- }
22231
- for (const stop of stops) {
22232
- var _textFill$opacity, _stop$opacity;
22233
- 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);
22234
- canvasGradient.addColorStop(stop.offset, this._colorWithOpacity(stop.color, opacity));
22235
- }
22236
- return canvasGradient;
22237
- }
22238
- _createTextPicturePattern(ctx, bounds, textFill) {
22239
- var _textFill$picture, _ref, _textFill$picture$opa, _textFill$picture2, _textFill$picture3, _pattern$setTransform;
22240
- const source = (_textFill$picture = textFill.picture) === null || _textFill$picture === void 0 ? void 0 : _textFill$picture.source;
22241
- if (!source) return null;
22242
- const image = this._getTextFillImage(source);
22243
- if (!image || !image.complete || !(image.naturalWidth || image.width)) return null;
22244
- const canvas = document.createElement("canvas");
22245
- canvas.width = Math.max(1, Math.ceil(bounds.width));
22246
- canvas.height = Math.max(1, Math.ceil(bounds.height));
22247
- const canvasContext = canvas.getContext("2d");
22248
- if (!canvasContext) return null;
22249
- 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);
22250
- if (((_textFill$picture3 = textFill.picture) === null || _textFill$picture3 === void 0 ? void 0 : _textFill$picture3.mode) === "tile") {
22251
- var _textFill$picture$sca, _textFill$picture$sca2, _textFill$picture$off, _textFill$picture$off2;
22252
- const scaleX = (_textFill$picture$sca = textFill.picture.scaleX) !== null && _textFill$picture$sca !== void 0 ? _textFill$picture$sca : 1;
22253
- const scaleY = (_textFill$picture$sca2 = textFill.picture.scaleY) !== null && _textFill$picture$sca2 !== void 0 ? _textFill$picture$sca2 : 1;
22254
- const cellWidth = Math.max(1, (image.naturalWidth || image.width) * scaleX);
22255
- const cellHeight = Math.max(1, (image.naturalHeight || image.height) * scaleY);
22256
- const offsetX = (_textFill$picture$off = textFill.picture.offsetX) !== null && _textFill$picture$off !== void 0 ? _textFill$picture$off : 0;
22257
- const offsetY = (_textFill$picture$off2 = textFill.picture.offsetY) !== null && _textFill$picture$off2 !== void 0 ? _textFill$picture$off2 : 0;
22258
- 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);
22259
- } else canvasContext.drawImage(image, 0, 0, canvas.width, canvas.height);
22260
- const pattern = ctx.createPattern(canvas, "no-repeat");
22261
- 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));
22262
- return pattern;
22263
- }
22264
- _getTextFillImage(source) {
22265
- const cached = this._textFillImageCache.get(source);
22266
- if (cached) return cached;
22267
- const image = new Image();
22268
- image.crossOrigin = "anonymous";
22269
- image.src = source;
22270
- this._textFillImageCache.set(source, image);
22271
- return image.complete ? image : null;
22272
- }
22273
- _normalizeGradientStops(stops, fallbackColor) {
22274
- return (stops && stops.length >= 2 ? stops : [{
22275
- offset: 0,
22276
- color: fallbackColor
22277
- }, {
22278
- offset: 100,
22279
- color: "#ffffff"
22280
- }]).map((stop) => ({
22281
- color: stop.color,
22282
- offset: this._clamp(stop.offset > 1 ? stop.offset / 100 : stop.offset, 0, 1),
22283
- opacity: stop.opacity
22284
- }));
22285
- }
22286
- _getLinearGradientLine(bounds, angle) {
22287
- const angleRad = angle * Math.PI / 180;
22288
- const centerX = bounds.left + bounds.width / 2;
22289
- const centerY = bounds.top + bounds.height / 2;
22290
- const cos = Math.cos(angleRad);
22291
- const sin = Math.sin(angleRad);
22292
- const halfDiagonal = (Math.abs(bounds.width * cos) + Math.abs(bounds.height * sin)) / 2;
22293
- return {
22294
- x0: centerX - cos * halfDiagonal,
22295
- y0: centerY - sin * halfDiagonal,
22296
- x1: centerX + cos * halfDiagonal,
22297
- y1: centerY + sin * halfDiagonal
22298
- };
22299
- }
22300
- _colorWithOpacity(color, opacity) {
22301
- if (opacity === void 0 || opacity >= 1) return color;
22302
- const alpha = this._clamp(opacity, 0, 1);
22303
- const hex = color.trim();
22304
- if (/^#[0-9a-f]{3}$/i.test(hex)) {
22305
- const [, r, g, b] = hex;
22306
- return `rgba(${Number.parseInt(r + r, 16)}, ${Number.parseInt(g + g, 16)}, ${Number.parseInt(b + b, 16)}, ${alpha})`;
22307
- }
22308
- 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})`;
22309
- return color;
22310
- }
22311
- _clamp(value, min, max) {
22312
- return Math.max(min, Math.min(max, value));
22313
- }
22314
21653
  _fillText(ctx, glyph, spanPointWithFont) {
22315
21654
  const { renderConfig, spanStartPoint, centerPoint } = this.extensionOffset;
22316
21655
  const { content, width, bBox } = glyph;
@@ -22658,14 +21997,24 @@ var Documents = class Documents extends DocComponent {
22658
21997
  this._drawLiquid.translateSave();
22659
21998
  this._drawLiquid.translateLine(line, true, true);
22660
21999
  rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i]);
22661
- this._drawLineBackground(ctx, page, line);
22662
22000
  const divideLength = divides.length;
22663
22001
  for (let i = 0; i < divideLength; i++) {
22664
22002
  const divide = divides[i];
22665
22003
  const { glyphGroup } = divide;
22666
22004
  this._drawLiquid.translateSave();
22667
22005
  this._drawLiquid.translateDivide(divide, isVertical && wrapStrategy === _univerjs_core.WrapStrategy.WRAP, verticalAlign, rotatedHeightStore);
22668
- this._drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension);
22006
+ for (const glyph of glyphGroup) {
22007
+ if (!glyph.content || glyph.content.length === 0) continue;
22008
+ const { width: spanWidth, left: spanLeft } = glyph;
22009
+ const { x: translateX, y: translateY } = this._drawLiquid;
22010
+ const originTranslate = Vector2.create(translateX, translateY);
22011
+ const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
22012
+ const extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
22013
+ if (backgroundExtension) {
22014
+ backgroundExtension.extensionOffset = extensionOffset;
22015
+ backgroundExtension.draw(ctx, parentScale, glyph);
22016
+ }
22017
+ }
22669
22018
  for (const glyph of glyphGroup) {
22670
22019
  if (!glyph.content || glyph.content.length === 0) continue;
22671
22020
  const { width: spanWidth, left: spanLeft, xOffset } = glyph;
@@ -22721,18 +22070,15 @@ var Documents = class Documents extends DocComponent {
22721
22070
  const viewport = this._getTableViewport(page, tableSkeleton, renderUnitId, sourceTableId);
22722
22071
  drawLiquid.translateSave();
22723
22072
  drawLiquid.translate(tableLeft, tableTop);
22724
- if (hasDocsTableHorizontalViewport(viewport)) {
22725
- var _viewport$leadingInse;
22073
+ if (viewport && viewport.contentWidth > viewport.viewportWidth) {
22726
22074
  const { x, y } = drawLiquid;
22727
- const clipLeft = x + page.marginLeft - ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0);
22728
22075
  ctx.save();
22729
22076
  ctx.beginPath();
22730
- 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);
22077
+ 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);
22731
22078
  ctx.closePath();
22732
22079
  ctx.clip();
22733
22080
  drawLiquid.translate(-viewport.scrollLeft, 0);
22734
22081
  }
22735
- this._drawTableCellBackgrounds(ctx, page, tableSkeleton);
22736
22082
  for (const row of rows) {
22737
22083
  const { top: rowTop, cells } = row;
22738
22084
  drawLiquid.translateSave();
@@ -22747,49 +22093,16 @@ var Documents = class Documents extends DocComponent {
22747
22093
  }
22748
22094
  drawLiquid.translateRestore();
22749
22095
  }
22750
- if (hasDocsTableHorizontalViewport(viewport)) ctx.restore();
22096
+ if (viewport && viewport.contentWidth > viewport.viewportWidth) ctx.restore();
22751
22097
  drawLiquid.translateRestore();
22752
22098
  }
22753
22099
  }
22754
- _drawTableCellBackgrounds(ctx, page, tableSkeleton) {
22755
- if (this._drawLiquid == null) return;
22756
- const backgrounds = /* @__PURE__ */ new Map();
22757
- const tableX = this._drawLiquid.x + page.marginLeft;
22758
- const tableY = this._drawLiquid.y + page.marginTop;
22759
- for (const row of tableSkeleton.rows) row.cells.forEach((cell, index) => {
22760
- var _cellSource$backgroun, _backgrounds$get;
22761
- if (cell.isMergedCellCovered) return;
22762
- const cellSource = row.rowSource.tableCells[index];
22763
- if (!cellSource || cellSource.rowSpan === 0 || cellSource.columnSpan === 0) return;
22764
- const color = (_cellSource$backgroun = cellSource.backgroundColor) === null || _cellSource$backgroun === void 0 ? void 0 : _cellSource$backgroun.rgb;
22765
- if (!color) return;
22766
- const rects = (_backgrounds$get = backgrounds.get(color)) !== null && _backgrounds$get !== void 0 ? _backgrounds$get : [];
22767
- rects.push({
22768
- x: tableX + cell.left,
22769
- y: tableY + row.top,
22770
- width: cell.pageWidth,
22771
- height: cell.pageHeight
22772
- });
22773
- backgrounds.set(color, rects);
22774
- });
22775
- backgrounds.forEach((rects, color) => {
22776
- ctx.save();
22777
- ctx.fillStyle = color;
22778
- ctx.beginPath();
22779
- rects.forEach(({ x, y, width, height }) => {
22780
- rectByPrecisionBounds(ctx, x, y, width, height);
22781
- });
22782
- ctx.fill();
22783
- ctx.closePath();
22784
- ctx.restore();
22785
- });
22786
- }
22787
22100
  _getTableViewport(page, tableSkeleton, unitId, tableId) {
22788
22101
  const viewport = getDocsTableRenderViewport(unitId, tableId);
22789
22102
  if (viewport) return viewport;
22790
22103
  const { pageWidth, marginLeft = 0, marginRight = 0 } = page;
22791
22104
  if (!Number.isFinite(pageWidth)) return null;
22792
- 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);
22105
+ const viewportWidth = Math.max(0, pageWidth - marginLeft - marginRight - tableSkeleton.left);
22793
22106
  if (viewportWidth <= 0 || tableSkeleton.width <= viewportWidth) return null;
22794
22107
  return {
22795
22108
  contentWidth: tableSkeleton.width,
@@ -22804,26 +22117,6 @@ var Documents = class Documents extends DocComponent {
22804
22117
  const dataModel = viewModel === null || viewModel === void 0 || (_viewModel$getDataMod = viewModel.getDataModel) === null || _viewModel$getDataMod === void 0 ? void 0 : _viewModel$getDataMod.call(viewModel);
22805
22118
  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;
22806
22119
  }
22807
- _getDocumentCompatibilityPolicy() {
22808
- var _skeleton$getViewMode2, _skeleton$getViewMode3;
22809
- const skeleton = this.getSkeleton();
22810
- 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);
22811
- }
22812
- _drawLineBackground(ctx, page, line, left = 0, top = 0) {
22813
- var _line$backgroundColor;
22814
- const color = (_line$backgroundColor = line.backgroundColor) === null || _line$backgroundColor === void 0 ? void 0 : _line$backgroundColor.rgb;
22815
- if (!color || this._drawLiquid == null) return;
22816
- let { x, y } = this._drawLiquid;
22817
- const { pageWidth, marginLeft, marginRight, marginTop } = page;
22818
- x += marginLeft + (left !== null && left !== void 0 ? left : 0);
22819
- y -= line.marginTop;
22820
- y -= line.paddingTop;
22821
- y += marginTop + top;
22822
- ctx.save();
22823
- ctx.fillStyle = color;
22824
- fillRectByPrecisionBounds(ctx, x, y, pageWidth - marginLeft - marginRight, line.lineHeight);
22825
- ctx.restore();
22826
- }
22827
22120
  _drawBorderBottom(ctx, page, line, left = 0, top = 0) {
22828
22121
  var _line$borderBottom$pa, _line$borderBottom, _line$borderBottom$co, _line$borderBottom2;
22829
22122
  if (this._drawLiquid == null) return;
@@ -22844,21 +22137,9 @@ var Documents = class Documents extends DocComponent {
22844
22137
  });
22845
22138
  ctx.restore();
22846
22139
  }
22847
- _drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension) {
22848
- if (!backgroundExtension || this._drawLiquid == null) return;
22849
- const backgroundRuns = collectBackgroundGlyphRuns(glyphGroup);
22850
- for (const backgroundRun of backgroundRuns) {
22851
- const { glyph, left: spanLeft, width: spanWidth } = backgroundRun;
22852
- const { x: translateX, y: translateY } = this._drawLiquid;
22853
- const originTranslate = Vector2.create(translateX, translateY);
22854
- const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
22855
- backgroundExtension.extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
22856
- backgroundExtension.draw(ctx, parentScale, glyph);
22857
- }
22858
- }
22859
22140
  _drawTableCell(ctx, page, cell, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale) {
22860
22141
  if (this._drawLiquid == null) return;
22861
- this._drawTableCellBordersAndBg(ctx, page, cell, false);
22142
+ this._drawTableCellBordersAndBg(ctx, page, cell);
22862
22143
  const { sections, marginLeft, marginTop } = cell;
22863
22144
  alignOffsetNoAngle = Vector2.create(alignOffsetNoAngle.x + marginLeft, alignOffsetNoAngle.y + marginTop);
22864
22145
  ctx.save();
@@ -22895,14 +22176,24 @@ var Documents = class Documents extends DocComponent {
22895
22176
  } else {
22896
22177
  this._drawLiquid.translateSave();
22897
22178
  this._drawLiquid.translateLine(line, true, true);
22898
- this._drawLineBackground(ctx, cell, line, page.marginLeft, page.marginTop);
22899
22179
  const divideLength = divides.length;
22900
22180
  for (let i = 0; i < divideLength; i++) {
22901
22181
  const divide = divides[i];
22902
22182
  const { glyphGroup } = divide;
22903
22183
  this._drawLiquid.translateSave();
22904
22184
  this._drawLiquid.translateDivide(divide);
22905
- this._drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension);
22185
+ for (const glyph of glyphGroup) {
22186
+ if (!glyph.content || glyph.content.length === 0) continue;
22187
+ const { width: spanWidth, left: spanLeft } = glyph;
22188
+ const { x: translateX, y: translateY } = this._drawLiquid;
22189
+ const originTranslate = Vector2.create(translateX, translateY);
22190
+ const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
22191
+ const extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
22192
+ if (backgroundExtension) {
22193
+ backgroundExtension.extensionOffset = extensionOffset;
22194
+ backgroundExtension.draw(ctx, parentScale, glyph);
22195
+ }
22196
+ }
22906
22197
  for (const glyph of glyphGroup) {
22907
22198
  if (!glyph.content || glyph.content.length === 0) continue;
22908
22199
  const { width: spanWidth, left: spanLeft, xOffset } = glyph;
@@ -22934,8 +22225,8 @@ var Documents = class Documents extends DocComponent {
22934
22225
  }
22935
22226
  ctx.restore();
22936
22227
  }
22937
- _drawTableCellBordersAndBg(ctx, page, cell, drawBackground = true) {
22938
- var _rowSke$index, _cellSource$backgroun2;
22228
+ _drawTableCellBordersAndBg(ctx, page, cell) {
22229
+ var _rowSke$index, _cellSource$backgroun;
22939
22230
  const { marginLeft, marginTop } = page;
22940
22231
  const { pageWidth, pageHeight } = cell;
22941
22232
  const rowSke = cell.parent;
@@ -22950,10 +22241,10 @@ var Documents = class Documents extends DocComponent {
22950
22241
  let { x, y } = this._drawLiquid;
22951
22242
  x += marginLeft;
22952
22243
  y += marginTop;
22953
- if (drawBackground && ((_cellSource$backgroun2 = cellSource.backgroundColor) === null || _cellSource$backgroun2 === void 0 ? void 0 : _cellSource$backgroun2.rgb)) {
22244
+ if ((_cellSource$backgroun = cellSource.backgroundColor) === null || _cellSource$backgroun === void 0 ? void 0 : _cellSource$backgroun.rgb) {
22954
22245
  ctx.save();
22955
22246
  ctx.fillStyle = cellSource.backgroundColor.rgb;
22956
- fillRectByPrecisionBounds(ctx, x, y, pageWidth, pageHeight);
22247
+ ctx.fillRectByPrecision(x, y, pageWidth, pageHeight);
22957
22248
  ctx.restore();
22958
22249
  }
22959
22250
  const position = {
@@ -23001,9 +22292,8 @@ var Documents = class Documents extends DocComponent {
23001
22292
  }
23002
22293
  _drawHeaderFooter(page, ctx, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale, parentPage, isHeader = true) {
23003
22294
  if (this._drawLiquid == null) return;
23004
- const { sections, skeTables } = page;
22295
+ const { sections } = page;
23005
22296
  const { y: originY } = this._drawLiquid;
23006
- if (skeTables.size > 0) this._drawTable(ctx, page, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
23007
22297
  for (const section of sections) {
23008
22298
  const { columns } = section;
23009
22299
  this._drawLiquid.translateSave();
@@ -23032,20 +22322,33 @@ var Documents = class Documents extends DocComponent {
23032
22322
  this._drawLiquid.translateSave();
23033
22323
  this._drawLiquid.translateLine(line, true, true);
23034
22324
  const { y } = this._drawLiquid;
23035
- if (!isHeader) {
23036
- if (y - originY + alignOffset.y + lineHeight < (parentPage.pageHeight - 100) / 2 + 100) {
22325
+ if (isHeader) {
22326
+ if (y - originY + alignOffset.y > (parentPage.pageHeight - 100) / 2) {
23037
22327
  this._drawLiquid.translateRestore();
23038
22328
  continue;
23039
22329
  }
22330
+ } else if (y - originY + alignOffset.y + lineHeight < (parentPage.pageHeight - 100) / 2 + 100) {
22331
+ this._drawLiquid.translateRestore();
22332
+ continue;
23040
22333
  }
23041
- this._drawLineBackground(ctx, page, line, parentPage.marginLeft);
23042
22334
  const divideLength = divides.length;
23043
22335
  for (let i = 0; i < divideLength; i++) {
23044
22336
  const divide = divides[i];
23045
22337
  const { glyphGroup } = divide;
23046
22338
  this._drawLiquid.translateSave();
23047
22339
  this._drawLiquid.translateDivide(divide);
23048
- this._drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension);
22340
+ for (const glyph of glyphGroup) {
22341
+ if (!glyph.content || glyph.content.length === 0) continue;
22342
+ const { width: spanWidth, left: spanLeft } = glyph;
22343
+ const { x: translateX, y: translateY } = this._drawLiquid;
22344
+ const originTranslate = Vector2.create(translateX, translateY);
22345
+ const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
22346
+ const extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
22347
+ if (backgroundExtension) {
22348
+ backgroundExtension.extensionOffset = extensionOffset;
22349
+ backgroundExtension.draw(ctx, parentScale, glyph);
22350
+ }
22351
+ }
23049
22352
  for (const glyph of glyphGroup) {
23050
22353
  if (!glyph.content || glyph.content.length === 0) continue;
23051
22354
  const { width: spanWidth, left: spanLeft, xOffset } = glyph;
@@ -23081,19 +22384,18 @@ var Documents = class Documents extends DocComponent {
23081
22384
  * In Excel, if horizontal alignment is not specified,
23082
22385
  * rotated text aligns to the right when rotated downwards and aligns to the left when rotated upwards.
23083
22386
  */
23084
- let resolvedHorizontalAlign = horizontalAlign;
23085
- if (resolvedHorizontalAlign === _univerjs_core.HorizontalAlign.UNSPECIFIED) if (centerAngleDeg === 90 && vertexAngleDeg === 90) resolvedHorizontalAlign = _univerjs_core.HorizontalAlign.CENTER;
22387
+ if (horizontalAlign === _univerjs_core.HorizontalAlign.UNSPECIFIED) if (centerAngleDeg === 90 && vertexAngleDeg === 90) horizontalAlign = _univerjs_core.HorizontalAlign.CENTER;
23086
22388
  else if (vertexAngleDeg > 0 && vertexAngleDeg !== 90 || vertexAngleDeg === -90)
23087
22389
  /**
23088
22390
  * https://github.com/dream-num/univer-pro/issues/334
23089
22391
  */
23090
- resolvedHorizontalAlign = _univerjs_core.HorizontalAlign.RIGHT;
23091
- else if (cellValueType === _univerjs_core.CellValueType.NUMBER) resolvedHorizontalAlign = _univerjs_core.HorizontalAlign.RIGHT;
23092
- else if (cellValueType === _univerjs_core.CellValueType.BOOLEAN) resolvedHorizontalAlign = _univerjs_core.HorizontalAlign.CENTER;
23093
- else resolvedHorizontalAlign = _univerjs_core.HorizontalAlign.LEFT;
22392
+ horizontalAlign = _univerjs_core.HorizontalAlign.RIGHT;
22393
+ else if (cellValueType === _univerjs_core.CellValueType.NUMBER) horizontalAlign = _univerjs_core.HorizontalAlign.RIGHT;
22394
+ else if (cellValueType === _univerjs_core.CellValueType.BOOLEAN) horizontalAlign = _univerjs_core.HorizontalAlign.CENTER;
22395
+ else horizontalAlign = _univerjs_core.HorizontalAlign.LEFT;
23094
22396
  let offsetLeft = 0;
23095
- if (resolvedHorizontalAlign === _univerjs_core.HorizontalAlign.CENTER) offsetLeft = (this.width - pageWidth) / 2;
23096
- else if (resolvedHorizontalAlign === _univerjs_core.HorizontalAlign.RIGHT) offsetLeft = this.width - pageWidth - pagePaddingRight;
22397
+ if (horizontalAlign === _univerjs_core.HorizontalAlign.CENTER) offsetLeft = (this.width - pageWidth) / 2;
22398
+ else if (horizontalAlign === _univerjs_core.HorizontalAlign.RIGHT) offsetLeft = this.width - pageWidth - pagePaddingRight;
23097
22399
  else offsetLeft = pagePaddingLeft;
23098
22400
  return offsetLeft;
23099
22401
  }
@@ -23127,22 +22429,6 @@ function setTableCellBorderDash(ctx, dashStyle) {
23127
22429
  }
23128
22430
  ctx.setLineDash([0]);
23129
22431
  }
23130
- function fillRectByPrecisionBounds(ctx, x, y, width, height) {
23131
- const { scaleX, scaleY } = ctx.getScale();
23132
- const startX = fixLineWidthByScale(x, scaleX);
23133
- const startY = fixLineWidthByScale(y, scaleY);
23134
- const endX = fixLineWidthByScale(x + width, scaleX);
23135
- const endY = fixLineWidthByScale(y + height, scaleY);
23136
- ctx.fillRect(startX, startY, endX - startX, endY - startY);
23137
- }
23138
- function rectByPrecisionBounds(ctx, x, y, width, height) {
23139
- const { scaleX, scaleY } = ctx.getScale();
23140
- const startX = fixLineWidthByScale(x, scaleX);
23141
- const startY = fixLineWidthByScale(y, scaleY);
23142
- const endX = fixLineWidthByScale(x + width, scaleX);
23143
- const endY = fixLineWidthByScale(y + height, scaleY);
23144
- ctx.rect(startX, startY, endX - startX, endY - startY);
23145
- }
23146
22432
 
23147
22433
  //#endregion
23148
22434
  //#region src/components/sheets/spreadsheet.ts
@@ -24355,8 +23641,6 @@ var DocBackground = class DocBackground extends DocComponent {
24355
23641
  _defineProperty(this, "_pageFillColor", void 0);
24356
23642
  _defineProperty(this, "_pageStrokeColor", void 0);
24357
23643
  _defineProperty(this, "_marginStrokeColor", void 0);
24358
- _defineProperty(this, "_pageBackgroundSource", void 0);
24359
- _defineProperty(this, "_pageBackgroundImage", void 0);
24360
23644
  this._drawLiquid = new Liquid();
24361
23645
  this._backgroundFillColor = config === null || config === void 0 ? void 0 : config.backgroundFillColor;
24362
23646
  this._pageFillColor = config === null || config === void 0 ? void 0 : config.pageFillColor;
@@ -24380,7 +23664,7 @@ var DocBackground = class DocBackground extends DocComponent {
24380
23664
  const skeletonData = (_this$getSkeleton = this.getSkeleton()) === null || _this$getSkeleton === void 0 ? void 0 : _this$getSkeleton.getSkeletonData();
24381
23665
  const docDataModel = (_this$getSkeleton2 = this.getSkeleton()) === null || _this$getSkeleton2 === void 0 ? void 0 : _this$getSkeleton2.getViewModel().getDataModel();
24382
23666
  if (skeletonData == null || docDataModel == null) return;
24383
- const { documentFlavor, background } = docDataModel.getSnapshot().documentStyle;
23667
+ const { documentFlavor } = docDataModel.getSnapshot().documentStyle;
24384
23668
  const workspaceFill = (_this$_backgroundFill = this._backgroundFillColor) !== null && _this$_backgroundFill !== void 0 ? _this$_backgroundFill : documentFlavor === _univerjs_core.DocumentFlavor.MODERN ? PAGE_FILL_COLOR : DOCS_WORKSPACE_FILL_COLOR;
24385
23669
  this._drawWorkspaceBackground(ctx, workspaceFill, bounds);
24386
23670
  if (documentFlavor === _univerjs_core.DocumentFlavor.MODERN) return;
@@ -24409,7 +23693,6 @@ var DocBackground = class DocBackground extends DocComponent {
24409
23693
  zIndex: 3
24410
23694
  };
24411
23695
  Rect.drawWith(ctx, backgroundOptions);
24412
- 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);
24413
23696
  const IDENTIFIER_WIDTH = 15;
24414
23697
  const marginIdentification = {
24415
23698
  dataArray: [
@@ -24490,22 +23773,6 @@ var DocBackground = class DocBackground extends DocComponent {
24490
23773
  });
24491
23774
  ctx.restore();
24492
23775
  }
24493
- _drawPageBackgroundImage(ctx, source, width, height) {
24494
- if (!source || width <= 0 || height <= 0) return;
24495
- const image = this._getPageBackgroundImage(source);
24496
- if (!image.complete) return;
24497
- ctx.drawImage(image, 0, 0, width, height);
24498
- }
24499
- _getPageBackgroundImage(source) {
24500
- if (this._pageBackgroundSource === source && this._pageBackgroundImage != null) return this._pageBackgroundImage;
24501
- const image = document.createElement("img");
24502
- image.crossOrigin = "anonymous";
24503
- image.onload = () => this.makeDirty(true);
24504
- image.src = source;
24505
- this._pageBackgroundSource = source;
24506
- this._pageBackgroundImage = image;
24507
- return image;
24508
- }
24509
23776
  changeSkeleton(newSkeleton) {
24510
23777
  this.setSkeleton(newSkeleton);
24511
23778
  return this;
@@ -24942,42 +24209,6 @@ var DumbCanvasColorService = class {
24942
24209
  return color;
24943
24210
  }
24944
24211
  };
24945
- const DARK_RENDER_COLOR_OVERRIDES = {
24946
- "#17212b": "#e2e8f0",
24947
- "#64748b": "#94a3b8",
24948
- "#d9e0e7": "#253044",
24949
- "#edf1f5": "#1b2535",
24950
- "#eef2f6": "#1b2535",
24951
- "#f2f5f8": "#101827",
24952
- "#f3f6fa": "#18243a",
24953
- "#f4f8ff": "#172a46",
24954
- "#f5f9ff": "#12233a",
24955
- "#f7f9fb": "#0d1422",
24956
- "#f7f9fc": "#0d1422",
24957
- "#f8fafc": "#0f172a",
24958
- "#fbfcfd": "#07111f",
24959
- "#fcfdff": "#050914",
24960
- "#e8f1ff": "#173a69",
24961
- "#eaf5ff": "#12315a",
24962
- "#dbeafe": "#1e3a8a",
24963
- "#bfdbfe": "#60a5fa",
24964
- "#93c5fd": "#60a5fa",
24965
- "#8eb6f5": "#60a5fa",
24966
- "#60a5fa": "#60a5fa",
24967
- "#2563eb": "#60a5fa",
24968
- "#1d64d8": "#93c5fd",
24969
- "#1d5cff": "#60a5fa",
24970
- "#0f766e": "#2dd4bf",
24971
- "#d7f4ef": "#134e4a",
24972
- "rgba(37,99,235,0.05)": "rgba(96,165,250,0.16)",
24973
- "rgba(37,99,235,0.06)": "rgba(96,165,250,0.18)",
24974
- "rgba(37,99,235,0.08)": "rgba(96,165,250,0.22)",
24975
- "rgba(37,99,235,0.12)": "rgba(96,165,250,0.26)",
24976
- "rgba(37,99,235,0.18)": "rgba(96,165,250,0.30)",
24977
- "rgba(37,99,235,0.28)": "rgba(96,165,250,0.38)",
24978
- "rgba(239,246,255,0.88)": "rgba(30,64,175,0.72)",
24979
- "rgba(148,163,184,0.45)": "rgba(148,163,184,0.52)"
24980
- };
24981
24212
  let CanvasColorService = class CanvasColorService extends _univerjs_core.Disposable {
24982
24213
  constructor(_themeService) {
24983
24214
  super();
@@ -24988,14 +24219,8 @@ let CanvasColorService = class CanvasColorService extends _univerjs_core.Disposa
24988
24219
  getRenderColor(color) {
24989
24220
  if (!this._themeService.darkMode) return color;
24990
24221
  if (this._cache.has(color)) return this._cache.get(color);
24991
- if (normalizeRenderColor(color) === "transparent") {
24992
- this._cache.set(color, "transparent");
24993
- return "transparent";
24994
- }
24995
24222
  let cachedColor = "";
24996
- const mappedColor = getDarkRenderColorOverride(color);
24997
- if (mappedColor) cachedColor = mappedColor;
24998
- else if (color.startsWith("#")) {
24223
+ if (color.startsWith("#")) {
24999
24224
  cachedColor = rgbToHex(this._invertAlgo(hexToRgb(color)));
25000
24225
  if (color.length === 5) {
25001
24226
  const alpha = color.charAt(4);
@@ -25027,15 +24252,6 @@ let CanvasColorService = class CanvasColorService extends _univerjs_core.Disposa
25027
24252
  }
25028
24253
  };
25029
24254
  CanvasColorService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))], CanvasColorService);
25030
- function getDarkRenderColorOverride(color) {
25031
- var _DARK_RENDER_COLOR_OV;
25032
- return (_DARK_RENDER_COLOR_OV = DARK_RENDER_COLOR_OVERRIDES[normalizeRenderColor(color)]) !== null && _DARK_RENDER_COLOR_OV !== void 0 ? _DARK_RENDER_COLOR_OV : null;
25033
- }
25034
- function normalizeRenderColor(color) {
25035
- const trimmed = color.trim().toLowerCase();
25036
- if (trimmed.startsWith("rgb")) return trimmed.replace(/\s+/g, "");
25037
- return trimmed;
25038
- }
25039
24255
  function hexToRgb(_hex) {
25040
24256
  const hex = _hex.replace(/^#/, "");
25041
24257
  let r;
@@ -25709,7 +24925,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
25709
24925
  //#endregion
25710
24926
  //#region package.json
25711
24927
  var name = "@univerjs/engine-render";
25712
- var version = "0.25.0-insiders.20260623-012b5a8";
24928
+ var version = "0.25.1";
25713
24929
 
25714
24930
  //#endregion
25715
24931
  //#region src/config/config.ts
@@ -26181,47 +25397,7 @@ const DEFAULT_TRANSFORMER_LAYER_INDEX = 2;
26181
25397
  const MINI_WIDTH_LIMIT = 20;
26182
25398
  const MINI_HEIGHT_LIMIT = 20;
26183
25399
  const DEFAULT_CONTROL_PLUS_INDEX = 5e3;
26184
- const SINGLE_ACTIVE_OBJECT_TYPE_MAP = /* @__PURE__ */ new Set([6]);
26185
- const ROTATE_ICON_SIZE = 14;
26186
- var TransformerRotateIcon = class extends Rect {
26187
- _draw(ctx) {
26188
- const iconWidth = this.width || ROTATE_ICON_SIZE;
26189
- const iconHeight = this.height || ROTATE_ICON_SIZE;
26190
- const scaleX = iconWidth / 24;
26191
- const scaleY = iconHeight / 24;
26192
- ctx.save();
26193
- ctx.scale(scaleX, scaleY);
26194
- ctx.beginPath();
26195
- ctx.lineWidth = (this.strokeWidth || 2) / Math.max(scaleX, scaleY);
26196
- ctx.lineCap = "round";
26197
- ctx.lineJoin = "round";
26198
- ctx.strokeStyle = this.stroke || "currentColor";
26199
- ctx.moveTo(21, 12);
26200
- ctx.arc(12, 12, 9, 0, Math.PI * 1.5, false);
26201
- ctx.bezierCurveTo(14.52, 3, 16.93, 4, 18.74, 5.74);
26202
- ctx.lineTo(21, 8);
26203
- ctx.moveTo(21, 3);
26204
- ctx.lineTo(21, 8);
26205
- ctx.lineTo(16, 8);
26206
- ctx.stroke();
26207
- ctx.restore();
26208
- }
26209
- };
26210
- var TransformerAnchor = class extends Rect {
26211
- _draw(ctx) {
26212
- if (!this.shadowColor || !this.shadowBlur && !this.shadowOffsetX && !this.shadowOffsetY) {
26213
- Rect.drawWith(ctx, this);
26214
- return;
26215
- }
26216
- ctx.save();
26217
- ctx.shadowColor = this.shadowColor;
26218
- ctx.shadowBlur = this.shadowBlur;
26219
- ctx.shadowOffsetX = this.shadowOffsetX;
26220
- ctx.shadowOffsetY = this.shadowOffsetY;
26221
- Rect.drawWith(ctx, this);
26222
- ctx.restore();
26223
- }
26224
- };
25400
+ const SINGLE_ACTIVE_OBJECT_TYPE_MAP = new Set([6]);
26225
25401
  /**
26226
25402
  * Transformer constructor. Transformer is a special type of group that allow you transform
26227
25403
  * primitives and shapes. Transforming tool is not changing `width` and `height` properties of nodes
@@ -26240,16 +25416,8 @@ var Transformer = class extends _univerjs_core.Disposable {
26240
25416
  _defineProperty(this, "rotationSnaps", []);
26241
25417
  _defineProperty(this, "rotationSnapTolerance", 5);
26242
25418
  _defineProperty(this, "rotateAnchorOffset", 50);
26243
- _defineProperty(this, "rotateAnchorPosition", "top");
26244
- _defineProperty(this, "rotateLineEnabled", true);
26245
25419
  _defineProperty(this, "rotateSize", 10);
26246
25420
  _defineProperty(this, "rotateCornerRadius", 10);
26247
- _defineProperty(this, "rotateFill", void 0);
26248
- _defineProperty(this, "rotateStroke", void 0);
26249
- _defineProperty(this, "rotateStrokeWidth", void 0);
26250
- _defineProperty(this, "rotateIconEnabled", false);
26251
- _defineProperty(this, "rotateIconStroke", void 0);
26252
- _defineProperty(this, "rotateIconStrokeWidth", 1.5);
26253
25421
  _defineProperty(this, "borderEnabled", true);
26254
25422
  _defineProperty(this, "borderStroke", "rgb(97, 97, 97)");
26255
25423
  _defineProperty(this, "borderStrokeWidth", 1);
@@ -26260,19 +25428,10 @@ var Transformer = class extends _univerjs_core.Disposable {
26260
25428
  _defineProperty(this, "anchorStrokeWidth", 1);
26261
25429
  _defineProperty(this, "anchorSize", 10);
26262
25430
  _defineProperty(this, "anchorCornerRadius", 10);
26263
- _defineProperty(this, "anchorStyle", "default");
26264
- _defineProperty(this, "anchorSideLongSize", 16);
26265
- _defineProperty(this, "anchorSideShortSize", 5);
26266
- _defineProperty(this, "anchorSideCornerRadius", 2.5);
26267
- _defineProperty(this, "anchorShadowColor", void 0);
26268
- _defineProperty(this, "anchorShadowBlur", 0);
26269
- _defineProperty(this, "anchorShadowOffsetX", 0);
26270
- _defineProperty(this, "anchorShadowOffsetY", 0);
26271
25431
  _defineProperty(this, "keepRatio", true);
26272
25432
  _defineProperty(this, "centeredScaling", false);
26273
25433
  _defineProperty(this, "zeroLeft", 0);
26274
25434
  _defineProperty(this, "zeroTop", 0);
26275
- _defineProperty(this, "moveBoundaryEnabled", true);
26276
25435
  _defineProperty(
26277
25436
  this,
26278
25437
  /**
@@ -26386,9 +25545,9 @@ var Transformer = class extends _univerjs_core.Disposable {
26386
25545
  }
26387
25546
  _getConfig(applyObject) {
26388
25547
  const objectTransformerConfig = applyObject.transformerConfig;
26389
- 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;
25548
+ 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;
26390
25549
  if (objectTransformerConfig != null) {
26391
- 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;
25550
+ 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;
26392
25551
  isCropper = (_objectTransformerCon = objectTransformerConfig.isCropper) !== null && _objectTransformerCon !== void 0 ? _objectTransformerCon : isCropper;
26393
25552
  hoverEnabled = (_objectTransformerCon2 = objectTransformerConfig.hoverEnabled) !== null && _objectTransformerCon2 !== void 0 ? _objectTransformerCon2 : hoverEnabled;
26394
25553
  hoverEnterFunc = (_objectTransformerCon3 = objectTransformerConfig.hoverEnterFunc) !== null && _objectTransformerCon3 !== void 0 ? _objectTransformerCon3 : hoverEnterFunc;
@@ -26398,43 +25557,26 @@ var Transformer = class extends _univerjs_core.Disposable {
26398
25557
  rotationSnaps = (_objectTransformerCon7 = objectTransformerConfig.rotationSnaps) !== null && _objectTransformerCon7 !== void 0 ? _objectTransformerCon7 : rotationSnaps;
26399
25558
  rotationSnapTolerance = (_objectTransformerCon8 = objectTransformerConfig.rotationSnapTolerance) !== null && _objectTransformerCon8 !== void 0 ? _objectTransformerCon8 : rotationSnapTolerance;
26400
25559
  rotateAnchorOffset = (_objectTransformerCon9 = objectTransformerConfig.rotateAnchorOffset) !== null && _objectTransformerCon9 !== void 0 ? _objectTransformerCon9 : rotateAnchorOffset;
26401
- rotateAnchorPosition = (_objectTransformerCon10 = objectTransformerConfig.rotateAnchorPosition) !== null && _objectTransformerCon10 !== void 0 ? _objectTransformerCon10 : rotateAnchorPosition;
26402
- rotateLineEnabled = (_objectTransformerCon11 = objectTransformerConfig.rotateLineEnabled) !== null && _objectTransformerCon11 !== void 0 ? _objectTransformerCon11 : rotateLineEnabled;
26403
- rotateSize = (_objectTransformerCon12 = objectTransformerConfig.rotateSize) !== null && _objectTransformerCon12 !== void 0 ? _objectTransformerCon12 : rotateSize;
26404
- rotateCornerRadius = (_objectTransformerCon13 = objectTransformerConfig.rotateCornerRadius) !== null && _objectTransformerCon13 !== void 0 ? _objectTransformerCon13 : rotateCornerRadius;
26405
- rotateFill = (_objectTransformerCon14 = objectTransformerConfig.rotateFill) !== null && _objectTransformerCon14 !== void 0 ? _objectTransformerCon14 : rotateFill;
26406
- rotateStroke = (_objectTransformerCon15 = objectTransformerConfig.rotateStroke) !== null && _objectTransformerCon15 !== void 0 ? _objectTransformerCon15 : rotateStroke;
26407
- rotateStrokeWidth = (_objectTransformerCon16 = objectTransformerConfig.rotateStrokeWidth) !== null && _objectTransformerCon16 !== void 0 ? _objectTransformerCon16 : rotateStrokeWidth;
26408
- rotateIconEnabled = (_objectTransformerCon17 = objectTransformerConfig.rotateIconEnabled) !== null && _objectTransformerCon17 !== void 0 ? _objectTransformerCon17 : rotateIconEnabled;
26409
- rotateIconStroke = (_objectTransformerCon18 = objectTransformerConfig.rotateIconStroke) !== null && _objectTransformerCon18 !== void 0 ? _objectTransformerCon18 : rotateIconStroke;
26410
- rotateIconStrokeWidth = (_objectTransformerCon19 = objectTransformerConfig.rotateIconStrokeWidth) !== null && _objectTransformerCon19 !== void 0 ? _objectTransformerCon19 : rotateIconStrokeWidth;
26411
- borderEnabled = (_objectTransformerCon20 = objectTransformerConfig.borderEnabled) !== null && _objectTransformerCon20 !== void 0 ? _objectTransformerCon20 : borderEnabled;
26412
- borderStroke = (_objectTransformerCon21 = objectTransformerConfig.borderStroke) !== null && _objectTransformerCon21 !== void 0 ? _objectTransformerCon21 : borderStroke;
26413
- borderStrokeWidth = (_objectTransformerCon22 = objectTransformerConfig.borderStrokeWidth) !== null && _objectTransformerCon22 !== void 0 ? _objectTransformerCon22 : borderStrokeWidth;
26414
- borderDash = (_objectTransformerCon23 = objectTransformerConfig.borderDash) !== null && _objectTransformerCon23 !== void 0 ? _objectTransformerCon23 : borderDash;
26415
- borderSpacing = (_objectTransformerCon24 = objectTransformerConfig.borderSpacing) !== null && _objectTransformerCon24 !== void 0 ? _objectTransformerCon24 : borderSpacing;
26416
- anchorFill = (_objectTransformerCon25 = objectTransformerConfig.anchorFill) !== null && _objectTransformerCon25 !== void 0 ? _objectTransformerCon25 : anchorFill;
26417
- anchorStroke = (_objectTransformerCon26 = objectTransformerConfig.anchorStroke) !== null && _objectTransformerCon26 !== void 0 ? _objectTransformerCon26 : anchorStroke;
26418
- anchorStrokeWidth = (_objectTransformerCon27 = objectTransformerConfig.anchorStrokeWidth) !== null && _objectTransformerCon27 !== void 0 ? _objectTransformerCon27 : anchorStrokeWidth;
26419
- anchorSize = (_objectTransformerCon28 = objectTransformerConfig.anchorSize) !== null && _objectTransformerCon28 !== void 0 ? _objectTransformerCon28 : anchorSize;
26420
- anchorCornerRadius = (_objectTransformerCon29 = objectTransformerConfig.anchorCornerRadius) !== null && _objectTransformerCon29 !== void 0 ? _objectTransformerCon29 : anchorCornerRadius;
26421
- anchorStyle = (_objectTransformerCon30 = objectTransformerConfig.anchorStyle) !== null && _objectTransformerCon30 !== void 0 ? _objectTransformerCon30 : anchorStyle;
26422
- anchorSideLongSize = (_objectTransformerCon31 = objectTransformerConfig.anchorSideLongSize) !== null && _objectTransformerCon31 !== void 0 ? _objectTransformerCon31 : anchorSideLongSize;
26423
- anchorSideShortSize = (_objectTransformerCon32 = objectTransformerConfig.anchorSideShortSize) !== null && _objectTransformerCon32 !== void 0 ? _objectTransformerCon32 : anchorSideShortSize;
26424
- anchorSideCornerRadius = (_objectTransformerCon33 = objectTransformerConfig.anchorSideCornerRadius) !== null && _objectTransformerCon33 !== void 0 ? _objectTransformerCon33 : anchorSideCornerRadius;
26425
- anchorShadowColor = (_objectTransformerCon34 = objectTransformerConfig.anchorShadowColor) !== null && _objectTransformerCon34 !== void 0 ? _objectTransformerCon34 : anchorShadowColor;
26426
- anchorShadowBlur = (_objectTransformerCon35 = objectTransformerConfig.anchorShadowBlur) !== null && _objectTransformerCon35 !== void 0 ? _objectTransformerCon35 : anchorShadowBlur;
26427
- anchorShadowOffsetX = (_objectTransformerCon36 = objectTransformerConfig.anchorShadowOffsetX) !== null && _objectTransformerCon36 !== void 0 ? _objectTransformerCon36 : anchorShadowOffsetX;
26428
- anchorShadowOffsetY = (_objectTransformerCon37 = objectTransformerConfig.anchorShadowOffsetY) !== null && _objectTransformerCon37 !== void 0 ? _objectTransformerCon37 : anchorShadowOffsetY;
26429
- keepRatio = (_objectTransformerCon38 = objectTransformerConfig.keepRatio) !== null && _objectTransformerCon38 !== void 0 ? _objectTransformerCon38 : keepRatio;
26430
- centeredScaling = (_objectTransformerCon39 = objectTransformerConfig.centeredScaling) !== null && _objectTransformerCon39 !== void 0 ? _objectTransformerCon39 : centeredScaling;
26431
- enabledAnchors = (_objectTransformerCon40 = objectTransformerConfig.enabledAnchors) !== null && _objectTransformerCon40 !== void 0 ? _objectTransformerCon40 : enabledAnchors;
26432
- flipEnabled = (_objectTransformerCon41 = objectTransformerConfig.flipEnabled) !== null && _objectTransformerCon41 !== void 0 ? _objectTransformerCon41 : flipEnabled;
26433
- ignoreStroke = (_objectTransformerCon42 = objectTransformerConfig.ignoreStroke) !== null && _objectTransformerCon42 !== void 0 ? _objectTransformerCon42 : ignoreStroke;
26434
- boundBoxFunc = (_objectTransformerCon43 = objectTransformerConfig.boundBoxFunc) !== null && _objectTransformerCon43 !== void 0 ? _objectTransformerCon43 : boundBoxFunc;
26435
- useSingleNodeRotation = (_objectTransformerCon44 = objectTransformerConfig.useSingleNodeRotation) !== null && _objectTransformerCon44 !== void 0 ? _objectTransformerCon44 : useSingleNodeRotation;
26436
- shouldOverdrawWholeArea = (_objectTransformerCon45 = objectTransformerConfig.shouldOverdrawWholeArea) !== null && _objectTransformerCon45 !== void 0 ? _objectTransformerCon45 : shouldOverdrawWholeArea;
26437
- moveBoundaryEnabled = (_objectTransformerCon46 = objectTransformerConfig.moveBoundaryEnabled) !== null && _objectTransformerCon46 !== void 0 ? _objectTransformerCon46 : moveBoundaryEnabled;
25560
+ rotateSize = (_objectTransformerCon10 = objectTransformerConfig.rotateSize) !== null && _objectTransformerCon10 !== void 0 ? _objectTransformerCon10 : rotateSize;
25561
+ rotateCornerRadius = (_objectTransformerCon11 = objectTransformerConfig.rotateCornerRadius) !== null && _objectTransformerCon11 !== void 0 ? _objectTransformerCon11 : rotateCornerRadius;
25562
+ borderEnabled = (_objectTransformerCon12 = objectTransformerConfig.borderEnabled) !== null && _objectTransformerCon12 !== void 0 ? _objectTransformerCon12 : borderEnabled;
25563
+ borderStroke = (_objectTransformerCon13 = objectTransformerConfig.borderStroke) !== null && _objectTransformerCon13 !== void 0 ? _objectTransformerCon13 : borderStroke;
25564
+ borderStrokeWidth = (_objectTransformerCon14 = objectTransformerConfig.borderStrokeWidth) !== null && _objectTransformerCon14 !== void 0 ? _objectTransformerCon14 : borderStrokeWidth;
25565
+ borderDash = (_objectTransformerCon15 = objectTransformerConfig.borderDash) !== null && _objectTransformerCon15 !== void 0 ? _objectTransformerCon15 : borderDash;
25566
+ borderSpacing = (_objectTransformerCon16 = objectTransformerConfig.borderSpacing) !== null && _objectTransformerCon16 !== void 0 ? _objectTransformerCon16 : borderSpacing;
25567
+ anchorFill = (_objectTransformerCon17 = objectTransformerConfig.anchorFill) !== null && _objectTransformerCon17 !== void 0 ? _objectTransformerCon17 : anchorFill;
25568
+ anchorStroke = (_objectTransformerCon18 = objectTransformerConfig.anchorStroke) !== null && _objectTransformerCon18 !== void 0 ? _objectTransformerCon18 : anchorStroke;
25569
+ anchorStrokeWidth = (_objectTransformerCon19 = objectTransformerConfig.anchorStrokeWidth) !== null && _objectTransformerCon19 !== void 0 ? _objectTransformerCon19 : anchorStrokeWidth;
25570
+ anchorSize = (_objectTransformerCon20 = objectTransformerConfig.anchorSize) !== null && _objectTransformerCon20 !== void 0 ? _objectTransformerCon20 : anchorSize;
25571
+ anchorCornerRadius = (_objectTransformerCon21 = objectTransformerConfig.anchorCornerRadius) !== null && _objectTransformerCon21 !== void 0 ? _objectTransformerCon21 : anchorCornerRadius;
25572
+ keepRatio = (_objectTransformerCon22 = objectTransformerConfig.keepRatio) !== null && _objectTransformerCon22 !== void 0 ? _objectTransformerCon22 : keepRatio;
25573
+ centeredScaling = (_objectTransformerCon23 = objectTransformerConfig.centeredScaling) !== null && _objectTransformerCon23 !== void 0 ? _objectTransformerCon23 : centeredScaling;
25574
+ enabledAnchors = (_objectTransformerCon24 = objectTransformerConfig.enabledAnchors) !== null && _objectTransformerCon24 !== void 0 ? _objectTransformerCon24 : enabledAnchors;
25575
+ flipEnabled = (_objectTransformerCon25 = objectTransformerConfig.flipEnabled) !== null && _objectTransformerCon25 !== void 0 ? _objectTransformerCon25 : flipEnabled;
25576
+ ignoreStroke = (_objectTransformerCon26 = objectTransformerConfig.ignoreStroke) !== null && _objectTransformerCon26 !== void 0 ? _objectTransformerCon26 : ignoreStroke;
25577
+ boundBoxFunc = (_objectTransformerCon27 = objectTransformerConfig.boundBoxFunc) !== null && _objectTransformerCon27 !== void 0 ? _objectTransformerCon27 : boundBoxFunc;
25578
+ useSingleNodeRotation = (_objectTransformerCon28 = objectTransformerConfig.useSingleNodeRotation) !== null && _objectTransformerCon28 !== void 0 ? _objectTransformerCon28 : useSingleNodeRotation;
25579
+ shouldOverdrawWholeArea = (_objectTransformerCon29 = objectTransformerConfig.shouldOverdrawWholeArea) !== null && _objectTransformerCon29 !== void 0 ? _objectTransformerCon29 : shouldOverdrawWholeArea;
26438
25580
  }
26439
25581
  return {
26440
25582
  isCropper,
@@ -26446,16 +25588,8 @@ var Transformer = class extends _univerjs_core.Disposable {
26446
25588
  rotationSnaps,
26447
25589
  rotationSnapTolerance,
26448
25590
  rotateAnchorOffset,
26449
- rotateAnchorPosition,
26450
- rotateLineEnabled,
26451
25591
  rotateSize,
26452
25592
  rotateCornerRadius,
26453
- rotateFill,
26454
- rotateStroke,
26455
- rotateStrokeWidth,
26456
- rotateIconEnabled,
26457
- rotateIconStroke,
26458
- rotateIconStrokeWidth,
26459
25593
  borderEnabled,
26460
25594
  borderStroke,
26461
25595
  borderStrokeWidth,
@@ -26466,14 +25600,6 @@ var Transformer = class extends _univerjs_core.Disposable {
26466
25600
  anchorStrokeWidth,
26467
25601
  anchorSize,
26468
25602
  anchorCornerRadius,
26469
- anchorStyle,
26470
- anchorSideLongSize,
26471
- anchorSideShortSize,
26472
- anchorSideCornerRadius,
26473
- anchorShadowColor,
26474
- anchorShadowBlur,
26475
- anchorShadowOffsetX,
26476
- anchorShadowOffsetY,
26477
25603
  keepRatio,
26478
25604
  centeredScaling,
26479
25605
  enabledAnchors,
@@ -26481,8 +25607,7 @@ var Transformer = class extends _univerjs_core.Disposable {
26481
25607
  ignoreStroke,
26482
25608
  boundBoxFunc,
26483
25609
  useSingleNodeRotation,
26484
- shouldOverdrawWholeArea,
26485
- moveBoundaryEnabled
25610
+ shouldOverdrawWholeArea
26486
25611
  };
26487
25612
  }
26488
25613
  attachTo(applyObject) {
@@ -26516,7 +25641,7 @@ var Transformer = class extends _univerjs_core.Disposable {
26516
25641
  this._copperSelectedObject = applyObject;
26517
25642
  this._changeStart$.next({
26518
25643
  target: applyObject,
26519
- objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
25644
+ objects: new Map([[applyObject.oKey, applyObject]]),
26520
25645
  type: 0
26521
25646
  });
26522
25647
  }
@@ -26544,7 +25669,7 @@ var Transformer = class extends _univerjs_core.Disposable {
26544
25669
  event
26545
25670
  });
26546
25671
  else this._changeEnd$.next({
26547
- objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
25672
+ objects: new Map([[applyObject.oKey, applyObject]]),
26548
25673
  type: 2,
26549
25674
  offsetX,
26550
25675
  offsetY,
@@ -26591,10 +25716,6 @@ var Transformer = class extends _univerjs_core.Disposable {
26591
25716
  });
26592
25717
  }
26593
25718
  _checkMoveBoundary(moveObject, moveLeft, moveTop, ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight) {
26594
- if (this._getConfig(moveObject).moveBoundaryEnabled === false) return {
26595
- moveLeft,
26596
- moveTop
26597
- };
26598
25719
  const { left, top, width, height } = moveObject;
26599
25720
  let resultMoveLeft = moveLeft;
26600
25721
  let resultMoveTop = moveTop;
@@ -26644,7 +25765,7 @@ var Transformer = class extends _univerjs_core.Disposable {
26644
25765
  moveTop = boundary.moveTop;
26645
25766
  cropper.translate(moveLeft + cropper.left, moveTop + cropper.top);
26646
25767
  this._changing$.next({
26647
- objects: /* @__PURE__ */ new Map([[cropper.oKey, cropper]]),
25768
+ objects: new Map([[cropper.oKey, cropper]]),
26648
25769
  moveX: moveLeft,
26649
25770
  moveY: moveTop,
26650
25771
  type: 1,
@@ -26679,7 +25800,7 @@ var Transformer = class extends _univerjs_core.Disposable {
26679
25800
  } else {
26680
25801
  this._moveFunc(applyObject, type, x, y, keepRatio, isCropper, isGroup);
26681
25802
  this._changing$.next({
26682
- objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
25803
+ objects: new Map([[applyObject.oKey, applyObject]]),
26683
25804
  type: 1,
26684
25805
  offsetX: moveOffsetX,
26685
25806
  offsetY: moveOffsetY
@@ -26926,7 +26047,7 @@ var Transformer = class extends _univerjs_core.Disposable {
26926
26047
  });
26927
26048
  } else {
26928
26049
  this._changeStart$.next({
26929
- objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
26050
+ objects: new Map([[applyObject.oKey, applyObject]]),
26930
26051
  type: 0
26931
26052
  });
26932
26053
  const { width, height, left, top } = applyObject.getState();
@@ -26967,7 +26088,7 @@ var Transformer = class extends _univerjs_core.Disposable {
26967
26088
  } else {
26968
26089
  this._recoverySizeBoundary([applyObject], ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight);
26969
26090
  this._changeEnd$.next({
26970
- objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
26091
+ objects: new Map([[applyObject.oKey, applyObject]]),
26971
26092
  type: 2,
26972
26093
  offsetX,
26973
26094
  offsetY,
@@ -27042,11 +26163,7 @@ var Transformer = class extends _univerjs_core.Disposable {
27042
26163
  _rotateMoving(moveOffsetX, moveOffsetY, centerX, centerY, agentOrigin) {
27043
26164
  const { ancestorScaleX, ancestorScaleY } = this._scene;
27044
26165
  if (this._moveBufferBlocker(moveOffsetX, moveOffsetY)) return;
27045
- const moveSceneX = moveOffsetX / ancestorScaleX + this._viewportScrollX;
27046
- const moveSceneY = moveOffsetY / ancestorScaleY + this._viewportScrollY;
27047
- const startSceneX = this._startOffsetX / ancestorScaleX + this._viewportScrollX;
27048
- const startSceneY = this._startOffsetY / ancestorScaleY + this._viewportScrollY;
27049
- let angle = agentOrigin + radToDeg(Math.atan2(moveSceneY - centerY, moveSceneX - centerX) - Math.atan2(startSceneY - centerY, startSceneX - centerX));
26166
+ 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));
27050
26167
  if (angle < 0) angle = 360 + angle;
27051
26168
  angle %= 360;
27052
26169
  angle = this._smoothAccuracy(angle);
@@ -27103,23 +26220,6 @@ var Transformer = class extends _univerjs_core.Disposable {
27103
26220
  }
27104
26221
  return cursor;
27105
26222
  }
27106
- _createRotateIcon(applyObject, zIndex, left, top) {
27107
- const { rotateSize, rotateIconStroke, rotateIconStrokeWidth, borderStroke } = this._getConfig(applyObject);
27108
- const iconOffset = (rotateSize - ROTATE_ICON_SIZE) / 2;
27109
- return new TransformerRotateIcon(`__SpreadsheetTransformerRotate___ICON_${zIndex}`, {
27110
- zIndex,
27111
- evented: false,
27112
- left: left + iconOffset,
27113
- top: top + iconOffset,
27114
- width: ROTATE_ICON_SIZE,
27115
- height: ROTATE_ICON_SIZE,
27116
- fill: null,
27117
- stroke: rotateIconStroke !== null && rotateIconStroke !== void 0 ? rotateIconStroke : borderStroke,
27118
- strokeWidth: rotateIconStrokeWidth,
27119
- strokeLineCap: "round",
27120
- strokeLineJoin: "round"
27121
- });
27122
- }
27123
26223
  _getCopperAnchorPosition(type, height, width, applyObject) {
27124
26224
  const { borderStrokeWidth, borderSpacing, anchorSize } = this._getConfig(applyObject);
27125
26225
  let left = 0;
@@ -27166,18 +26266,17 @@ var Transformer = class extends _univerjs_core.Disposable {
27166
26266
  };
27167
26267
  }
27168
26268
  _getRotateAnchorPosition(type, height, width, applyObject) {
27169
- const { rotateAnchorOffset, rotateAnchorPosition, rotateSize, borderStrokeWidth, borderSpacing, anchorSize } = this._getConfig(applyObject);
27170
- const isBottomRotateAnchor = rotateAnchorPosition === "bottom";
26269
+ const { rotateAnchorOffset, rotateSize, borderStrokeWidth, borderSpacing, anchorSize } = this._getConfig(applyObject);
27171
26270
  let left = -anchorSize / 2;
27172
26271
  let top = -anchorSize / 2;
27173
26272
  switch (type) {
27174
26273
  case "__SpreadsheetTransformerRotate__":
27175
26274
  left = width / 2 - rotateSize / 2;
27176
- top = isBottomRotateAnchor ? height + rotateAnchorOffset + borderSpacing + borderStrokeWidth * 2 : -rotateAnchorOffset - borderSpacing - borderStrokeWidth * 2 - rotateSize;
26275
+ top = -rotateAnchorOffset - borderSpacing - borderStrokeWidth * 2 - rotateSize;
27177
26276
  break;
27178
26277
  case "__SpreadsheetTransformerRotateLine__":
27179
26278
  left = width / 2;
27180
- top = isBottomRotateAnchor ? height + borderSpacing + borderStrokeWidth : -rotateAnchorOffset - borderSpacing - borderStrokeWidth;
26279
+ top = -rotateAnchorOffset - borderSpacing - borderStrokeWidth;
27181
26280
  break;
27182
26281
  case "__SpreadsheetTransformerResizeLT__":
27183
26282
  left += -borderSpacing - borderStrokeWidth;
@@ -27217,43 +26316,21 @@ var Transformer = class extends _univerjs_core.Disposable {
27217
26316
  top
27218
26317
  };
27219
26318
  }
27220
- _isMiddleAnchor(type) {
27221
- return type === "__SpreadsheetTransformerResizeCT__" || type === "__SpreadsheetTransformerResizeLM__" || type === "__SpreadsheetTransformerResizeRM__" || type === "__SpreadsheetTransformerResizeCB__";
27222
- }
27223
- _getResizeAnchorProps(type, applyObject) {
27224
- const { anchorSize, anchorCornerRadius, anchorStyle, anchorSideLongSize, anchorSideShortSize, anchorSideCornerRadius } = this._getConfig(applyObject);
27225
- if (anchorStyle !== "canva" || !this._isMiddleAnchor(type)) return {
27226
- width: anchorSize,
27227
- height: anchorSize,
27228
- radius: anchorStyle === "canva" ? anchorSize / 2 : anchorCornerRadius
27229
- };
27230
- const isHorizontal = type === "__SpreadsheetTransformerResizeCT__" || type === "__SpreadsheetTransformerResizeCB__";
27231
- return {
27232
- width: isHorizontal ? anchorSideLongSize : anchorSideShortSize,
27233
- height: isHorizontal ? anchorSideShortSize : anchorSideLongSize,
27234
- radius: anchorSideCornerRadius
27235
- };
27236
- }
27237
26319
  _createResizeAnchor(type, applyObject, zIndex) {
27238
26320
  const { height = 0, width = 0, scaleX = 1, scaleY = 1 } = applyObject.getState();
27239
- const { anchorFill, anchorStroke, anchorStrokeWidth, anchorSize, anchorShadowColor, anchorShadowBlur, anchorShadowOffsetX, anchorShadowOffsetY } = this._getConfig(applyObject);
26321
+ const { anchorFill, anchorStroke, anchorStrokeWidth, anchorCornerRadius, anchorSize } = this._getConfig(applyObject);
27240
26322
  const { left, top } = this._getRotateAnchorPosition(type, height, width, applyObject);
27241
- const anchorProps = this._getResizeAnchorProps(type, applyObject);
27242
26323
  const cursor = this._getRotateAnchorCursor(type);
27243
- const anchor = new TransformerAnchor(`${type}_${zIndex}`, {
26324
+ const anchor = new Rect(`${type}_${zIndex}`, {
27244
26325
  zIndex: zIndex - 1,
27245
26326
  fill: anchorFill,
27246
26327
  stroke: anchorStroke,
27247
26328
  strokeWidth: anchorStrokeWidth,
27248
- width: anchorProps.width,
27249
- height: anchorProps.height,
27250
- radius: anchorProps.radius,
27251
- left: left + (anchorSize - anchorProps.width) / 2,
27252
- top: top + (anchorSize - anchorProps.height) / 2,
27253
- shadowColor: anchorShadowColor,
27254
- shadowBlur: anchorShadowBlur,
27255
- shadowOffsetX: anchorShadowOffsetX,
27256
- shadowOffsetY: anchorShadowOffsetY
26329
+ width: anchorSize,
26330
+ height: anchorSize,
26331
+ radius: anchorCornerRadius,
26332
+ left,
26333
+ top
27257
26334
  });
27258
26335
  this._attachHover(anchor, cursor, "default");
27259
26336
  return anchor;
@@ -27501,7 +26578,7 @@ var Transformer = class extends _univerjs_core.Disposable {
27501
26578
  _createControl(applyObject, isSkipOnCropper = true) {
27502
26579
  const { left = 0, top = 0, height = 0, width = 0 } = applyObject.getState();
27503
26580
  const angle = applyObject.angle;
27504
- const { isCropper, resizeEnabled, rotateEnabled, rotateAnchorOffset, rotateLineEnabled, rotateSize, rotateCornerRadius, rotateFill, rotateStroke, rotateStrokeWidth, rotateIconEnabled, anchorShadowColor, anchorShadowBlur, anchorShadowOffsetX, anchorShadowOffsetY, borderEnabled, borderStroke, borderStrokeWidth, borderSpacing, enabledAnchors } = this._getConfig(applyObject);
26581
+ const { isCropper, resizeEnabled, rotateEnabled, rotateAnchorOffset, rotateSize, rotateCornerRadius, borderEnabled, borderStroke, borderStrokeWidth, borderSpacing, enabledAnchors } = this._getConfig(applyObject);
27505
26582
  if (isSkipOnCropper && isCropper) return;
27506
26583
  const oKey = applyObject.oKey;
27507
26584
  const zIndex = this._selectedObjectMap.size + applyObject.maxZIndex + DEFAULT_CONTROL_PLUS_INDEX;
@@ -27532,26 +26609,19 @@ var Transformer = class extends _univerjs_core.Disposable {
27532
26609
  });
27533
26610
  const { left: rotateLeft, top: rotateTop } = this._getRotateAnchorPosition("__SpreadsheetTransformerRotate__", height, width, applyObject);
27534
26611
  const cursor = this._getRotateAnchorCursor("__SpreadsheetTransformerRotate__");
27535
- const rotate = new TransformerAnchor(`__SpreadsheetTransformerRotate___${zIndex}`, {
26612
+ const rotate = new Rect(`__SpreadsheetTransformerRotate___${zIndex}`, {
27536
26613
  zIndex: zIndex - 1,
27537
26614
  left: rotateLeft,
27538
26615
  top: rotateTop,
27539
26616
  height: rotateSize,
27540
26617
  width: rotateSize,
27541
26618
  radius: rotateCornerRadius,
27542
- fill: rotateFill,
27543
- strokeWidth: rotateStrokeWidth !== null && rotateStrokeWidth !== void 0 ? rotateStrokeWidth : borderStrokeWidth * 2,
27544
- stroke: rotateStroke !== null && rotateStroke !== void 0 ? rotateStroke : borderStroke,
27545
- shadowColor: anchorShadowColor,
27546
- shadowBlur: anchorShadowBlur,
27547
- shadowOffsetX: anchorShadowOffsetX,
27548
- shadowOffsetY: anchorShadowOffsetY
26619
+ strokeWidth: borderStrokeWidth * 2,
26620
+ stroke: borderStroke
27549
26621
  });
27550
26622
  this._attachEventToRotate(rotate, applyObject);
27551
26623
  this._attachHover(rotate, cursor, "default");
27552
- if (rotateLineEnabled) groupElements.push(rotateLine);
27553
- groupElements.push(rotate);
27554
- if (rotateIconEnabled) groupElements.push(this._createRotateIcon(applyObject, zIndex, rotateLeft, rotateTop));
26624
+ groupElements.push(rotateLine, rotate);
27555
26625
  }
27556
26626
  }
27557
26627
  if (resizeEnabled) for (let i = 0, len = enabledAnchors.length; i < len; i++) {