@univerjs/engine-render 1.0.0-alpha.6 → 1.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -13018,8 +13018,14 @@ function baseAdjustability(content, width) {
13018
13018
  function createSkeletonWordGlyph(content, config, glyphWidth) {
13019
13019
  return _createSkeletonWordOrLetter(1, content, config, glyphWidth);
13020
13020
  }
13021
- function createSkeletonLetterGlyph(content, config, glyphWidth, glyphInfo) {
13022
- return _createSkeletonWordOrLetter(0, content, config, glyphWidth, glyphInfo);
13021
+ function createSkeletonLetterGlyph(content, config, glyphMetrics, glyphInfo) {
13022
+ const glyphWidth = typeof glyphMetrics === "number" ? glyphMetrics : glyphMetrics === null || glyphMetrics === void 0 ? void 0 : glyphMetrics.width;
13023
+ const glyph = _createSkeletonWordOrLetter(0, content, config, glyphWidth, glyphInfo);
13024
+ if (typeof glyphMetrics === "object") {
13025
+ if (glyphMetrics.ascent != null) glyph.bBox.ba = glyph.bBox.aba = glyphMetrics.ascent;
13026
+ if (glyphMetrics.descent != null) glyph.bBox.bd = glyph.bBox.abd = glyphMetrics.descent;
13027
+ }
13028
+ return glyph;
13023
13029
  }
13024
13030
  function createSkeletonTabGlyph(config, glyphWidth) {
13025
13031
  return _createSkeletonWordOrLetter(4, DataStreamTreeTokenType.TAB, config, glyphWidth);
@@ -13214,7 +13220,7 @@ function glyphShrinkLeft(glyph, amount) {
13214
13220
 
13215
13221
  //#endregion
13216
13222
  //#region src/components/docs/layout/model/line.ts
13217
- function createSkeletonLine(paragraphIndex, lineType, lineBoundingBox, columnWidth, lineIndex = 0, isParagraphStart = false, paragraphConfig, page, headerPage, footerPage) {
13223
+ function createSkeletonLine(paragraphIndex, lineType, lineBoundingBox, columnWidth, lineIndex = 0, isParagraphStart = false, paragraphConfig, page, headerPage, footerPage, columnLeft = 0, sectionTop = 0) {
13218
13224
  var _page$skeDrawings, _page$skeTables;
13219
13225
  const { lineHeight = 15.6, lineTop = 0, contentHeight = 0, paddingLeft = 0, paddingRight = 0, paddingTop = 0, paddingBottom = 0, marginTop = 0, spaceBelowApply = 0 } = lineBoundingBox;
13220
13226
  const { skeTablesInParagraph } = paragraphConfig;
@@ -13239,35 +13245,36 @@ function createSkeletonLine(paragraphIndex, lineType, lineBoundingBox, columnWid
13239
13245
  }
13240
13246
  const affectSkeDrawings = new Map(Array.from(pageSkeDrawings).filter(([_, drawing]) => drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.INLINE && drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.WRAP_NONE));
13241
13247
  const wrapTypeTables = new Map(Array.from(pageSkeTables).filter(([_, table]) => table.tableSource.textWrap === TableTextWrapType.WRAP));
13242
- lineSke.divides = lineHeight <= .01 ? [__getDivideSKe(0, columnWidth)] : _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, affectSkeDrawings, headersDrawings, footersDrawings, wrapTypeTables);
13248
+ lineSke.divides = lineHeight <= .01 ? [__getDivideSKe(0, columnWidth)] : _calculateDividesByDrawings(lineHeight, sectionTop + lineTop, columnLeft, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, affectSkeDrawings, headersDrawings, footersDrawings, wrapTypeTables);
13243
13249
  for (const divide of lineSke.divides) divide.parent = lineSke;
13244
13250
  return lineSke;
13245
13251
  }
13246
- function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, headerPage, footerPage, columnLeft = 0, columnWidth = 0) {
13247
- let maxTop = lineTop;
13252
+ function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, headerPage, footerPage, columnLeft = 0, columnWidth = 0, sectionTop = 0) {
13253
+ const absoluteLineTop = sectionTop + lineTop;
13254
+ let maxTop = absoluteLineTop;
13248
13255
  const pageSkeDrawings = page.skeDrawings;
13249
13256
  const skeNonWrapTables = new Map(Array.from(page.skeTables).filter(([_, table]) => table.tableSource.textWrap === TableTextWrapType.NONE));
13250
13257
  const headersDrawings = headerPage === null || headerPage === void 0 ? void 0 : headerPage.skeDrawings;
13251
13258
  const footersDrawings = footerPage === null || footerPage === void 0 ? void 0 : footerPage.skeDrawings;
13252
13259
  if (headerPage && headersDrawings) headersDrawings.forEach((drawing) => {
13253
- const top = _getLineTopWidthWrapTopBottom(translateHeaderFooterDrawingPosition(drawing, headerPage, page, true), lineHeight, lineTop);
13260
+ const top = _getLineTopWidthWrapTopBottom(translateHeaderFooterDrawingPosition(drawing, headerPage, page, true), lineHeight, absoluteLineTop, columnLeft, columnWidth);
13254
13261
  if (top) maxTop = Math.max(maxTop, top);
13255
13262
  });
13256
13263
  if (footerPage && footersDrawings) footersDrawings.forEach((drawing) => {
13257
- const top = _getLineTopWidthWrapTopBottom(translateHeaderFooterDrawingPosition(drawing, footerPage, page, false), lineHeight, lineTop);
13264
+ const top = _getLineTopWidthWrapTopBottom(translateHeaderFooterDrawingPosition(drawing, footerPage, page, false), lineHeight, absoluteLineTop, columnLeft, columnWidth);
13258
13265
  if (top) maxTop = Math.max(maxTop, top);
13259
13266
  });
13260
13267
  pageSkeDrawings === null || pageSkeDrawings === void 0 || pageSkeDrawings.forEach((drawing) => {
13261
- const top = _getLineTopWidthWrapTopBottom(drawing, lineHeight, lineTop);
13268
+ const top = _getLineTopWidthWrapTopBottom(drawing, lineHeight, absoluteLineTop, columnLeft, columnWidth);
13262
13269
  if (top) maxTop = Math.max(maxTop, top);
13263
- const blockingWrapTop = _getLineTopWithFullColumnWrap(drawing, lineHeight, lineTop, columnLeft, columnWidth);
13270
+ const blockingWrapTop = _getLineTopWithFullColumnWrap(drawing, lineHeight, absoluteLineTop, columnLeft, columnWidth);
13264
13271
  if (blockingWrapTop) maxTop = Math.max(maxTop, blockingWrapTop);
13265
13272
  });
13266
13273
  skeNonWrapTables === null || skeNonWrapTables === void 0 || skeNonWrapTables.forEach((table) => {
13267
- const top = _getLineTopWidthWrapNone(table, lineHeight, lineTop);
13274
+ const top = _getLineTopWidthWrapNone(table, lineHeight, absoluteLineTop, columnLeft, columnWidth);
13268
13275
  if (top) maxTop = Math.max(maxTop, top);
13269
13276
  });
13270
- return maxTop;
13277
+ return maxTop - sectionTop;
13271
13278
  }
13272
13279
  function _getLineTopWithFullColumnWrap(drawing, lineHeight, lineTop, columnLeft, columnWidth) {
13273
13280
  if (columnWidth <= 0) return;
@@ -13300,15 +13307,25 @@ function _getLineTopWithFullColumnWrap(drawing, lineHeight, lineTop, columnLeft,
13300
13307
  if (split.left > 0 || split.left + split.width < columnWidth) return;
13301
13308
  return bottom;
13302
13309
  }
13303
- function _getLineTopWidthWrapNone(table, lineHeight, lineTop) {
13304
- const { top, height } = table;
13310
+ function _getLineTopWidthWrapNone(table, lineHeight, lineTop, columnLeft, columnWidth) {
13311
+ const { top, height, left, width } = table;
13312
+ if (columnWidth > 0 && (left + width <= columnLeft || left >= columnLeft + columnWidth)) return;
13305
13313
  if (top + height < lineTop || top > lineHeight + lineTop) return;
13306
13314
  return top + height;
13307
13315
  }
13308
- function _getLineTopWidthWrapTopBottom(drawing, lineHeight, lineTop) {
13316
+ function _getLineTopWidthWrapTopBottom(drawing, lineHeight, lineTop, columnLeft, columnWidth) {
13309
13317
  const { aTop, height, aLeft, width, angle = 0, drawingOrigin } = drawing;
13310
13318
  const { layoutType, distT = 0, distB = 0 } = drawingOrigin;
13311
13319
  if (layoutType !== PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) return;
13320
+ if (columnWidth > 0) {
13321
+ var _bounds$left, _bounds$width;
13322
+ const bounds = angle === 0 ? {
13323
+ left: aLeft,
13324
+ width
13325
+ } : getBoundingBox(angle, aLeft, width, aTop, height);
13326
+ const drawingLeft = (_bounds$left = bounds.left) !== null && _bounds$left !== void 0 ? _bounds$left : aLeft;
13327
+ if (drawingLeft + ((_bounds$width = bounds.width) !== null && _bounds$width !== void 0 ? _bounds$width : width) <= columnLeft || drawingLeft >= columnLeft + columnWidth) return;
13328
+ }
13312
13329
  if (angle === 0) {
13313
13330
  const newAtop = aTop - distT;
13314
13331
  const newHeight = distT + height + distB;
@@ -13321,7 +13338,7 @@ function _getLineTopWidthWrapTopBottom(drawing, lineHeight, lineTop) {
13321
13338
  if (sTop + sHeight < lineTop || sTop > lineHeight + lineTop) return;
13322
13339
  return sTop + sHeight;
13323
13340
  }
13324
- function _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, paragraphNonInlineSkeDrawings, headersDrawings, footersDrawings, wrapTypeTables) {
13341
+ function _calculateDividesByDrawings(lineHeight, lineTop, columnLeft, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, paragraphNonInlineSkeDrawings, headersDrawings, footersDrawings, wrapTypeTables) {
13325
13342
  const drawingsMix = [];
13326
13343
  drawingsMix.push({
13327
13344
  left: 0,
@@ -13331,21 +13348,21 @@ function _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLe
13331
13348
  width: paddingRight
13332
13349
  });
13333
13350
  if (headerPage && headersDrawings) headersDrawings.forEach((drawing) => {
13334
- const split = _calculateSplit(translateHeaderFooterDrawingPosition(drawing, headerPage, page, true), lineHeight, lineTop, columnWidth);
13351
+ const split = _calculateSplit(translateHeaderFooterDrawingPosition(drawing, headerPage, page, true), lineHeight, lineTop, columnLeft, columnWidth);
13335
13352
  if (split) drawingsMix.push(split);
13336
13353
  });
13337
13354
  if (footerPage && footersDrawings) footersDrawings.forEach((drawing) => {
13338
- const split = _calculateSplit(translateHeaderFooterDrawingPosition(drawing, footerPage, page, false), lineHeight, lineTop, columnWidth);
13355
+ const split = _calculateSplit(translateHeaderFooterDrawingPosition(drawing, footerPage, page, false), lineHeight, lineTop, columnLeft, columnWidth);
13339
13356
  if (split) drawingsMix.push(split);
13340
13357
  });
13341
13358
  paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 || paragraphNonInlineSkeDrawings.forEach((drawing) => {
13342
- const split = _calculateSplit(drawing, lineHeight, lineTop, columnWidth);
13359
+ const split = _calculateSplit(drawing, lineHeight, lineTop, columnLeft, columnWidth);
13343
13360
  if (split) drawingsMix.push(split);
13344
13361
  });
13345
13362
  if (wrapTypeTables && wrapTypeTables.size > 0) wrapTypeTables.forEach((table) => {
13346
13363
  const { left, top, width, height, tableSource } = table;
13347
13364
  const { dist } = tableSource;
13348
- const split = __getSplitWidthNoAngle(top, height, left, width, lineTop, lineHeight, columnWidth, dist);
13365
+ const split = __getSplitWidthNoAngle(top, height, left - columnLeft, width, lineTop, lineHeight, columnWidth, dist);
13349
13366
  if (split) drawingsMix.push(split);
13350
13367
  });
13351
13368
  return _calculateDivideByDrawings(columnWidth, drawingsMix);
@@ -13363,7 +13380,7 @@ function collisionDetection(floatObject, lineHeight, lineTop, columnLeft, column
13363
13380
  if (left + width < columnLeft || left > columnLeft + columnWidth) return false;
13364
13381
  return true;
13365
13382
  }
13366
- function _calculateSplit(drawing, lineHeight, lineTop, columnWidth) {
13383
+ function _calculateSplit(drawing, lineHeight, lineTop, columnLeft, columnWidth) {
13367
13384
  const { aTop, height, aLeft, width, angle = 0, drawingOrigin } = drawing;
13368
13385
  const { layoutType } = drawingOrigin;
13369
13386
  if (layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) return;
@@ -13376,6 +13393,9 @@ function _calculateSplit(drawing, lineHeight, lineTop, columnWidth) {
13376
13393
  const point = lineTo[i];
13377
13394
  points.push(new Vector2(point[0], point[1]));
13378
13395
  }
13396
+ points.forEach((point) => {
13397
+ point.x -= columnLeft;
13398
+ });
13379
13399
  if (angle !== 0) {
13380
13400
  const transform = new Transform().rotate(angle);
13381
13401
  for (let i = 0; i < points.length; i++) {
@@ -13392,8 +13412,8 @@ function _calculateSplit(drawing, lineHeight, lineTop, columnWidth) {
13392
13412
  distB,
13393
13413
  distR
13394
13414
  };
13395
- if (angle === 0) return __getSplitWidthNoAngle(aTop, height, aLeft, width, lineTop, lineHeight, columnWidth, dist, layoutType, wrapText);
13396
- const boundingBox = getBoundingBox(angle, aLeft, width, aTop, height);
13415
+ if (angle === 0) return __getSplitWidthNoAngle(aTop, height, aLeft - columnLeft, width, lineTop, lineHeight, columnWidth, dist, layoutType, wrapText);
13416
+ const boundingBox = getBoundingBox(angle, aLeft - columnLeft, width, aTop, height);
13397
13417
  if (layoutType === PositionedObjectLayoutType.WRAP_SQUARE) {
13398
13418
  const { left: sLeft, width: sWidth, top: sTop, height: sHeight } = boundingBox;
13399
13419
  return __getSplitWidthNoAngle(sTop, sHeight, sLeft, sWidth, lineTop, lineHeight, columnWidth, dist, layoutType, wrapText);
@@ -13707,7 +13727,7 @@ function createTableSkeleton(ctx, curPage, viewModel, tableNode, sectionBreakCon
13707
13727
  tableSkeleton.height = rowTop;
13708
13728
  applyMergedCellSpanHeights(tableSkeleton);
13709
13729
  const { pageWidth, marginLeft = 0, marginRight = 0 } = curPage;
13710
- tableSkeleton.left = _getTableLeft(pageWidth - marginLeft - marginRight, tableWidth, table.align, table.indent);
13730
+ tableSkeleton.left = getTableLeft(pageWidth - marginLeft - marginRight, tableWidth, table.align, table.indent);
13711
13731
  return tableSkeleton;
13712
13732
  }
13713
13733
  function rollbackListCache(listLevel, table) {
@@ -13751,7 +13771,7 @@ function createTableSkeletons(ctx, curPage, viewModel, tableNode, sectionBreakCo
13751
13771
  function updateTableSkeletonsPosition(cache, curPage, skeTables, table) {
13752
13772
  const { pageWidth, marginLeft = 0, marginRight = 0 } = curPage;
13753
13773
  const { tableWidth } = cache;
13754
- const tableLeft = _getTableLeft(pageWidth - marginLeft - marginRight, tableWidth, table.align, table.indent);
13774
+ const tableLeft = getTableLeft(pageWidth - marginLeft - marginRight, tableWidth, table.align, table.indent);
13755
13775
  let tableIndex = 0;
13756
13776
  for (const tableSkeleton of skeTables) {
13757
13777
  applyMergedCellSpanHeights(tableSkeleton);
@@ -13956,7 +13976,7 @@ function findMergedMasterCell(table, row, col) {
13956
13976
  function isCoveredTableCell(cellConfig) {
13957
13977
  return (cellConfig === null || cellConfig === void 0 ? void 0 : cellConfig.rowSpan) === 0 || (cellConfig === null || cellConfig === void 0 ? void 0 : cellConfig.columnSpan) === 0;
13958
13978
  }
13959
- function _getTableLeft(pageWidth, tableWidth, align, indent = { v: 0 }) {
13979
+ function getTableLeft(pageWidth, tableWidth, align, indent = { v: 0 }) {
13960
13980
  switch (align) {
13961
13981
  case TableAlignmentType.START: return indent.v;
13962
13982
  case TableAlignmentType.END: return Math.max(0, pageWidth - tableWidth);
@@ -14094,7 +14114,7 @@ function _popHyphenSlice(divide) {
14094
14114
  }
14095
14115
  return glyphGroup;
14096
14116
  }
14097
- function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal", defaultSpanLineHeight) {
14117
+ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal", defaultSpanMetrics) {
14098
14118
  const divideInfo = getLastNotFullDivideInfo(getLastPage(pages));
14099
14119
  if (divideInfo) {
14100
14120
  var _divide$glyphGroup;
@@ -14121,7 +14141,8 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
14121
14141
  else if (!isLast && (divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0 && glyphGroup.length === 1 && glyphGroup[0].streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyphGroup[0].width > divide.width) {
14122
14142
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
14123
14143
  updateDivideInfo(divide, { breakType: breakPointType });
14124
- } else if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0) {
14144
+ } else if (!isLast && (divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0) _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanMetrics);
14145
+ else if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0) {
14125
14146
  const sliceGlyphGroup = [];
14126
14147
  while (glyphGroup.length) {
14127
14148
  sliceGlyphGroup.push(glyphGroup.shift());
@@ -14131,22 +14152,22 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
14131
14152
  }
14132
14153
  }
14133
14154
  if (sliceGlyphGroup.length > 0) addGlyphToDivide(divide, sliceGlyphGroup, preOffsetLeft);
14134
- if (glyphGroup.length) _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, false, breakPointType, defaultSpanLineHeight);
14155
+ if (glyphGroup.length) _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, false, breakPointType, defaultSpanMetrics);
14135
14156
  } else if (hyphenLineCount > consecutiveHyphenLimit) {
14136
14157
  const hyphenSliceGlyphGroup = _popHyphenSlice(divide);
14137
14158
  if (hyphenSliceGlyphGroup.length > 0) {
14138
14159
  updateDivideInfo(divide, { breakType: "Normal" });
14139
14160
  _divideOperator(ctx, hyphenSliceGlyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, "Hyphen");
14140
14161
  }
14141
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
14142
- } else _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
14162
+ _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanMetrics);
14163
+ } else _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanMetrics);
14143
14164
  } else if (isLast && hyphenationZone && hyphenationZone > 0 && preOffsetLeft >= divide.width - hyphenationZone && breakPointType === "Hyphen" && divide.breakType === "Normal") {
14144
14165
  updateDivideInfo(divide, { isFull: true });
14145
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
14166
+ _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanMetrics);
14146
14167
  } else {
14147
14168
  const currentLine = divide.parent;
14148
14169
  const maxBox = __maxFontBoundingBoxByGlyphGroup(glyphGroup);
14149
- if (currentLine && __isZeroWidthNonFlowFloatingAnchorLine(__getGlyphGroupByLine(currentLine), paragraphConfig.paragraphNonInlineSkeDrawings) && __hasFlowGlyph(glyphGroup)) {
14170
+ if (currentLine && __isPositionedCustomBlockOnlyLine(__getGlyphGroupByLine(currentLine), paragraphConfig.paragraphNonInlineSkeDrawings) && __hasFlowGlyph(glyphGroup)) {
14150
14171
  for (const lineDivide of currentLine.divides) updateDivideInfo(lineDivide, { isFull: true });
14151
14172
  _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, false, breakPointType);
14152
14173
  return;
@@ -14165,7 +14186,10 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
14165
14186
  startIndex = 2;
14166
14187
  } else newGlyphGroup = [spanGroupCached[0]];
14167
14188
  const { paragraphStart: lineIsStart } = currentLine.parent.lines.pop();
14168
- _lineOperator(ctx, newGlyphGroup, pages, sectionBreakConfig, paragraphConfig, lineIsStart, breakPointType, boundingBoxAscent + boundingBoxDescent);
14189
+ _lineOperator(ctx, newGlyphGroup, pages, sectionBreakConfig, paragraphConfig, lineIsStart, breakPointType, {
14190
+ lineHeight: boundingBoxAscent + boundingBoxDescent,
14191
+ hasInlineCustomBlock: glyphGroup.some((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0)
14192
+ });
14169
14193
  for (let i = startIndex; i < spanGroupCached.length; i++) _divideOperator(ctx, [spanGroupCached[i]], pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText);
14170
14194
  _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
14171
14195
  return;
@@ -14187,9 +14211,9 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
14187
14211
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
14188
14212
  updateDivideInfo(divide, { breakType: breakPointType });
14189
14213
  }
14190
- } else _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
14214
+ } else _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanMetrics);
14191
14215
  }
14192
- function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal", defaultGlyphLineHeight) {
14216
+ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal", defaultSpanMetrics) {
14193
14217
  var _originParagraphStyle, _originParagraphStyle2, _skeHeaders$get, _skeFooters$get;
14194
14218
  let lastPage = getLastPage(pages);
14195
14219
  let columnInfo = getLastNotFullColumnInfo(lastPage);
@@ -14220,7 +14244,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
14220
14244
  const preLine = getLastLineByColumn(column);
14221
14245
  const ascent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.ba));
14222
14246
  const descent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.bd));
14223
- const glyphLineHeight = defaultGlyphLineHeight || ascent + descent;
14247
+ const glyphLineHeight = (defaultSpanMetrics === null || defaultSpanMetrics === void 0 ? void 0 : defaultSpanMetrics.lineHeight) || ascent + descent;
14224
14248
  const { paragraphStyle: originParagraphStyle = {}, paragraphNonInlineSkeDrawings, skeTablesInParagraph, skeHeaders, skeFooters, pDrawingAnchor, paragraphIndex } = paragraphConfig;
14225
14249
  const isZeroWidthNonFlowFloatingAnchorLine = __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings);
14226
14250
  const { namedStyleType } = originParagraphStyle;
@@ -14231,7 +14255,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
14231
14255
  spaceBelow: (_originParagraphStyle2 = originParagraphStyle.spaceBelow) !== null && _originParagraphStyle2 !== void 0 ? _originParagraphStyle2 : namedStyle === null || namedStyle === void 0 ? void 0 : namedStyle.spaceBelow
14232
14256
  };
14233
14257
  const { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(sectionBreakConfig, paragraphConfig);
14234
- const hasInlineCustomBlock = glyphGroup.some((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0);
14258
+ const hasInlineCustomBlock = (defaultSpanMetrics === null || defaultSpanMetrics === void 0 ? void 0 : defaultSpanMetrics.hasInlineCustomBlock) || glyphGroup.some((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0);
14235
14259
  const positionedCustomBlockOnly = glyphGroup.length > 0 && paragraphNonInlineSkeDrawings != null && paragraphNonInlineSkeDrawings.size > 0 && glyphGroup.every((glyph) => {
14236
14260
  if (!glyph) return false;
14237
14261
  if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) return [...paragraphNonInlineSkeDrawings.values()].some((drawing) => drawing.drawingId === glyph.drawingId);
@@ -14292,12 +14316,12 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
14292
14316
  var _pDrawingAnchor$get2;
14293
14317
  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);
14294
14318
  }
14295
- const calculatedLineTop = positionedCustomBlockOnly ? lineTop : calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage);
14319
+ const calculatedLineTop = positionedCustomBlockOnly ? lineTop : calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage, column.left, column.width, section.top);
14296
14320
  const previousTopBottomCustomBlockFlowBottom = deferredTopBottomAnchorDrawings.length > 0 ? paragraphConfig.topBottomCustomBlockFlowBottom : void 0;
14297
14321
  const newLineTop = previousTopBottomCustomBlockFlowBottom == null ? calculatedLineTop : Math.max(calculatedLineTop, previousTopBottomCustomBlockFlowBottom);
14298
14322
  if (lineHeight + newLineTop - section.height > LINE_LAYOUT_OVERFLOW_TOLERANCE && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
14299
14323
  setColumnFullState(column, true);
14300
- _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
14324
+ _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanMetrics);
14301
14325
  if (isParagraphFirstShapedText && paragraphNonInlineSkeDrawings && paragraphNonInlineSkeDrawings.size > 0) for (const drawing of paragraphNonInlineSkeDrawings.values()) {
14302
14326
  if (lastPage.skeDrawings.has(drawing.drawingId)) lastPage.skeDrawings.delete(drawing.drawingId);
14303
14327
  if (ctx.floatObjectsCache.has(drawing.drawingId)) {
@@ -14325,16 +14349,16 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
14325
14349
  paddingBottom,
14326
14350
  marginTop,
14327
14351
  spaceBelowApply
14328
- }, column.width, lineIndex, isParagraphFirstShapedText, paragraphConfig, lastPage, headerPage, footerPage);
14352
+ }, column.width, lineIndex, isParagraphFirstShapedText, paragraphConfig, lastPage, headerPage, footerPage, column.left, section.top);
14329
14353
  column.lines.push(newLine);
14330
14354
  newLine.parent = column;
14331
14355
  const blockAnchorTop = deferredTopBottomAnchorDrawings.length > 0 ? newLineTop : lineTop;
14332
14356
  createAndUpdateBlockAnchor(paragraphIndex, newLine, blockAnchorTop, pDrawingAnchor);
14333
14357
  if (deferredTopBottomAnchorDrawings.length > 0) {
14334
- __updateAndPositionDrawings(ctx, newLineTop, lineHeight, column, deferredTopBottomAnchorDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, blockAnchorTop, paragraphAnchorLeft, true, true);
14335
- __updateTopBottomCustomBlockFlowBottom(paragraphConfig, deferredTopBottomAnchorDrawings);
14358
+ __updateAndPositionDrawings(ctx, newLineTop, lineHeight, column, deferredTopBottomAnchorDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, blockAnchorTop, paragraphAnchorLeft, false, true);
14359
+ __updateTopBottomCustomBlockFlowBottom(paragraphConfig, deferredTopBottomAnchorDrawings, section.top);
14336
14360
  }
14337
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
14361
+ _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanMetrics);
14338
14362
  if (deferredInlineGroupAnchorDrawings.length > 0) {
14339
14363
  var _pDrawingAnchor$get3;
14340
14364
  __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);
@@ -14385,18 +14409,21 @@ function __updateWrapTablePosition(ctx, table, lineTop, lineHeight, column, para
14385
14409
  table.left = left;
14386
14410
  }
14387
14411
  function __getWrapTablePosition(table, column, lineTop, lineHeight, drawingAnchorTop) {
14388
- var _column$parent, _getPositionHorizon, _getPositionVertical;
14412
+ var _column$parent, _column$parent$top, _column$parent2, _getPositionHorizon, _getPositionVertical;
14389
14413
  const page = (_column$parent = column.parent) === null || _column$parent === void 0 ? void 0 : _column$parent.parent;
14414
+ const sectionTop = (_column$parent$top = (_column$parent2 = column.parent) === null || _column$parent2 === void 0 ? void 0 : _column$parent2.top) !== null && _column$parent$top !== void 0 ? _column$parent$top : 0;
14390
14415
  if (page == null) return;
14391
14416
  const isPageBreak = __checkPageBreak(column);
14392
14417
  const { tableSource, width, height } = table;
14393
14418
  const { positionH, positionV } = tableSource.position;
14394
14419
  return {
14395
14420
  left: (_getPositionHorizon = getPositionHorizon(positionH, column, page, width, isPageBreak)) !== null && _getPositionHorizon !== void 0 ? _getPositionHorizon : 0,
14396
- top: (_getPositionVertical = getPositionVertical(positionV, page, lineTop, lineHeight, height, drawingAnchorTop, isPageBreak)) !== null && _getPositionVertical !== void 0 ? _getPositionVertical : 0
14421
+ top: (_getPositionVertical = getPositionVertical(positionV, page, sectionTop + lineTop, lineHeight, height, drawingAnchorTop == null ? void 0 : sectionTop + drawingAnchorTop, isPageBreak)) !== null && _getPositionVertical !== void 0 ? _getPositionVertical : 0
14397
14422
  };
14398
14423
  }
14399
14424
  function __avoidFlowAffectingDrawingsForTable(table, page, column) {
14425
+ var _column$left;
14426
+ const columnLeft = (_column$left = column.left) !== null && _column$left !== void 0 ? _column$left : 0;
14400
14427
  const tableTop = table.top;
14401
14428
  const tableBottom = table.top + table.height;
14402
14429
  const tableRight = table.left + table.width;
@@ -14409,7 +14436,7 @@ function __avoidFlowAffectingDrawingsForTable(table, page, column) {
14409
14436
  if (drawingTop >= tableBottom || drawingBottom <= tableTop) continue;
14410
14437
  const drawingRight = drawing.aLeft + drawing.width + ((_drawingOrigin$distR = drawingOrigin.distR) !== null && _drawingOrigin$distR !== void 0 ? _drawingOrigin$distR : 0);
14411
14438
  if (drawing.aLeft >= tableRight || drawingRight <= table.left) continue;
14412
- if (drawingRight + table.width <= column.width) table.left = Math.max(table.left, drawingRight);
14439
+ if (drawingRight + table.width <= columnLeft + column.width) table.left = Math.max(table.left, drawingRight);
14413
14440
  }
14414
14441
  }
14415
14442
  function _updateAndPositionTable(ctx, lineTop, lineHeight, page, column, section, skeTablesInParagraph, paragraphIndex, sectionBreakConfig, drawingAnchorTop) {
@@ -14418,9 +14445,10 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, column, section
14418
14445
  if (firstUnPositionedTable == null) return false;
14419
14446
  const { tableId, table } = firstUnPositionedTable;
14420
14447
  const { tableSource } = table;
14421
- if (firstUnPositionedTable.isSlideTable === false) switch (tableSource.textWrap) {
14448
+ if (firstUnPositionedTable.isSlideTable === false || tableSource.textWrap === TableTextWrapType.NONE) switch (tableSource.textWrap) {
14422
14449
  case TableTextWrapType.NONE:
14423
- table.top = lineTop;
14450
+ table.top = section.top + lineTop;
14451
+ table.left = column.left + getTableLeft(column.width, table.width, tableSource.align, tableSource.indent);
14424
14452
  __avoidFlowAffectingDrawingsForTable(table, page, column);
14425
14453
  break;
14426
14454
  case TableTextWrapType.WRAP:
@@ -14429,9 +14457,10 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, column, section
14429
14457
  default: throw new Error(`Unsupported table text wrap type: ${tableSource.textWrap}`);
14430
14458
  }
14431
14459
  const { top, left, height } = table;
14432
- if (!ctx.isDirty && top + height > section.height && firstUnPositionedTable.isSlideTable === false) {
14460
+ const localTop = top - section.top;
14461
+ if (!ctx.isDirty && localTop + height > section.height && firstUnPositionedTable.isSlideTable === false) {
14433
14462
  skeTablesInParagraph.pop();
14434
- const availableHeight = section.height - top;
14463
+ const availableHeight = section.height - localTop;
14435
14464
  const { segmentId } = page;
14436
14465
  const viewModel = ctx.viewModel.getSelfOrHeaderFooterViewModel(segmentId);
14437
14466
  const tableNode = firstUnPositionedTable.tableNode;
@@ -14475,18 +14504,30 @@ function _getCustomBlockIdsInLine(line) {
14475
14504
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) customBlockIds.push(glyph.drawingId);
14476
14505
  return customBlockIds;
14477
14506
  }
14478
- function __updateTopBottomCustomBlockFlowBottom(paragraphConfig, drawings) {
14507
+ function __updateTopBottomCustomBlockFlowBottom(paragraphConfig, drawings, sectionTop) {
14479
14508
  for (const drawing of drawings) {
14480
14509
  var _drawingOrigin$distB, _paragraphConfig$topB;
14481
14510
  const { drawingOrigin } = drawing;
14482
14511
  if (drawingOrigin.layoutType !== PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM || drawingOrigin.behindDoc === BooleanNumber.TRUE) continue;
14483
- const bottom = drawing.aTop + drawing.height + ((_drawingOrigin$distB = drawingOrigin.distB) !== null && _drawingOrigin$distB !== void 0 ? _drawingOrigin$distB : 0);
14512
+ const bottom = drawing.aTop + drawing.height + ((_drawingOrigin$distB = drawingOrigin.distB) !== null && _drawingOrigin$distB !== void 0 ? _drawingOrigin$distB : 0) - sectionTop;
14484
14513
  paragraphConfig.topBottomCustomBlockFlowBottom = Math.max((_paragraphConfig$topB = paragraphConfig.topBottomCustomBlockFlowBottom) !== null && _paragraphConfig$topB !== void 0 ? _paragraphConfig$topB : Number.NEGATIVE_INFINITY, bottom);
14485
14514
  }
14486
14515
  }
14487
14516
  function __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings) {
14488
14517
  return __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings).length > 0;
14489
14518
  }
14519
+ function __isPositionedCustomBlockOnlyLine(glyphGroup, paragraphNonInlineSkeDrawings) {
14520
+ let hasPositionedCustomBlock = false;
14521
+ for (const glyph of glyphGroup) {
14522
+ var _paragraphNonInlineSk;
14523
+ if (__isStructuralTerminatorGlyph(glyph) || __isIgnorableZeroSizeGlyph(glyph)) continue;
14524
+ if (glyph.streamType !== DataStreamTreeTokenType.CUSTOM_BLOCK || glyph.drawingId == null) return false;
14525
+ const drawingOrigin = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 || (_paragraphNonInlineSk = paragraphNonInlineSkeDrawings.get(glyph.drawingId)) === null || _paragraphNonInlineSk === void 0 ? void 0 : _paragraphNonInlineSk.drawingOrigin;
14526
+ if (drawingOrigin == null || drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE) return false;
14527
+ hasPositionedCustomBlock = true;
14528
+ }
14529
+ return hasPositionedCustomBlock;
14530
+ }
14490
14531
  function __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings) {
14491
14532
  const drawings = [];
14492
14533
  for (const glyph of glyphGroup) {
@@ -14515,26 +14556,25 @@ function __hasFlowGlyph(glyphGroup) {
14515
14556
  });
14516
14557
  }
14517
14558
  function _reLayoutCheck(ctx, floatObjects, column, paragraphIndex) {
14518
- var _column$parent2;
14519
- const page = (_column$parent2 = column.parent) === null || _column$parent2 === void 0 ? void 0 : _column$parent2.parent;
14559
+ var _column$parent3;
14560
+ const page = (_column$parent3 = column.parent) === null || _column$parent3 === void 0 ? void 0 : _column$parent3.parent;
14520
14561
  const flowAffectingFloatObjects = floatObjects.filter((floatObject) => floatObject.behindDoc !== BooleanNumber.TRUE || floatObject.layoutType != null && floatObject.layoutType !== PositionedObjectLayoutType.WRAP_NONE);
14521
14562
  if (flowAffectingFloatObjects.length === 0 || page == null) return;
14522
14563
  let needBreakLineIterator = false;
14523
14564
  for (const floatObject of flowAffectingFloatObjects) {
14524
- var _floatObjectCache$pag, _page$sections$;
14525
14565
  const floatObjectCache = ctx.floatObjectsCache.get(floatObject.id);
14526
14566
  if (floatObjectCache == null || floatObjectCache.page.segmentId !== page.segmentId) continue;
14527
14567
  if (floatObjectCache.count >= FLOAT_OBJECT_RELAYOUT_LIMIT) continue;
14528
- 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;
14529
- 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;
14530
- if (floatObjectCache.page && cachePageStartParagraphIndex && startIndex && cachePageStartParagraphIndex !== startIndex) {
14568
+ if (floatObjectCache.page.pageNumber !== page.pageNumber) {
14531
14569
  floatObjectCache.page.skeDrawings.delete(floatObject.id);
14532
14570
  ctx.floatObjectsCache.delete(floatObject.id);
14533
14571
  lineIterator([floatObjectCache.page], (line) => {
14534
- const { lineHeight, top } = line;
14572
+ var _column$parent$top2, _column$parent4;
14573
+ const { lineHeight } = line;
14535
14574
  const column = line.parent;
14536
14575
  if (needBreakLineIterator || column == null) return;
14537
14576
  const { width: columnWidth, left: columnLeft } = column;
14577
+ const top = ((_column$parent$top2 = (_column$parent4 = column.parent) === null || _column$parent4 === void 0 ? void 0 : _column$parent4.top) !== null && _column$parent$top2 !== void 0 ? _column$parent$top2 : 0) + line.top;
14538
14578
  if (collisionDetection(floatObjectCache.floatObject, lineHeight, top, columnLeft, columnWidth)) {
14539
14579
  var _ctx$layoutStartPoint;
14540
14580
  needBreakLineIterator = true;
@@ -14547,9 +14587,12 @@ function _reLayoutCheck(ctx, floatObjects, column, paragraphIndex) {
14547
14587
  }
14548
14588
  needBreakLineIterator = false;
14549
14589
  lineIterator([page], (line) => {
14550
- const { lineHeight, top } = line;
14551
- const { width: columnWidth, left: columnLeft } = column;
14552
- if (needBreakLineIterator) return;
14590
+ var _lineColumn$parent$to, _lineColumn$parent;
14591
+ const { lineHeight } = line;
14592
+ const lineColumn = line.parent;
14593
+ if (needBreakLineIterator || lineColumn == null) return;
14594
+ const { width: columnWidth, left: columnLeft } = lineColumn;
14595
+ const top = ((_lineColumn$parent$to = (_lineColumn$parent = lineColumn.parent) === null || _lineColumn$parent === void 0 ? void 0 : _lineColumn$parent.top) !== null && _lineColumn$parent$to !== void 0 ? _lineColumn$parent$to : 0) + line.top;
14553
14596
  for (const floatObject of flowAffectingFloatObjects.values()) {
14554
14597
  let targetObject = floatObject;
14555
14598
  if (ctx.floatObjectsCache.has(floatObject.id)) {
@@ -14592,18 +14635,18 @@ function checkRelativeDrawingNeedRePosition(ctx, floatObject) {
14592
14635
  }
14593
14636
  return false;
14594
14637
  }
14595
- function _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal", defaultSpanLineHeight) {
14596
- if (isColumnFull(getLastPage(pages)) === true) _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
14597
- else _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
14638
+ function _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal", defaultSpanMetrics) {
14639
+ if (isColumnFull(getLastPage(pages)) === true) _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanMetrics);
14640
+ else _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanMetrics);
14598
14641
  }
14599
- function _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal", defaultSpanLineHeight) {
14642
+ function _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal", defaultSpanMetrics) {
14600
14643
  const curSkeletonPage = getLastPage(pages);
14601
14644
  const { skeHeaders, skeFooters } = paragraphConfig;
14602
14645
  pages.push(createSkeletonPage(ctx, sectionBreakConfig, {
14603
14646
  skeHeaders,
14604
14647
  skeFooters
14605
14648
  }, (curSkeletonPage === null || curSkeletonPage === void 0 ? void 0 : curSkeletonPage.pageNumber) + 1));
14606
- _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
14649
+ _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanMetrics);
14607
14650
  }
14608
14651
  /**
14609
14652
  * 17.3.1.12 ind (Paragraph Indentation)
@@ -14752,8 +14795,8 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId =
14752
14795
  const drawingHeight = (_viewport$height = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _viewport$height !== void 0 ? _viewport$height : height;
14753
14796
  drawing.aLeft = viewport ? blockLeft + ((_viewport$offsetLeft = viewport.offsetLeft) !== null && _viewport$offsetLeft !== void 0 ? _viewport$offsetLeft : 0) : blockLeft + .5 * glyph.width - .5 * drawingWidth || 0;
14754
14797
  if (glyph.width > divide.width) {
14755
- var _paragraphNonInlineSk;
14756
- for (const positionedDrawing of (_paragraphNonInlineSk = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.values()) !== null && _paragraphNonInlineSk !== void 0 ? _paragraphNonInlineSk : []) {
14798
+ var _paragraphNonInlineSk2;
14799
+ for (const positionedDrawing of (_paragraphNonInlineSk2 = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.values()) !== null && _paragraphNonInlineSk2 !== void 0 ? _paragraphNonInlineSk2 : []) {
14757
14800
  const positionedOrigin = positionedDrawing.drawingOrigin;
14758
14801
  if (positionedOrigin == null || positionedOrigin.layoutType === PositionedObjectLayoutType.INLINE || positionedOrigin.layoutType === PositionedObjectLayoutType.WRAP_NONE || positionedOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) continue;
14759
14802
  const positionedBottom = positionedDrawing.aTop + positionedDrawing.height;
@@ -14789,11 +14832,14 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId =
14789
14832
  page.skeDrawings = new Map([...page.skeDrawings, ...drawings]);
14790
14833
  }
14791
14834
  function __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = [], blockAnchorLeft = 0, normalizeTraditionalColumnAnchor = true) {
14792
- var _column$parent3;
14793
- const page = (_column$parent3 = column.parent) === null || _column$parent3 === void 0 ? void 0 : _column$parent3.parent;
14835
+ var _column$parent5, _column$parent$top3, _column$parent6;
14836
+ const page = (_column$parent5 = column.parent) === null || _column$parent5 === void 0 ? void 0 : _column$parent5.parent;
14794
14837
  if (page == null || needPositionDrawings.length === 0) return;
14795
14838
  const drawings = /* @__PURE__ */ new Map();
14796
14839
  const isPageBreak = __checkPageBreak(column);
14840
+ const sectionTop = (_column$parent$top3 = (_column$parent6 = column.parent) === null || _column$parent6 === void 0 ? void 0 : _column$parent6.top) !== null && _column$parent$top3 !== void 0 ? _column$parent$top3 : 0;
14841
+ const absoluteLineTop = sectionTop + lineTop;
14842
+ const absoluteBlockAnchorTop = blockAnchorTop == null ? void 0 : sectionTop + blockAnchorTop;
14797
14843
  if (isPageBreak && !isParagraphFirstShapedText) return;
14798
14844
  for (const drawing of needPositionDrawings) {
14799
14845
  var _ctx$dataModel$getUni, _ctx$dataModel$getUni2, _ctx$dataModel, _viewport$width2, _viewport$height2, _getPositionHorizon2, _getPositionVertical2;
@@ -14820,7 +14866,7 @@ function __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirst
14820
14866
  if (normalizeTraditionalColumnAnchor && ctx.dataModel.documentStyle.documentFlavor === DocumentFlavor.TRADITIONAL && positionV.relativeFrom === ObjectRelativeFromV.PARAGRAPH) aLeft -= page.marginLeft;
14821
14867
  }
14822
14868
  drawing.aLeft = aLeft;
14823
- drawing.aTop = (_getPositionVertical2 = getPositionVertical(positionV, page, lineTop, lineHeight, drawingHeight, blockAnchorTop, isPageBreak)) !== null && _getPositionVertical2 !== void 0 ? _getPositionVertical2 : 0;
14869
+ drawing.aTop = (_getPositionVertical2 = getPositionVertical(positionV, page, absoluteLineTop, lineHeight, drawingHeight, absoluteBlockAnchorTop, isPageBreak)) !== null && _getPositionVertical2 !== void 0 ? _getPositionVertical2 : 0;
14824
14870
  drawing.width = drawingWidth;
14825
14871
  drawing.height = drawingHeight;
14826
14872
  drawing.angle = angle;
@@ -14834,17 +14880,17 @@ function __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirst
14834
14880
  } : void 0;
14835
14881
  drawing.initialState = true;
14836
14882
  drawing.columnLeft = column.left;
14837
- drawing.lineTop = lineTop;
14883
+ drawing.lineTop = absoluteLineTop;
14838
14884
  drawing.lineHeight = lineHeight;
14839
14885
  drawing.isPageBreak = isPageBreak;
14840
- drawing.blockAnchorTop = blockAnchorTop !== null && blockAnchorTop !== void 0 ? blockAnchorTop : lineTop;
14886
+ drawing.blockAnchorTop = absoluteBlockAnchorTop !== null && absoluteBlockAnchorTop !== void 0 ? absoluteBlockAnchorTop : absoluteLineTop;
14841
14887
  drawings.set(drawing.drawingId, drawing);
14842
14888
  }
14843
14889
  return drawings;
14844
14890
  }
14845
14891
  function __updateDrawingPosition(column, drawings, overwriteTopBottomPosition = false) {
14846
- var _column$parent4;
14847
- const page = (_column$parent4 = column.parent) === null || _column$parent4 === void 0 ? void 0 : _column$parent4.parent;
14892
+ var _column$parent7;
14893
+ const page = (_column$parent7 = column.parent) === null || _column$parent7 === void 0 ? void 0 : _column$parent7.parent;
14848
14894
  if (drawings == null || drawings.size === 0 || page == null) return;
14849
14895
  for (const drawing of drawings.values()) {
14850
14896
  const originDrawing = page.skeDrawings.get(drawing.drawingId);
@@ -14858,8 +14904,11 @@ function __updateDrawingPosition(column, drawings, overwriteTopBottomPosition =
14858
14904
  }
14859
14905
  }
14860
14906
  function __checkPageBreak(column) {
14907
+ var _section$parent;
14861
14908
  const section = column.parent;
14862
14909
  if (!section) return false;
14910
+ const pageSections = (_section$parent = section.parent) === null || _section$parent === void 0 ? void 0 : _section$parent.sections;
14911
+ if (pageSections && pageSections[0] !== section) return false;
14863
14912
  const columns = section === null || section === void 0 ? void 0 : section.columns;
14864
14913
  if (!columns) return false;
14865
14914
  const columnLength = columns.length;
@@ -15680,11 +15729,17 @@ function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig
15680
15729
  if (!hasAddonStyle && originTextRun) fontCreateConfigCache.setValue(st, ed, result);
15681
15730
  return result;
15682
15731
  }
15683
- function getCustomRangeGlyphWidth(index, viewModel, paragraphNode, config) {
15732
+ function getCustomRangeGlyphMetrics(index, viewModel, paragraphNode, config) {
15684
15733
  const customRange = viewModel.getCustomRange(index + paragraphNode.startIndex);
15685
- const glyphWidthEm = customRange === null || customRange === void 0 ? void 0 : customRange.glyphWidthEm;
15686
- if (typeof glyphWidthEm !== "number" || !Number.isFinite(glyphWidthEm) || glyphWidthEm < 0) return;
15687
- return glyphWidthEm * config.fontStyle.originFontSize;
15734
+ if (!customRange) return;
15735
+ const fontSize = ptToPixel(config.fontStyle.originFontSize);
15736
+ const toPixels = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value * fontSize : void 0;
15737
+ const metrics = {
15738
+ ascent: toPixels(customRange.glyphAscentEm),
15739
+ descent: toPixels(customRange.glyphDescentEm),
15740
+ width: toPixels(customRange.glyphWidthEm)
15741
+ };
15742
+ return metrics.ascent == null && metrics.descent == null && metrics.width == null ? void 0 : metrics;
15688
15743
  }
15689
15744
  function getNullSkeleton() {
15690
15745
  return {
@@ -16055,10 +16110,25 @@ function createSkeletonCellPages(ctx, viewModel, cellNode, sectionBreakConfig, t
16055
16110
  var _sectionBreakConfig$d2, _ctx$dataModel, _ctx$dataModel$getBod;
16056
16111
  const sectionNode = cellNode.children[0];
16057
16112
  const { page: areaPage, sectionBreakConfig: cellSectionBreakConfig } = createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, availableHeight, maxCellPageHeight);
16058
- const { pages } = dealWithSection(ctx, viewModel, sectionNode, areaPage, cellSectionBreakConfig);
16113
+ const segmentId = tableConfig.tableId;
16114
+ const retainedPages = [];
16115
+ let currentPage = areaPage;
16116
+ let pages = [];
16117
+ for (let count = 0; count <= 10; count++) {
16118
+ const layoutAnchor = ctx.layoutStartPointer[segmentId];
16119
+ ctx.layoutStartPointer[segmentId] = null;
16120
+ const result = dealWithSection(ctx, viewModel, sectionNode, currentPage, cellSectionBreakConfig, layoutAnchor);
16121
+ pages = [...retainedPages, ...result.pages];
16122
+ if (!ctx.isDirty || ctx.layoutStartPointer[segmentId] == null || count === 10) break;
16123
+ const retryPage = pages.at(-1);
16124
+ if (retryPage == null) break;
16125
+ retainedPages.splice(0, retainedPages.length, ...pages.slice(0, -1));
16126
+ currentPage = retryPage;
16127
+ resetContext(ctx);
16128
+ }
16059
16129
  for (const p of pages) {
16060
16130
  p.type = 3;
16061
- p.segmentId = tableConfig.tableId;
16131
+ p.segmentId = segmentId;
16062
16132
  }
16063
16133
  updateBlockIndex(pages, cellNode.startIndex, (_sectionBreakConfig$d2 = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d2 !== void 0 ? _sectionBreakConfig$d2 : getDocumentCompatibilityPolicy());
16064
16134
  applyTrailingBlockRangeSpaceBelow(pages, (_ctx$dataModel = ctx.dataModel) === null || _ctx$dataModel === void 0 || (_ctx$dataModel$getBod = _ctx$dataModel.getBody) === null || _ctx$dataModel$getBod === void 0 ? void 0 : _ctx$dataModel$getBod.call(_ctx$dataModel), cellNode.endIndex);
@@ -16240,6 +16310,11 @@ function horizontalAlignHandler(line, horizontalAlign, allowOverflowHorizontalOf
16240
16310
  for (let i = 0; i < divides.length; i++) {
16241
16311
  const divide = divides[i];
16242
16312
  const { width } = divide;
16313
+ if (divide.glyphGroup.length === 0) {
16314
+ divide.glyphGroupWidth = 0;
16315
+ divide.paddingLeft = 0;
16316
+ continue;
16317
+ }
16243
16318
  let glyphGroupWidth = getGlyphGroupWidth(divide);
16244
16319
  divide.glyphGroupWidth = glyphGroupWidth;
16245
16320
  if (width === Number.POSITIVE_INFINITY) continue;
@@ -16752,10 +16827,16 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
16752
16827
  segmentDrawingAnchorCache = /* @__PURE__ */ new Map();
16753
16828
  drawingAnchor === null || drawingAnchor === void 0 || drawingAnchor.set(segmentId, segmentDrawingAnchorCache);
16754
16829
  }
16830
+ const resolvedParagraphStyle = _applyBlockRangeLayoutParagraphStyle((_viewModel$getBody2 = (_viewModel$getBody3 = viewModel.getBody) === null || _viewModel$getBody3 === void 0 ? void 0 : _viewModel$getBody3.call(viewModel)) !== null && _viewModel$getBody2 !== void 0 ? _viewModel$getBody2 : null, paragraph, paragraphStyle, documentStyle, shouldApplyDocumentDefaults);
16831
+ const borderBottom = resolvedParagraphStyle.borderBottom;
16832
+ if (borderBottom) {
16833
+ var _borderBottom$padding, _borderBottom$width;
16834
+ _withMinSpacing(resolvedParagraphStyle, "spaceBelow", Math.max(0, (_borderBottom$padding = borderBottom.padding) !== null && _borderBottom$padding !== void 0 ? _borderBottom$padding : 0) + Math.max(0, (_borderBottom$width = borderBottom.width) !== null && _borderBottom$width !== void 0 ? _borderBottom$width : 1) / 2);
16835
+ }
16755
16836
  const paragraphConfig = {
16756
16837
  paragraphIndex: endIndex,
16757
16838
  documentCompatibilityPolicy,
16758
- paragraphStyle: _applyBlockRangeLayoutParagraphStyle((_viewModel$getBody2 = (_viewModel$getBody3 = viewModel.getBody) === null || _viewModel$getBody3 === void 0 ? void 0 : _viewModel$getBody3.call(viewModel)) !== null && _viewModel$getBody2 !== void 0 ? _viewModel$getBody2 : null, paragraph, paragraphStyle, documentStyle, shouldApplyDocumentDefaults),
16839
+ paragraphStyle: resolvedParagraphStyle,
16759
16840
  docxFallbackAnchorLeft: _getFollowingIndentedParagraphAnchorLeft(viewModel, paragraph, paragraphNode, drawings, isTraditionalDocumentCompatibility(documentCompatibilityPolicy)),
16760
16841
  useWordStyleLineHeight,
16761
16842
  paragraphNonInlineSkeDrawings,
@@ -17316,7 +17397,7 @@ function otherHandler(index, charArray, viewModel, paragraphNode, sectionBreakCo
17316
17397
  if (char == null) break;
17317
17398
  if (hasSpace(char) || startWithEmoji(charArray.substring(step))) break;
17318
17399
  const config = getFontCreateConfig(index + step, viewModel, paragraphNode, sectionBreakConfig, paragraph);
17319
- const glyph = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphWidth(index + step, viewModel, paragraphNode, config));
17400
+ const glyph = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphMetrics(index + step, viewModel, paragraphNode, config));
17320
17401
  glyphGroup.push(glyph);
17321
17402
  src = src.substring(char.length);
17322
17403
  step += char.length;
@@ -17474,7 +17555,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
17474
17555
  const newSpan = createSkeletonLetterGlyph(char, config);
17475
17556
  shapedGlyphs.push(newSpan);
17476
17557
  } else {
17477
- const newSpan = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphWidth(start, viewModel, paragraphNode, config), glyphInfo);
17558
+ const newSpan = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphMetrics(start, viewModel, paragraphNode, config), glyphInfo);
17478
17559
  shapedGlyphs.push(newSpan);
17479
17560
  }
17480
17561
  }
@@ -17515,7 +17596,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
17515
17596
  else if (char === DataStreamTreeTokenType.PARAGRAPH) {
17516
17597
  var _sectionBreakConfig$r;
17517
17598
  if (((_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.zeroWidthParagraphBreak) === BooleanNumber.TRUE) newGlyph = createSkeletonLetterGlyph(char, config, 0);
17518
- else newGlyph = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphWidth(i, viewModel, paragraphNode, config));
17599
+ else newGlyph = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphMetrics(i, viewModel, paragraphNode, config));
17519
17600
  } else newGlyph = createSkeletonLetterGlyph(char, config);
17520
17601
  shapedGlyphs.push(newGlyph);
17521
17602
  i += char.length;
@@ -17820,7 +17901,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
17820
17901
  let currentPageCache = curPage;
17821
17902
  if (allCurrentSkeletonPages.length > 0) currentPageCache = allCurrentSkeletonPages[allCurrentSkeletonPages.length - 1];
17822
17903
  if (paragraphNode.nodeType === DataStreamTreeNodeType.PARAGRAPH) {
17823
- if (ctx.paragraphsOpenNewPage.has(paragraphNode.endIndex)) currentPageCache = createSkeletonPage(ctx, sectionBreakConfig, ctx.skeletonResourceReference, currentPageCache.pageNumber + 1);
17904
+ if (ctx.paragraphsOpenNewPage.delete(paragraphNode.endIndex) && currentPageCache.sections.some((section) => section.columns.some((column) => column.lines.length > 0))) currentPageCache = createSkeletonPage(ctx, sectionBreakConfig, ctx.skeletonResourceReference, currentPageCache.pageNumber + 1);
17824
17905
  skeletonPages = dealWidthParagraph(ctx, viewModel, paragraphNode, currentPageCache, sectionBreakConfig);
17825
17906
  }
17826
17907
  if (paragraphNode.nodeType === DataStreamTreeNodeType.COLUMN_GROUP) {
@@ -18962,7 +19043,8 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
18962
19043
  ctx.sectionBreakConfigCache.set(sectionNode.endIndex, sectionBreakConfig);
18963
19044
  if (sectionType === SectionType.CONTINUOUS && curSkeletonPage != null) {
18964
19045
  updateBlockIndex(allSkeletonPages, -1, ctx.docsConfig.documentCompatibilityPolicy);
18965
- this._addNewSectionByContinuous(curSkeletonPage, columnProperties, columnSeparatorType);
19046
+ if (layoutAnchor != null && layoutAnchor >= sectionNode.startIndex && layoutAnchor <= sectionNode.endIndex) this._restoreContinuousSection(curSkeletonPage, columnProperties, columnSeparatorType);
19047
+ else this._addNewSectionByContinuous(curSkeletonPage, columnProperties, columnSeparatorType);
18966
19048
  isContinuous = true;
18967
19049
  } else if (layoutAnchor == null || curSkeletonPage == null) {
18968
19050
  var _curSkeletonPage$page;
@@ -19004,6 +19086,19 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
19004
19086
  newSection.parent = curSkeletonPage;
19005
19087
  sections.push(newSection);
19006
19088
  }
19089
+ _restoreContinuousSection(curSkeletonPage, columnProperties, columnSeparatorType) {
19090
+ const section = curSkeletonPage.sections[curSkeletonPage.sections.length - 1];
19091
+ if (section == null) return;
19092
+ const pageContentWidth = curSkeletonPage.pageWidth - curSkeletonPage.marginLeft - curSkeletonPage.marginRight;
19093
+ const pageContentHeight = curSkeletonPage.pageHeight - curSkeletonPage.marginTop - curSkeletonPage.marginBottom;
19094
+ const restoredSection = createSkeletonSection(columnProperties, columnSeparatorType, section.top, 0, pageContentWidth, pageContentHeight - section.top);
19095
+ for (const column of restoredSection.columns.slice(section.columns.length)) {
19096
+ column.parent = section;
19097
+ section.columns.push(column);
19098
+ }
19099
+ section.colCount = restoredSection.colCount;
19100
+ section.height = restoredSection.height;
19101
+ }
19007
19102
  _findNodeByIndex(charIndex, segmentId = "", segmentPageIndex = -1) {
19008
19103
  const skeletonData = this.getSkeletonData();
19009
19104
  if (skeletonData == null) return;
@@ -24191,6 +24286,7 @@ var Documents = class Documents extends DocComponent {
24191
24286
  this._startRotation(ctx, finalAngle);
24192
24287
  for (const section of sections) {
24193
24288
  const { columns } = section;
24289
+ this._drawLiquid.translateSave();
24194
24290
  this._drawLiquid.translateSection(section);
24195
24291
  for (const column of columns) {
24196
24292
  const { lines, width: columnWidth } = column;
@@ -24233,7 +24329,7 @@ var Documents = class Documents extends DocComponent {
24233
24329
  this._drawLiquid.translateSave();
24234
24330
  this._drawLiquid.translateLine(line, true, true);
24235
24331
  rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i]);
24236
- this._drawLineBackground(ctx, page, line);
24332
+ this._drawLineBackground(ctx, page, line, column.width);
24237
24333
  const divideLength = divides.length;
24238
24334
  for (let i = 0; i < divideLength; i++) {
24239
24335
  const divide = divides[i];
@@ -24262,12 +24358,13 @@ var Documents = class Documents extends DocComponent {
24262
24358
  }
24263
24359
  this._drawLiquid.translateRestore();
24264
24360
  }
24265
- if (line.borderBottom) this._drawBorderBottom(ctx, page, line);
24361
+ if (line.borderBottom) this._drawBorderBottom(ctx, page, line, column.width);
24266
24362
  this._drawLiquid.translateRestore();
24267
24363
  }
24268
24364
  }
24269
24365
  this._drawLiquid.translateRestore();
24270
24366
  }
24367
+ this._drawLiquid.translateRestore();
24271
24368
  }
24272
24369
  if (skeColumnGroups.size > 0) this._drawColumnGroups(ctx, page, skeColumnGroups, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
24273
24370
  this._resetRotation(ctx, finalAngle);
@@ -24400,30 +24497,30 @@ var Documents = class Documents extends DocComponent {
24400
24497
  const skeleton = this.getSkeleton();
24401
24498
  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);
24402
24499
  }
24403
- _drawLineBackground(ctx, page, line, left = 0, top = 0) {
24500
+ _drawLineBackground(ctx, page, line, width = page.pageWidth - page.marginLeft - page.marginRight, left = 0, top = 0) {
24404
24501
  var _line$backgroundColor;
24405
24502
  const color = (_line$backgroundColor = line.backgroundColor) === null || _line$backgroundColor === void 0 ? void 0 : _line$backgroundColor.rgb;
24406
24503
  if (!color || this._drawLiquid == null) return;
24407
24504
  let { x, y } = this._drawLiquid;
24408
- const { pageWidth, marginLeft, marginRight, marginTop } = page;
24505
+ const { marginLeft, marginTop } = page;
24409
24506
  x += marginLeft + (left !== null && left !== void 0 ? left : 0);
24410
24507
  y -= line.marginTop;
24411
24508
  y -= line.paddingTop;
24412
24509
  y += marginTop + top;
24413
24510
  ctx.save();
24414
24511
  ctx.fillStyle = color;
24415
- fillRectByPrecisionBounds(ctx, x, y, pageWidth - marginLeft - marginRight, line.lineHeight);
24512
+ fillRectByPrecisionBounds(ctx, x, y, width, line.lineHeight);
24416
24513
  ctx.restore();
24417
24514
  }
24418
- _drawBorderBottom(ctx, page, line, left = 0, top = 0) {
24515
+ _drawBorderBottom(ctx, page, line, width = page.pageWidth - page.marginLeft - page.marginRight, left = 0, top = 0) {
24419
24516
  var _line$borderBottom$pa, _line$borderBottom, _border$width, _border$color$rgb;
24420
24517
  if (this._drawLiquid == null) return;
24421
24518
  let { x, y } = this._drawLiquid;
24422
- const { pageWidth, marginLeft, marginRight, marginTop } = page;
24519
+ const { marginLeft, marginTop } = page;
24423
24520
  x += marginLeft + (left !== null && left !== void 0 ? left : 0);
24424
24521
  y -= line.marginTop;
24425
24522
  y -= line.paddingTop;
24426
- y += marginTop + top + line.lineHeight + ((_line$borderBottom$pa = (_line$borderBottom = line.borderBottom) === null || _line$borderBottom === void 0 ? void 0 : _line$borderBottom.padding) !== null && _line$borderBottom$pa !== void 0 ? _line$borderBottom$pa : 0);
24523
+ y += marginTop + top + line.lineHeight - line.marginBottom + ((_line$borderBottom$pa = (_line$borderBottom = line.borderBottom) === null || _line$borderBottom === void 0 ? void 0 : _line$borderBottom.padding) !== null && _line$borderBottom$pa !== void 0 ? _line$borderBottom$pa : 0);
24427
24524
  ctx.save();
24428
24525
  const border = line.borderBottom;
24429
24526
  ctx.setLineWidthByPrecision(Math.max(0, (_border$width = border === null || border === void 0 ? void 0 : border.width) !== null && _border$width !== void 0 ? _border$width : 1));
@@ -24432,7 +24529,7 @@ var Documents = class Documents extends DocComponent {
24432
24529
  drawLineByBorderType(ctx, "b", 0, {
24433
24530
  startX: x,
24434
24531
  startY: y,
24435
- endX: x + pageWidth - marginLeft - marginRight,
24532
+ endX: x + width,
24436
24533
  endY: y
24437
24534
  });
24438
24535
  ctx.restore();
@@ -24505,7 +24602,7 @@ var Documents = class Documents extends DocComponent {
24505
24602
  } else {
24506
24603
  this._drawLiquid.translateSave();
24507
24604
  this._drawLiquid.translateLine(line, true, true);
24508
- this._drawLineBackground(ctx, nestedPage, line);
24605
+ this._drawLineBackground(ctx, nestedPage, line, column.width);
24509
24606
  const divideLength = divides.length;
24510
24607
  for (let i = 0; i < divideLength; i++) {
24511
24608
  const divide = divides[i];
@@ -24534,7 +24631,7 @@ var Documents = class Documents extends DocComponent {
24534
24631
  }
24535
24632
  this._drawLiquid.translateRestore();
24536
24633
  }
24537
- if (line.borderBottom) this._drawBorderBottom(ctx, nestedPage, line, parentPage.marginLeft, parentPage.marginTop);
24634
+ if (line.borderBottom) this._drawBorderBottom(ctx, nestedPage, line, column.width, parentPage.marginLeft, parentPage.marginTop);
24538
24635
  this._drawLiquid.translateRestore();
24539
24636
  }
24540
24637
  }
@@ -24656,7 +24753,7 @@ var Documents = class Documents extends DocComponent {
24656
24753
  continue;
24657
24754
  }
24658
24755
  }
24659
- this._drawLineBackground(ctx, page, line, parentPage.marginLeft);
24756
+ this._drawLineBackground(ctx, page, line, column.width, parentPage.marginLeft);
24660
24757
  const divideLength = divides.length;
24661
24758
  for (let i = 0; i < divideLength; i++) {
24662
24759
  const divide = divides[i];
@@ -24685,7 +24782,7 @@ var Documents = class Documents extends DocComponent {
24685
24782
  }
24686
24783
  this._drawLiquid.translateRestore();
24687
24784
  }
24688
- if (line.borderBottom) this._drawBorderBottom(ctx, page, line, parentPage.marginLeft);
24785
+ if (line.borderBottom) this._drawBorderBottom(ctx, page, line, column.width, parentPage.marginLeft);
24689
24786
  this._drawLiquid.translateRestore();
24690
24787
  }
24691
24788
  }
@@ -27601,7 +27698,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
27601
27698
  //#endregion
27602
27699
  //#region package.json
27603
27700
  var name = "@univerjs/engine-render";
27604
- var version = "1.0.0-alpha.6";
27701
+ var version = "1.0.0-alpha.7";
27605
27702
 
27606
27703
  //#endregion
27607
27704
  //#region src/config/config.ts
@@ -29000,14 +29097,15 @@ var Transformer = class extends Disposable {
29000
29097
  }
29001
29098
  _createRotateIcon(applyObject, zIndex, left, top) {
29002
29099
  const { rotateSize, rotateIconStroke, rotateIconStrokeWidth, borderStroke } = this._getConfig(applyObject);
29003
- const iconOffset = (rotateSize - ROTATE_ICON_SIZE) / 2;
29100
+ const iconSize = Math.min(ROTATE_ICON_SIZE, Math.max(rotateSize - 4, 1));
29101
+ const iconOffset = (rotateSize - iconSize) / 2;
29004
29102
  return new TransformerRotateIcon(`__SpreadsheetTransformerRotate___ICON_${zIndex}`, {
29005
29103
  zIndex,
29006
29104
  evented: false,
29007
29105
  left: left + iconOffset,
29008
29106
  top: top + iconOffset,
29009
- width: ROTATE_ICON_SIZE,
29010
- height: ROTATE_ICON_SIZE,
29107
+ width: iconSize,
29108
+ height: iconSize,
29011
29109
  fill: null,
29012
29110
  stroke: rotateIconStroke !== null && rotateIconStroke !== void 0 ? rotateIconStroke : borderStroke,
29013
29111
  strokeWidth: rotateIconStrokeWidth,
@@ -29423,7 +29521,7 @@ var Transformer = class extends Disposable {
29423
29521
  height: rotateAnchorOffset,
29424
29522
  width: 1,
29425
29523
  strokeWidth: borderStrokeWidth,
29426
- stroke: borderStroke
29524
+ stroke: rotateStroke !== null && rotateStroke !== void 0 ? rotateStroke : borderStroke
29427
29525
  });
29428
29526
  const { left: rotateLeft, top: rotateTop } = this._getRotateAnchorPosition("__SpreadsheetTransformerRotate__", height, width, applyObject);
29429
29527
  const cursor = this._getRotateAnchorCursor("__SpreadsheetTransformerRotate__");