@univerjs/engine-render 0.2.8 → 0.2.9

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
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
5
  import { Tools, DEFAULT_STYLES, FontStyleType, BaselineOffset, getCellInfoInMergeData, Rectangle, ColorKit, Disposable, EventSubject, checkParagraphHasIndentByStyle, DataStreamTreeTokenType, BorderStyleTypes, BooleanNumber, DisposableCollection, toDisposable, sortRules, Registry, numberToABC, CustomDecorationType, CustomRangeType, PositionedObjectLayoutType, WrapTextType, TableAlignmentType, GridType, BulletAlignment, ColumnSeparatorType, GlyphType as GlyphType$1, numberToListABC, HorizontalAlign, DataStreamTreeNodeType, PageOrientType, ObjectRelativeFromV, TableTextWrapType, SpacingRule, ObjectMatrix, SectionType, NumberUnitType, VerticalAlign, WrapStrategy, AlignTypeH, ObjectRelativeFromH, AlignTypeV, Inject, LocaleService, insertTextToContent, horizontalLineSegmentsSubtraction, deleteContent, DocumentDataModel, PRESET_LIST_TYPE, searchArray, extractPureTextFromCell, CellValueType, isCellCoverable, isNullCell, getColorStyle, isWhiteColor, IContextService, DEFAULT_EMPTY_DOCUMENT_VALUE, Range, TextDecoration, COLORS, requestImmediateMacroTask, MOVE_BUFFER_VALUE, sortRulesByDesc, Injector, isClassDependencyItem, createIdentifier, remove, UniverInstanceType, IUniverInstanceService, Plugin, RxDisposable, ILogService, DocumentFlavor } from "@univerjs/core";
6
- import { BehaviorSubject, startWith, distinctUntilChanged, Subscription, Subject, Observable, shareReplay, fromEvent } from "rxjs";
6
+ import { BehaviorSubject, Subject, startWith, distinctUntilChanged, Subscription, Observable, shareReplay, fromEvent } from "rxjs";
7
7
  var SHAPE_TYPE = /* @__PURE__ */ ((SHAPE_TYPE2) => (SHAPE_TYPE2.RECT = "rect", SHAPE_TYPE2.CIRCLE = "circle", SHAPE_TYPE2.PATH = "path", SHAPE_TYPE2))(SHAPE_TYPE || {}), LINK_VIEW_PORT_TYPE = /* @__PURE__ */ ((LINK_VIEW_PORT_TYPE2) => (LINK_VIEW_PORT_TYPE2[LINK_VIEW_PORT_TYPE2.XY = 0] = "XY", LINK_VIEW_PORT_TYPE2[LINK_VIEW_PORT_TYPE2.X = 1] = "X", LINK_VIEW_PORT_TYPE2[LINK_VIEW_PORT_TYPE2.Y = 2] = "Y", LINK_VIEW_PORT_TYPE2))(LINK_VIEW_PORT_TYPE || {});
8
8
  const MIDDLE_CELL_POS_MAGIC_NUMBER = 1, DEFAULT_FONTFACE_PLANE = '"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif', DEFAULT_SKELETON_HEADER_FOOTER = {
9
9
  lines: [],
@@ -2980,14 +2980,14 @@ const _BaseObject = class _BaseObject extends Disposable {
2980
2980
  }
2981
2981
  getScene() {
2982
2982
  let parent = this.parent;
2983
- if (parent != null) {
2983
+ if (parent == null)
2984
+ return null;
2985
+ if (parent.classType === RENDER_CLASS_TYPE.SCENE)
2986
+ return parent;
2987
+ for (; parent; ) {
2984
2988
  if (parent.classType === RENDER_CLASS_TYPE.SCENE)
2985
2989
  return parent;
2986
- for (; parent; ) {
2987
- if (parent.classType === RENDER_CLASS_TYPE.SCENE)
2988
- return parent;
2989
- parent = parent.getParent();
2990
- }
2990
+ parent = parent.getParent();
2991
2991
  }
2992
2992
  }
2993
2993
  resetCursor() {
@@ -20137,14 +20137,14 @@ function customBlockLineBreakExtension(breaker) {
20137
20137
  breaker.addRule("break_before_and_after_slash_b", (codePoint, lastCodePoint) => codePoint === SLASH_B_CODE_POINT || lastCodePoint === SLASH_B_CODE_POINT);
20138
20138
  }
20139
20139
  __name(customBlockLineBreakExtension, "customBlockLineBreakExtension");
20140
- function otherHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20140
+ function otherHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20141
20141
  const glyphGroup = [];
20142
20142
  let step = 0;
20143
20143
  for (let i = 0; i < charArray.length; i++) {
20144
20144
  const newChar = charArray[i];
20145
20145
  if (hasSpace(newChar) || startWithEmoji(charArray.substring(i)))
20146
20146
  break;
20147
- const config = getFontCreateConfig(index2 + i, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), glyph = createSkeletonLetterGlyph(newChar, config);
20147
+ const config = getFontCreateConfig(index2 + i, viewModel, paragraphNode, sectionBreakConfig, paragraph), glyph = createSkeletonLetterGlyph(newChar, config);
20148
20148
  glyphGroup.push(glyph), step++;
20149
20149
  }
20150
20150
  return {
@@ -20153,8 +20153,8 @@ function otherHandler(index2, charArray, viewModel, paragraphNode, sectionBreakC
20153
20153
  };
20154
20154
  }
20155
20155
  __name(otherHandler, "otherHandler");
20156
- function ArabicHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20157
- const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), glyph = [];
20156
+ function ArabicHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20157
+ const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph), glyph = [];
20158
20158
  let step = 0;
20159
20159
  for (let i = 0; i < charArray.length; i++) {
20160
20160
  const newChar = charArray[i];
@@ -20169,16 +20169,16 @@ function ArabicHandler(index2, charArray, viewModel, paragraphNode, sectionBreak
20169
20169
  };
20170
20170
  }
20171
20171
  __name(ArabicHandler, "ArabicHandler");
20172
- function emojiHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20173
- const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), match = charArray.match(EMOJI_REG);
20172
+ function emojiHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20173
+ const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph), match = charArray.match(EMOJI_REG);
20174
20174
  return {
20175
20175
  step: match[0].length,
20176
20176
  glyphGroup: [createSkeletonLetterGlyph(match[0], config)]
20177
20177
  };
20178
20178
  }
20179
20179
  __name(emojiHandler, "emojiHandler");
20180
- function TibetanHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20181
- const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), glyph = [];
20180
+ function TibetanHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20181
+ const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph), glyph = [];
20182
20182
  let step = 0;
20183
20183
  for (let i = 0; i < charArray.length; i++) {
20184
20184
  const newChar = charArray[i];
@@ -20228,7 +20228,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20228
20228
  drawings = {}
20229
20229
  } = sectionBreakConfig, shapedTextList = [];
20230
20230
  let breaker = new LineBreaker(content);
20231
- const { endIndex } = paragraphNode, { paragraphStyle = {} } = viewModel.getParagraph(endIndex) || { startIndex: 0 }, { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
20231
+ const { endIndex } = paragraphNode, paragraph = viewModel.getParagraph(endIndex) || { startIndex: 0 }, { paragraphStyle = {} } = paragraph, { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
20232
20232
  let last = 0, bk, lastGlyphIndex = 0;
20233
20233
  const { hyphen, languageDetector } = ctx, paragraphBody = prepareParagraphBody(viewModel.getBody(), endIndex);
20234
20234
  let glyphInfos = [];
@@ -20247,7 +20247,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20247
20247
  }
20248
20248
  lastGlyphIndex = i;
20249
20249
  for (const glyphInfo of glyphInfosInWord) {
20250
- const { start, char } = glyphInfo, config = getFontCreateConfig(start, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
20250
+ const { start, char } = glyphInfo, config = getFontCreateConfig(start, viewModel, paragraphNode, sectionBreakConfig, paragraph);
20251
20251
  if (char === DataStreamTreeTokenType.TAB) {
20252
20252
  const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid), newSpan = createSkeletonTabGlyph(config, charSpaceApply);
20253
20253
  shapedGlyphs.push(newSpan);
@@ -20266,7 +20266,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20266
20266
  if (char == null)
20267
20267
  break;
20268
20268
  if (char === DataStreamTreeTokenType.CUSTOM_BLOCK) {
20269
- const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
20269
+ const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
20270
20270
  let newGlyph = null;
20271
20271
  const customBlock = viewModel.getCustomBlockWithoutSetCurrentIndex(paragraphNode.startIndex + i);
20272
20272
  if (customBlock != null) {
@@ -20279,7 +20279,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20279
20279
  }
20280
20280
  newGlyph == null && (newGlyph = createSkeletonLetterGlyph(char, config)), shapedGlyphs.push(newGlyph), i += char.length, src = src.substring(char.length);
20281
20281
  } else if (/\s/.test(char) || hasCJK(char)) {
20282
- const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
20282
+ const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
20283
20283
  let newGlyph = null;
20284
20284
  if (char === DataStreamTreeTokenType.TAB) {
20285
20285
  const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
@@ -20294,7 +20294,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20294
20294
  viewModel,
20295
20295
  paragraphNode,
20296
20296
  sectionBreakConfig,
20297
- paragraphStyle
20297
+ paragraph
20298
20298
  );
20299
20299
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20300
20300
  } else if (hasArabic(char)) {
@@ -20304,7 +20304,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20304
20304
  viewModel,
20305
20305
  paragraphNode,
20306
20306
  sectionBreakConfig,
20307
- paragraphStyle
20307
+ paragraph
20308
20308
  );
20309
20309
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20310
20310
  } else if (hasTibetan(char)) {
@@ -20314,7 +20314,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20314
20314
  viewModel,
20315
20315
  paragraphNode,
20316
20316
  sectionBreakConfig,
20317
- paragraphStyle
20317
+ paragraph
20318
20318
  );
20319
20319
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20320
20320
  } else {
@@ -20324,7 +20324,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20324
20324
  viewModel,
20325
20325
  paragraphNode,
20326
20326
  sectionBreakConfig,
20327
- paragraphStyle
20327
+ paragraph
20328
20328
  );
20329
20329
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20330
20330
  }
@@ -20651,8 +20651,8 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
20651
20651
  const { blockId } = customBlock, drawingOrigin = drawings[blockId];
20652
20652
  drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE ? paragraphInlineSkeDrawings.set(blockId, _getDrawingSkeletonFormat(drawingOrigin)) : paragraphAffectSkeDrawings.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
20653
20653
  }
20654
- let allPages = [curPage], paragraphStart = !0;
20655
- for (const { text, glyphs, breakPointType } of shapedTextList) {
20654
+ let allPages = [curPage], isParagraphFirstShapedText = !0;
20655
+ for (const [_index, { text, glyphs, breakPointType }] of shapedTextList.entries()) {
20656
20656
  const pushPending = /* @__PURE__ */ __name(() => {
20657
20657
  glyphs.length !== 0 && (allPages = layoutParagraph(
20658
20658
  ctx,
@@ -20660,9 +20660,9 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
20660
20660
  allPages,
20661
20661
  sectionBreakConfig,
20662
20662
  paragraphConfig,
20663
- paragraphStart,
20663
+ isParagraphFirstShapedText,
20664
20664
  breakPointType
20665
- ), paragraphStart = !1);
20665
+ ), isParagraphFirstShapedText = !1);
20666
20666
  }, "pushPending");
20667
20667
  if (text.endsWith(DataStreamTreeTokenType.PAGE_BREAK)) {
20668
20668
  pushPending(), allPages.push(
@@ -21121,17 +21121,17 @@ function _getVerticalMargin(marginTB, headerOrFooter, pageHeight) {
21121
21121
  return Math.min(maxMargin, Math.max(marginTB, HeaderFooterPageHeight));
21122
21122
  }
21123
21123
  __name(_getVerticalMargin, "_getVerticalMargin");
21124
- function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal) {
21125
- if (paragraphStart)
21124
+ function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal) {
21125
+ if (isParagraphFirstShapedText)
21126
21126
  if (paragraphConfig.bulletSkeleton) {
21127
21127
  const { bulletSkeleton, paragraphStyle = {} } = paragraphConfig, { gridType = GridType.LINES, charSpace = 0, defaultTabStop = 10.5 } = sectionBreakConfig, paragraphProperties = bulletSkeleton.paragraphProperties || {};
21128
21128
  paragraphConfig.paragraphStyle = mergeByV(paragraphConfig.paragraphStyle, paragraphProperties);
21129
21129
  const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle, charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid), bulletGlyph = createSkeletonBulletGlyph(glyphGroup[0], bulletSkeleton, charSpaceApply);
21130
- _lineOperator(ctx, [bulletGlyph, ...glyphGroup], pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21130
+ _lineOperator(ctx, [bulletGlyph, ...glyphGroup], pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
21131
21131
  } else
21132
- _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21132
+ _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
21133
21133
  else
21134
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21134
+ _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
21135
21135
  return [...pages];
21136
21136
  }
21137
21137
  __name(layoutParagraph, "layoutParagraph");
@@ -21184,7 +21184,7 @@ function _popHyphenSlice(divide) {
21184
21184
  return divide.glyphGroup.length === 0 && (divide.glyphGroup.push(...glyphGroup), glyphGroup.length = 0), glyphGroup;
21185
21185
  }
21186
21186
  __name(_popHyphenSlice, "_popHyphenSlice");
21187
- function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21187
+ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21188
21188
  var _a11;
21189
21189
  const lastPage = getLastPage(pages), divideInfo = getLastNotFullDivideInfo(lastPage);
21190
21190
  if (divideInfo) {
@@ -21222,13 +21222,13 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21222
21222
  const hyphenSliceGlyphGroup = _popHyphenSlice(divide);
21223
21223
  hyphenSliceGlyphGroup.length > 0 && (updateDivideInfo(divide, {
21224
21224
  breakType: BreakPointType.Normal
21225
- }), _divideOperator(ctx, hyphenSliceGlyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, BreakPointType.Hyphen)), _divideOperator(
21225
+ }), _divideOperator(ctx, hyphenSliceGlyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, BreakPointType.Hyphen)), _divideOperator(
21226
21226
  ctx,
21227
21227
  glyphGroup,
21228
21228
  pages,
21229
21229
  sectionBreakConfig,
21230
21230
  paragraphConfig,
21231
- paragraphStart,
21231
+ isParagraphFirstShapedText,
21232
21232
  breakPointType,
21233
21233
  defaultSpanLineHeight
21234
21234
  );
@@ -21239,7 +21239,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21239
21239
  pages,
21240
21240
  sectionBreakConfig,
21241
21241
  paragraphConfig,
21242
- paragraphStart,
21242
+ isParagraphFirstShapedText,
21243
21243
  breakPointType,
21244
21244
  defaultSpanLineHeight
21245
21245
  );
@@ -21255,7 +21255,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21255
21255
  pages,
21256
21256
  sectionBreakConfig,
21257
21257
  paragraphConfig,
21258
- paragraphStart,
21258
+ isParagraphFirstShapedText,
21259
21259
  breakPointType,
21260
21260
  defaultSpanLineHeight
21261
21261
  );
@@ -21272,13 +21272,13 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21272
21272
  snapToGrid
21273
21273
  );
21274
21274
  if (currentLine.contentHeight < contentHeight) {
21275
- const spanGroupCached = __getSpanGroupByLine(currentLine), spanGroupCachedLen = spanGroupCached.length;
21276
- let newSpanGroup = [], startIndex = 1;
21277
- spanGroupCachedLen > 2 && spanGroupCached[0].glyphType === GlyphType.LIST ? (newSpanGroup = [spanGroupCached[0], spanGroupCached[1]], startIndex = 2) : newSpanGroup = [spanGroupCached[0]];
21275
+ const spanGroupCached = __getGlyphGroupByLine(currentLine), spanGroupCachedLen = spanGroupCached.length;
21276
+ let newGlyphGroup = [], startIndex = 1;
21277
+ spanGroupCachedLen > 2 && spanGroupCached[0].glyphType === GlyphType.LIST ? (newGlyphGroup = [spanGroupCached[0], spanGroupCached[1]], startIndex = 2) : newGlyphGroup = [spanGroupCached[0]];
21278
21278
  const column = currentLine.parent, { paragraphStart: lineIsStart } = column == null ? void 0 : column.lines.pop();
21279
21279
  _lineOperator(
21280
21280
  ctx,
21281
- newSpanGroup,
21281
+ newGlyphGroup,
21282
21282
  pages,
21283
21283
  sectionBreakConfig,
21284
21284
  paragraphConfig,
@@ -21293,28 +21293,45 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21293
21293
  pages,
21294
21294
  sectionBreakConfig,
21295
21295
  paragraphConfig,
21296
- paragraphStart
21296
+ isParagraphFirstShapedText
21297
21297
  );
21298
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21298
+ _divideOperator(
21299
+ ctx,
21300
+ glyphGroup,
21301
+ pages,
21302
+ sectionBreakConfig,
21303
+ paragraphConfig,
21304
+ isParagraphFirstShapedText,
21305
+ breakPointType
21306
+ );
21299
21307
  return;
21300
21308
  }
21301
21309
  }
21302
21310
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft), updateDivideInfo(divide, { breakType: breakPointType });
21303
21311
  }
21304
21312
  } else
21305
- _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight);
21313
+ _lineOperator(
21314
+ ctx,
21315
+ glyphGroup,
21316
+ pages,
21317
+ sectionBreakConfig,
21318
+ paragraphConfig,
21319
+ isParagraphFirstShapedText,
21320
+ breakPointType,
21321
+ defaultSpanLineHeight
21322
+ );
21306
21323
  }
21307
21324
  __name(_divideOperator, "_divideOperator");
21308
- function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21325
+ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultGlyphLineHeight) {
21309
21326
  var _a11, _b, _c, _d, _e, _f;
21310
21327
  let lastPage = getLastPage(pages), columnInfo = getLastNotFullColumnInfo(lastPage);
21311
- if ((!columnInfo || !columnInfo.column) && (_pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, void 0, breakPointType), lastPage = getLastPage(pages), columnInfo = getLastNotFullColumnInfo(lastPage)), !columnInfo) return;
21328
+ if ((!columnInfo || !columnInfo.column) && (_pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, !0, breakPointType), lastPage = getLastPage(pages), columnInfo = getLastNotFullColumnInfo(lastPage)), !columnInfo) return;
21312
21329
  const column = columnInfo.column;
21313
21330
  if (column.width <= 0) {
21314
21331
  console.error("The column width is less than 0, need to adjust page width to make it great than 0");
21315
21332
  return;
21316
21333
  }
21317
- const preLine = getLastLineByColumn(column), ascent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.ba)), descent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.bd)), spanLineHeight = defaultSpanLineHeight || ascent + descent, {
21334
+ const preLine = getLastLineByColumn(column), ascent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.ba)), descent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.bd)), glyphLineHeight = defaultGlyphLineHeight || ascent + descent, {
21318
21335
  paragraphStyle = {},
21319
21336
  paragraphAffectSkeDrawings,
21320
21337
  skeTablesInParagraph,
@@ -21330,11 +21347,18 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21330
21347
  hanging,
21331
21348
  indentStart,
21332
21349
  indentEnd
21333
- } = paragraphStyle, { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(
21350
+ } = paragraphStyle, {
21351
+ paragraphLineGapDefault,
21352
+ linePitch,
21353
+ lineSpacing,
21354
+ spacingRule,
21355
+ snapToGrid,
21356
+ gridType
21357
+ } = getLineHeightConfig(
21334
21358
  sectionBreakConfig,
21335
21359
  paragraphConfig
21336
21360
  ), { paddingTop, paddingBottom, contentHeight, lineSpacingApply } = __getLineHeight(
21337
- spanLineHeight,
21361
+ glyphLineHeight,
21338
21362
  paragraphLineGapDefault,
21339
21363
  linePitch,
21340
21364
  gridType,
@@ -21342,10 +21366,11 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21342
21366
  spacingRule,
21343
21367
  snapToGrid
21344
21368
  ), { marginTop, spaceBelowApply } = __getParagraphSpace(
21369
+ ctx,
21345
21370
  lineSpacingApply,
21346
21371
  spaceAbove,
21347
21372
  spaceBelow,
21348
- paragraphStart,
21373
+ isParagraphFirstShapedText,
21349
21374
  preLine
21350
21375
  ), lineHeight = marginTop + paddingTop + contentHeight + paddingBottom;
21351
21376
  let section = column.parent;
@@ -21356,12 +21381,12 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21356
21381
  const drawingsInLine = _getCustomBlockIdsInLine(preLine);
21357
21382
  if (drawingsInLine.length > 0) {
21358
21383
  const affectDrawings = (_d = (_c = ctx.paragraphConfigCache.get(segmentId)) == null ? void 0 : _c.get(preLine.paragraphIndex)) == null ? void 0 : _d.paragraphAffectSkeDrawings, relativeLineDrawings = [...(_e = affectDrawings == null ? void 0 : affectDrawings.values()) != null ? _e : []].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom === ObjectRelativeFromV.LINE).filter((drawing) => drawingsInLine.includes(drawing.drawingId));
21359
- relativeLineDrawings.length > 0 && __updateAndPositionDrawings(ctx, preLine.top, preLine.lineHeight, column, relativeLineDrawings, preLine.paragraphIndex, paragraphStart);
21384
+ relativeLineDrawings.length > 0 && __updateAndPositionDrawings(ctx, preLine.top, preLine.lineHeight, column, relativeLineDrawings, preLine.paragraphIndex, isParagraphFirstShapedText);
21360
21385
  }
21361
21386
  }
21362
21387
  if (paragraphAffectSkeDrawings != null && paragraphAffectSkeDrawings.size > 0) {
21363
21388
  const targetDrawings = [...paragraphAffectSkeDrawings.values()].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom !== ObjectRelativeFromV.LINE);
21364
- __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphConfig.paragraphIndex, paragraphStart, (_f = pDrawingAnchor == null ? void 0 : pDrawingAnchor.get(paragraphIndex)) == null ? void 0 : _f.top);
21389
+ __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, (_f = pDrawingAnchor == null ? void 0 : pDrawingAnchor.get(paragraphIndex)) == null ? void 0 : _f.top);
21365
21390
  }
21366
21391
  skeTablesInParagraph != null && skeTablesInParagraph.length > 0 && (needOpenNewPageByTableLayout = _updateAndPositionTable(lineTop, lastPage, section, skeTablesInParagraph));
21367
21392
  const newLineTop = calculateLineTopByDrawings(
@@ -21372,7 +21397,16 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21372
21397
  footerPage
21373
21398
  );
21374
21399
  if (lineHeight + newLineTop > section.height && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
21375
- if (setColumnFullState(column, !0), _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight), paragraphStart && paragraphAffectSkeDrawings && paragraphAffectSkeDrawings.size > 0)
21400
+ if (setColumnFullState(column, !0), _columnOperator(
21401
+ ctx,
21402
+ glyphGroup,
21403
+ pages,
21404
+ sectionBreakConfig,
21405
+ paragraphConfig,
21406
+ isParagraphFirstShapedText,
21407
+ breakPointType,
21408
+ defaultGlyphLineHeight
21409
+ ), isParagraphFirstShapedText && paragraphAffectSkeDrawings && paragraphAffectSkeDrawings.size > 0)
21376
21410
  for (const drawing of paragraphAffectSkeDrawings.values())
21377
21411
  lastPage.skeDrawings.has(drawing.drawingId) && lastPage.skeDrawings.delete(drawing.drawingId), ctx.drawingsCache.has(drawing.drawingId) && (ctx.drawingsCache.delete(drawing.drawingId), ctx.isDirty = !1, ctx.layoutStartPointer[segmentId] = null);
21378
21412
  return;
@@ -21384,7 +21418,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21384
21418
  indentStart,
21385
21419
  indentEnd,
21386
21420
  charSpaceApply,
21387
- paragraphStart
21421
+ isParagraphFirstShapedText
21388
21422
  );
21389
21423
  if (paddingLeft + paddingRight >= column.width) {
21390
21424
  const leftPercent = paddingLeft / (paddingLeft + paddingRight);
@@ -21406,23 +21440,32 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21406
21440
  },
21407
21441
  column.width,
21408
21442
  lineIndex,
21409
- paragraphStart,
21443
+ isParagraphFirstShapedText,
21410
21444
  paragraphConfig,
21411
21445
  lastPage,
21412
21446
  headerPage,
21413
21447
  footerPage
21414
21448
  );
21415
- column.lines.push(newLine), newLine.parent = column, createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor), _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight);
21449
+ column.lines.push(newLine), newLine.parent = column, createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor), _divideOperator(
21450
+ ctx,
21451
+ glyphGroup,
21452
+ pages,
21453
+ sectionBreakConfig,
21454
+ paragraphConfig,
21455
+ isParagraphFirstShapedText,
21456
+ breakPointType,
21457
+ defaultGlyphLineHeight
21458
+ );
21416
21459
  }
21417
21460
  __name(_lineOperator, "_lineOperator");
21418
- function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, paragraphStart, drawingAnchorTop) {
21461
+ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop) {
21419
21462
  if (targetDrawings.length === 0)
21420
21463
  return;
21421
21464
  const drawings = __getDrawingPosition(
21422
21465
  lineTop,
21423
21466
  lineHeight,
21424
21467
  column,
21425
- paragraphStart,
21468
+ isParagraphFirstShapedText,
21426
21469
  drawingAnchorTop,
21427
21470
  targetDrawings
21428
21471
  );
@@ -21552,29 +21595,56 @@ function checkRelativeDrawingNeedRePosition(ctx, drawing) {
21552
21595
  return !1;
21553
21596
  }
21554
21597
  __name(checkRelativeDrawingNeedRePosition, "checkRelativeDrawingNeedRePosition");
21555
- function _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21598
+ function _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21556
21599
  const lastPage = getLastPage(pages);
21557
- isColumnFull(lastPage) === !0 ? _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight) : _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight);
21600
+ isColumnFull(lastPage) === !0 ? _pageOperator(
21601
+ ctx,
21602
+ glyphGroup,
21603
+ pages,
21604
+ sectionBreakConfig,
21605
+ paragraphConfig,
21606
+ isParagraphFirstShapedText,
21607
+ breakPointType,
21608
+ defaultSpanLineHeight
21609
+ ) : _lineOperator(
21610
+ ctx,
21611
+ glyphGroup,
21612
+ pages,
21613
+ sectionBreakConfig,
21614
+ paragraphConfig,
21615
+ isParagraphFirstShapedText,
21616
+ breakPointType,
21617
+ defaultSpanLineHeight
21618
+ );
21558
21619
  }
21559
21620
  __name(_columnOperator, "_columnOperator");
21560
- function _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21621
+ function _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21561
21622
  const curSkeletonPage = getLastPage(pages), { skeHeaders, skeFooters } = paragraphConfig;
21562
- pages.push(createSkeletonPage(ctx, sectionBreakConfig, { skeHeaders, skeFooters }, (curSkeletonPage == null ? void 0 : curSkeletonPage.pageNumber) + 1)), _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight);
21623
+ pages.push(createSkeletonPage(ctx, sectionBreakConfig, { skeHeaders, skeFooters }, (curSkeletonPage == null ? void 0 : curSkeletonPage.pageNumber) + 1)), _columnOperator(
21624
+ ctx,
21625
+ glyphGroup,
21626
+ pages,
21627
+ sectionBreakConfig,
21628
+ paragraphConfig,
21629
+ isParagraphFirstShapedText,
21630
+ breakPointType,
21631
+ defaultSpanLineHeight
21632
+ );
21563
21633
  }
21564
21634
  __name(_pageOperator, "_pageOperator");
21565
- function __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, charSpaceApply, paragraphStart = !1) {
21635
+ function __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, charSpaceApply, isParagraphFirstShapedText = !1) {
21566
21636
  const indentFirstLineNumber = getNumberUnitValue(indentFirstLine, charSpaceApply), hangingNumber = getNumberUnitValue(hanging, charSpaceApply), indentStartNumber = getNumberUnitValue(indentStart, charSpaceApply), indentEndNumber = getNumberUnitValue(indentEnd, charSpaceApply);
21567
21637
  let paddingLeft = indentStartNumber;
21568
21638
  const paddingRight = indentEndNumber;
21569
- return indentFirstLineNumber > 0 && paragraphStart && (paddingLeft += indentFirstLineNumber), hangingNumber > 0 && !paragraphStart && (paddingLeft += hangingNumber), {
21639
+ return indentFirstLineNumber > 0 && isParagraphFirstShapedText && (paddingLeft += indentFirstLineNumber), hangingNumber > 0 && !isParagraphFirstShapedText && (paddingLeft += hangingNumber), {
21570
21640
  paddingLeft,
21571
21641
  paddingRight
21572
21642
  };
21573
21643
  }
21574
21644
  __name(__getIndentPadding, "__getIndentPadding");
21575
- function __getParagraphSpace(lineSpacing = 0, spaceAbove, spaceBelow, paragraphStart, preLine) {
21645
+ function __getParagraphSpace(ctx, lineSpacing = 0, spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine) {
21576
21646
  const spaceBelowApply = getNumberUnitValue(spaceBelow, lineSpacing);
21577
- if (paragraphStart) {
21647
+ if (isParagraphFirstShapedText) {
21578
21648
  let marginTop = getNumberUnitValue(spaceAbove, lineSpacing);
21579
21649
  if (preLine) {
21580
21650
  const { spaceBelowApply: preSpaceBelowApply } = preLine;
@@ -21594,25 +21664,25 @@ function __getParagraphSpace(lineSpacing = 0, spaceAbove, spaceBelow, paragraphS
21594
21664
  };
21595
21665
  }
21596
21666
  __name(__getParagraphSpace, "__getParagraphSpace");
21597
- function __getLineHeight(spanLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid) {
21667
+ function __getLineHeight(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid) {
21598
21668
  let paddingTop = paragraphLineGapDefault, paddingBottom = paragraphLineGapDefault;
21599
21669
  if (gridType === GridType.DEFAULT || snapToGrid === BooleanNumber.FALSE)
21600
21670
  return spacingRule === SpacingRule.AUTO ? {
21601
21671
  paddingTop,
21602
21672
  paddingBottom,
21603
- contentHeight: lineSpacing * spanLineHeight,
21604
- lineSpacingApply: spanLineHeight
21673
+ contentHeight: lineSpacing * glyphLineHeight,
21674
+ lineSpacingApply: glyphLineHeight
21605
21675
  } : {
21606
21676
  paddingTop,
21607
21677
  paddingBottom,
21608
- contentHeight: Math.max(lineSpacing, spanLineHeight),
21678
+ contentHeight: Math.max(lineSpacing, glyphLineHeight),
21609
21679
  lineSpacingApply: lineSpacing
21610
21680
  };
21611
21681
  let lineSpacingApply = 0;
21612
- return spacingRule === SpacingRule.AUTO ? lineSpacingApply = lineSpacing * linePitch : lineSpacingApply = lineSpacing, spanLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply && (paddingTop = paddingBottom = (lineSpacingApply - spanLineHeight) / 2), {
21682
+ return spacingRule === SpacingRule.AUTO ? lineSpacingApply = lineSpacing * linePitch : lineSpacingApply = lineSpacing, glyphLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply ? paddingTop = paddingBottom = (lineSpacingApply - glyphLineHeight) / 2 : lineSpacingApply = glyphLineHeight, {
21613
21683
  paddingTop,
21614
21684
  paddingBottom,
21615
- contentHeight: spanLineHeight,
21685
+ contentHeight: glyphLineHeight,
21616
21686
  lineSpacingApply
21617
21687
  };
21618
21688
  }
@@ -21622,7 +21692,7 @@ function updateInlineDrawingPosition(line2, paragraphInlineSkeDrawings, blockAnc
21622
21692
  const column = line2.parent, page = (_b = (_a11 = line2 == null ? void 0 : line2.parent) == null ? void 0 : _a11.parent) == null ? void 0 : _b.parent;
21623
21693
  if (page == null || column == null)
21624
21694
  return;
21625
- const isPageBreak = __checkPageBreak(column), drawings = /* @__PURE__ */ new Map(), { top, lineHeight } = line2;
21695
+ const isPageBreak = __checkPageBreak(column), drawings = /* @__PURE__ */ new Map(), { top, lineHeight, marginBottom = 0 } = line2;
21626
21696
  for (const divide of line2.divides)
21627
21697
  for (const glyph of divide.glyphGroup)
21628
21698
  if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0) {
@@ -21633,19 +21703,19 @@ function updateInlineDrawingPosition(line2, paragraphInlineSkeDrawings, blockAnc
21633
21703
  if (drawingOrigin == null || drawing == null)
21634
21704
  continue;
21635
21705
  const { docTransform } = drawingOrigin, { size, angle } = docTransform, { width = 0, height = 0 } = size, glyphHeight = glyph.bBox.bd + glyph.bBox.ba;
21636
- drawing.aLeft = divide.left + divide.paddingLeft + glyph.left + 0.5 * glyph.width - 0.5 * width || 0, drawing.aTop = top + lineHeight - 0.5 * glyphHeight - 0.5 * height || 0, drawing.width = width, drawing.height = height, drawing.angle = angle, drawing.isPageBreak = isPageBreak, drawing.lineTop = top, drawing.columnLeft = column.left, drawing.blockAnchorTop = blockAnchorTop != null ? blockAnchorTop : top, drawing.lineHeight = line2.lineHeight, drawings.set(drawing.drawingId, drawing);
21706
+ drawing.aLeft = divide.left + divide.paddingLeft + glyph.left + 0.5 * glyph.width - 0.5 * width || 0, drawing.aTop = top + lineHeight - 0.5 * glyphHeight - 0.5 * height - marginBottom, drawing.width = width, drawing.height = height, drawing.angle = angle, drawing.isPageBreak = isPageBreak, drawing.lineTop = top, drawing.columnLeft = column.left, drawing.blockAnchorTop = blockAnchorTop != null ? blockAnchorTop : top, drawing.lineHeight = line2.lineHeight, drawings.set(drawing.drawingId, drawing);
21637
21707
  }
21638
21708
  const res = new Map([...page.skeDrawings, ...drawings]);
21639
21709
  page.skeDrawings = res;
21640
21710
  }
21641
21711
  __name(updateInlineDrawingPosition, "updateInlineDrawingPosition");
21642
- function __getDrawingPosition(lineTop, lineHeight, column, paragraphStart, blockAnchorTop, needPositionDrawings = []) {
21712
+ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = []) {
21643
21713
  var _a11, _b, _c;
21644
21714
  const page = (_a11 = column.parent) == null ? void 0 : _a11.parent;
21645
21715
  if (page == null || needPositionDrawings.length === 0)
21646
21716
  return;
21647
21717
  const drawings = /* @__PURE__ */ new Map(), isPageBreak = __checkPageBreak(column);
21648
- if (!(isPageBreak && !paragraphStart)) {
21718
+ if (!(isPageBreak && !isParagraphFirstShapedText)) {
21649
21719
  for (const drawing of needPositionDrawings) {
21650
21720
  const { drawingOrigin } = drawing;
21651
21721
  if (!drawingOrigin)
@@ -21721,10 +21791,10 @@ function __maxFontBoundingBoxByGlyphGroup(glyphGroup) {
21721
21791
  return maxBox;
21722
21792
  }
21723
21793
  __name(__maxFontBoundingBoxByGlyphGroup, "__maxFontBoundingBoxByGlyphGroup");
21724
- function __getSpanGroupByLine({ divides }) {
21794
+ function __getGlyphGroupByLine({ divides }) {
21725
21795
  return divides.flatMap((divide) => divide.glyphGroup);
21726
21796
  }
21727
- __name(__getSpanGroupByLine, "__getSpanGroupByLine");
21797
+ __name(__getGlyphGroupByLine, "__getGlyphGroupByLine");
21728
21798
  function __isNullLine(line2) {
21729
21799
  return !line2.divides[0].glyphGroup[0];
21730
21800
  }
@@ -22044,7 +22114,13 @@ function getFontConfigFromLastGlyph(glyph, sectionBreakConfig, paragraphStyle) {
22044
22114
  };
22045
22115
  }
22046
22116
  __name(getFontConfigFromLastGlyph, "getFontConfigFromLastGlyph");
22047
- function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
22117
+ function getBulletParagraphTextStyle(bullet, viewModel) {
22118
+ var _a11;
22119
+ const { listType } = bullet;
22120
+ return (_a11 = viewModel.getDataModel().getBulletPresetList()[listType].nestingLevel[0].paragraphProperties) == null ? void 0 : _a11.textStyle;
22121
+ }
22122
+ __name(getBulletParagraphTextStyle, "getBulletParagraphTextStyle");
22123
+ function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
22048
22124
  const {
22049
22125
  gridType = GridType.LINES,
22050
22126
  charSpace = 0,
@@ -22057,18 +22133,18 @@ function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfi
22057
22133
  marginLeft = 0,
22058
22134
  localeService,
22059
22135
  renderConfig = {}
22060
- } = sectionBreakConfig, { isRenderStyle } = renderConfig, { startIndex } = paragraphNode, textRun = isRenderStyle === BooleanNumber.FALSE ? { ts: {}, st: 0, ed: 0 } : viewModel.getTextRun(index2 + startIndex) || { ts: {}, st: 0, ed: 0 }, customDecoration = viewModel.getCustomDecoration(index2 + startIndex), showCustomDecoration = customDecoration && customDecoration.show !== !1, customDecorationStyle = showCustomDecoration ? getCustomDecorationStyle(customDecoration) : null, customRange = viewModel.getCustomRange(index2 + startIndex), showCustomRange = customRange && customRange.show !== !1, customRangeStyle = showCustomRange ? getCustomRangeStyle(customRange) : null, hasAddonStyle = showCustomRange || showCustomDecoration, { st, ed } = textRun;
22136
+ } = sectionBreakConfig, { paragraphStyle = {}, bullet } = paragraph, { isRenderStyle } = renderConfig, { startIndex } = paragraphNode, textRun = isRenderStyle === BooleanNumber.FALSE ? { ts: {}, st: 0, ed: 0 } : viewModel.getTextRun(index2 + startIndex) || { ts: {}, st: 0, ed: 0 }, customDecoration = viewModel.getCustomDecoration(index2 + startIndex), showCustomDecoration = customDecoration && customDecoration.show !== !1, customDecorationStyle = showCustomDecoration ? getCustomDecorationStyle(customDecoration) : null, customRange = viewModel.getCustomRange(index2 + startIndex), showCustomRange = customRange && customRange.show !== !1, customRangeStyle = showCustomRange ? getCustomRangeStyle(customRange) : null, hasAddonStyle = showCustomRange || showCustomDecoration, { st, ed } = textRun;
22061
22137
  let { ts: textStyle = {} } = textRun;
22062
22138
  const cache = fontCreateConfigCache.getValue(st, ed);
22063
22139
  if (cache && !hasAddonStyle)
22064
22140
  return cache;
22065
- const { snapToGrid = BooleanNumber.TRUE, textStyle: paragraphStyleTextStyle } = paragraphStyle;
22141
+ const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle, bulletTextStyle = bullet ? getBulletParagraphTextStyle(bullet, viewModel) : null;
22066
22142
  textStyle = {
22067
22143
  ...documentTextStyle,
22068
22144
  ...textStyle,
22069
22145
  ...customDecorationStyle,
22070
22146
  ...customRangeStyle,
22071
- ...paragraphStyleTextStyle
22147
+ ...bulletTextStyle
22072
22148
  };
22073
22149
  const fontStyle = getFontStyleString(textStyle), mixTextStyle = {
22074
22150
  ...documentTextStyle,
@@ -22328,14 +22404,14 @@ const _Liquid = class _Liquid {
22328
22404
  y: 0
22329
22405
  };
22330
22406
  }
22331
- translateLine(line2, isDraw = !1) {
22407
+ translateLine(line2, includeMarginTop = !1, includePaddingTop = !1) {
22332
22408
  const {
22333
22409
  top: lineTop,
22334
22410
  marginBottom: _lineMarginBottom = 0,
22335
22411
  marginTop: lineMarginTop = 0,
22336
22412
  paddingTop: linePaddingTop = 0,
22337
22413
  paddingBottom: _linePaddingBottom = 0
22338
- } = line2, lineOffset = lineTop + (isDraw === !0 ? lineMarginTop : 0) + linePaddingTop;
22414
+ } = line2, lineOffset = lineTop + (includeMarginTop ? lineMarginTop : 0) + (includePaddingTop ? linePaddingTop : 0);
22339
22415
  return this.translate(0, lineOffset), {
22340
22416
  x: 0,
22341
22417
  y: lineOffset
@@ -22544,6 +22620,8 @@ const _DocumentViewModel = class _DocumentViewModel {
22544
22620
  __publicField(this, "editAreaChange$", this._editAreaChange$.asObservable());
22545
22621
  __publicField(this, "headerTreeMap", /* @__PURE__ */ new Map());
22546
22622
  __publicField(this, "footerTreeMap", /* @__PURE__ */ new Map());
22623
+ __publicField(this, "_segmentViewModels$", new BehaviorSubject([]));
22624
+ __publicField(this, "segmentViewModels$", this._segmentViewModels$.asObservable());
22547
22625
  this._documentDataModel = _documentDataModel, _documentDataModel.getBody() != null && (this.children = parseDataStreamToTree(_documentDataModel.getBody().dataStream), this._buildHeaderFooterViewModel());
22548
22626
  }
22549
22627
  registerCustomRangeInterceptor(interceptor) {
@@ -22783,11 +22861,12 @@ const _DocumentViewModel = class _DocumentViewModel {
22783
22861
  return this._interceptor ? this._interceptor.getCustomDecoration(index2) : this.getCustomDecorationRaw(index2);
22784
22862
  }
22785
22863
  _buildHeaderFooterViewModel() {
22786
- const { headerModelMap, footerModelMap } = this._documentDataModel;
22864
+ const { headerModelMap, footerModelMap } = this._documentDataModel, viewModels = [];
22787
22865
  for (const [headerId, headerModel] of headerModelMap)
22788
- this.headerTreeMap.set(headerId, new _DocumentViewModel(headerModel));
22866
+ this.headerTreeMap.set(headerId, new _DocumentViewModel(headerModel)), viewModels.push(this.headerTreeMap.get(headerId));
22789
22867
  for (const [footerId, footerModel] of footerModelMap)
22790
- this.footerTreeMap.set(footerId, new _DocumentViewModel(footerModel));
22868
+ this.footerTreeMap.set(footerId, new _DocumentViewModel(footerModel)), viewModels.push(this.footerTreeMap.get(footerId));
22869
+ this._segmentViewModels$.next(viewModels);
22791
22870
  }
22792
22871
  _getParagraphByIndex(nodes, insertIndex) {
22793
22872
  for (const node of nodes) {
@@ -22995,7 +23074,7 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
22995
23074
  );
22996
23075
  const { start, end } = compareNodePosition(startOrigin, endOrigin);
22997
23076
  return this._selectionIterator(start, end, (start_sp, end_sp, isFirst, isLast, divide, line2) => {
22998
- const { lineHeight, marginTop, asc, paddingTop } = line2, { glyphGroup, st } = divide;
23077
+ const { lineHeight, asc, paddingTop, marginTop, marginBottom } = line2, { glyphGroup, st } = divide;
22999
23078
  if (glyphGroup.length === 0)
23000
23079
  return;
23001
23080
  const { x: startX, y: startY } = this._liquid;
@@ -23006,12 +23085,12 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
23006
23085
  startX: startX + firstGlyphLeft + (isCurrentList ? firstGlyphWidth : 0),
23007
23086
  startY,
23008
23087
  endX: startX + lastGlyphLeft + lastGlyphWidth,
23009
- endY: startY + lineHeight
23088
+ endY: startY + lineHeight - marginTop - marginBottom
23010
23089
  }, contentBoxPosition = {
23011
23090
  startX: startX + firstGlyphLeft + (isCurrentList ? firstGlyphWidth : 0),
23012
- startY: startY + marginTop + paddingTop + asc - anchorGlyph.bBox.ba,
23091
+ startY: startY + paddingTop + asc - anchorGlyph.bBox.ba,
23013
23092
  endX: startX + lastGlyphLeft + lastGlyphWidth,
23014
- endY: startY + marginTop + paddingTop + asc + anchorGlyph.bBox.bd
23093
+ endY: startY + paddingTop + asc + anchorGlyph.bBox.bd
23015
23094
  };
23016
23095
  else {
23017
23096
  const isStartBackFin = isStartBack && !isCurrentList;
@@ -23019,12 +23098,12 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
23019
23098
  startX: startX + firstGlyphLeft + (isStartBackFin ? 0 : firstGlyphWidth),
23020
23099
  startY,
23021
23100
  endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
23022
- endY: startY + lineHeight
23101
+ endY: startY + lineHeight - marginTop - marginBottom
23023
23102
  }, contentBoxPosition = {
23024
23103
  startX: startX + firstGlyphLeft + (isStartBackFin ? 0 : firstGlyphWidth),
23025
- startY: startY + marginTop + paddingTop + asc - anchorGlyph.bBox.ba,
23104
+ startY: startY + paddingTop + asc - anchorGlyph.bBox.ba,
23026
23105
  endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
23027
- endY: startY + marginTop + paddingTop + asc + anchorGlyph.bBox.bd
23106
+ endY: startY + paddingTop + asc + anchorGlyph.bBox.bd
23028
23107
  };
23029
23108
  }
23030
23109
  borderBoxPointGroup.push(pushToPoints(borderBoxPosition)), contentBoxPointGroup.push(pushToPoints(contentBoxPosition)), cursorList.push({
@@ -23175,7 +23254,7 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
23175
23254
  divides.length - 1,
23176
23255
  l
23177
23256
  );
23178
- this._liquid.translateSave(), this._liquid.translateLine(line2);
23257
+ this._liquid.translateSave(), this._liquid.translateLine(line2, !0, !1);
23179
23258
  for (let d = start_d; d <= end_d; d++) {
23180
23259
  const divide = divides[d];
23181
23260
  this._liquid.translateSave(), this._liquid.translateDivide(divide);
@@ -23778,6 +23857,8 @@ __name(getPagePath, "getPagePath");
23778
23857
  const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
23779
23858
  constructor(_docViewModel, localeService) {
23780
23859
  super(localeService);
23860
+ __publicField(this, "_dirty$", new Subject());
23861
+ __publicField(this, "dirty$", this._dirty$.asObservable());
23781
23862
  __publicField(this, "_skeletonData");
23782
23863
  __publicField(this, "_findLiquid", new Liquid());
23783
23864
  // Use for hyphenation.
@@ -23800,7 +23881,7 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
23800
23881
  if (!this.dirty)
23801
23882
  return;
23802
23883
  const ctx = this._prepareLayoutContext();
23803
- this._skeletonData = this._createSkeleton(ctx, bounds);
23884
+ this._skeletonData = this._createSkeleton(ctx, bounds), this._dirty$.next(!0);
23804
23885
  }
23805
23886
  getSkeletonData() {
23806
23887
  return this._skeletonData;
@@ -24126,7 +24207,9 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24126
24207
  _collectNearestNode(segmentPage, pageType, page, segmentId, pi, cache, x, y, nestLevel = 0) {
24127
24208
  var _a11, _b, _c, _d, _e, _f, _g, _h, _i;
24128
24209
  const { sections, skeTables } = segmentPage;
24129
- switch (this._findLiquid.translateSave(), pageType) {
24210
+ this._findLiquid.translateSave();
24211
+ const pageLeft = this._findLiquid.x, pageRight = pageLeft + page.pageWidth, pageTop = this._findLiquid.y + (pageType === DocumentSkeletonPageType.FOOTER ? page.pageHeight - segmentPage.pageHeight : 0), pageBottom = pageTop + segmentPage.pageHeight, pointInPage = x >= pageLeft && x <= pageRight && y >= pageTop && y <= pageBottom;
24212
+ switch (pageType) {
24130
24213
  case DocumentSkeletonPageType.HEADER: {
24131
24214
  this._findLiquid.translatePagePadding({
24132
24215
  ...segmentPage,
@@ -24145,7 +24228,6 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24145
24228
  break;
24146
24229
  }
24147
24230
  }
24148
- const pointInPage = x >= this._findLiquid.x && x <= this._findLiquid.x + segmentPage.pageWidth && y >= this._findLiquid.y && y <= this._findLiquid.y + segmentPage.pageHeight;
24149
24231
  if (pointInPage)
24150
24232
  for (const section of sections) {
24151
24233
  const { columns } = section;
@@ -24721,6 +24803,10 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24721
24803
  }
24722
24804
  return Math.min(height, MAXIMUM_ROW_HEIGHT);
24723
24805
  }
24806
+ /**
24807
+ * Calculate data for row col & cell position, then update position value to this._rowHeaderWidth & this._rowHeightAccumulation & this._columnHeaderHeight & this._columnWidthAccumulation.
24808
+ * @returns this
24809
+ */
24724
24810
  _updateLayout() {
24725
24811
  if (!this.dirty)
24726
24812
  return;
@@ -25275,18 +25361,20 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25275
25361
  // return mergeRangeCache;
25276
25362
  // }
25277
25363
  _calculateStylesCache() {
25278
- const dataMergeCache = this._dataMergeCache, rowColumnSegment = this._rowColumnSegment, columnWidthAccumulation = this.columnWidthAccumulation, { startRow, endRow, startColumn, endColumn } = rowColumnSegment;
25364
+ const dataMergeCaches = this._dataMergeCache, rowColumnSegment = this._rowColumnSegment, columnWidthAccumulation = this.columnWidthAccumulation, { startRow, endRow, startColumn, endColumn } = rowColumnSegment;
25279
25365
  if (!(endColumn === -1 || endRow === -1)) {
25280
- for (const data2 of dataMergeCache)
25281
- this._setCellCache(data2.startRow, data2.startColumn, !1, data2);
25366
+ for (const mergeRange of dataMergeCaches)
25367
+ this._setCellStylesCache(mergeRange.startRow, mergeRange.startColumn, {
25368
+ mergeRange
25369
+ });
25282
25370
  for (let r = startRow; r <= endRow; r++) {
25283
25371
  for (let c = startColumn; c <= endColumn; c++)
25284
- this._setCellCache(r, c, !1);
25372
+ this._setCellStylesCache(r, c);
25285
25373
  for (let c = 0; c < startColumn; c++)
25286
- this._setCellCache(r, c, !0);
25374
+ this._setCellStylesCache(r, c, { cacheItem: { bg: !1, border: !1 } });
25287
25375
  if (endColumn !== 0)
25288
25376
  for (let c = endColumn + 1; c < columnWidthAccumulation.length; c++)
25289
- this._setCellCache(r, c, !0);
25377
+ this._setCellStylesCache(r, c, { cacheItem: { bg: !1, border: !1 } });
25290
25378
  }
25291
25379
  }
25292
25380
  }
@@ -25314,11 +25402,11 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25314
25402
  }
25315
25403
  }
25316
25404
  // eslint-disable-next-line complexity
25317
- _setCellCache(r, c, skipBackgroundAndBorder, mergeRange) {
25405
+ _setCellStylesCache(r, c, options) {
25318
25406
  var _a11;
25319
- const needsRendering = this._renderedCellCache.getValue(r, c);
25320
25407
  if (r === -1 || c === -1)
25321
25408
  return !0;
25409
+ const needsRendering = this._renderedCellCache.getValue(r, c);
25322
25410
  if (needsRendering === !1)
25323
25411
  return this._makeDocumentSkeletonDirty(r, c), !0;
25324
25412
  const cell = this.worksheet.getCell(r, c) || this.worksheet.getCellRaw(r, c);
@@ -25335,14 +25423,18 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25335
25423
  if (!isMergedMainCell)
25336
25424
  return !0;
25337
25425
  }
25338
- const cache = this._stylesCache, style = this._styles.getStyleByCell(cell);
25339
- if (!skipBackgroundAndBorder && style && style.bg && style.bg.rgb) {
25426
+ const cache = this._stylesCache, style = this._styles.getStyleByCell(cell), cacheItem = (options == null ? void 0 : options.cacheItem) || { bg: !0, border: !0 };
25427
+ if (cacheItem.bg && style && style.bg && style.bg.rgb) {
25340
25428
  const rgb = style.bg.rgb;
25341
25429
  cache.background[rgb] || (cache.background[rgb] = new ObjectMatrix()), cache.background[rgb].setValue(r, c, rgb);
25342
25430
  const cellInfo = this.getCellByIndexWithNoHeader(r, c);
25343
25431
  (_a11 = cache.backgroundPositions) == null || _a11.setValue(r, c, cellInfo);
25344
25432
  }
25345
- if (!skipBackgroundAndBorder && style && style.bd && (mergeRange ? (this._setMergeBorderProps(BORDER_TYPE.TOP, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.BOTTOM, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.LEFT, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.RIGHT, cache, mergeRange)) : this.intersectMergeRange(r, c) || (this._setBorderProps(r, c, BORDER_TYPE.TOP, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BOTTOM, style, cache), this._setBorderProps(r, c, BORDER_TYPE.LEFT, style, cache), this._setBorderProps(r, c, BORDER_TYPE.RIGHT, style, cache)), this._setBorderProps(r, c, BORDER_TYPE.TL_BR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.TL_BC, style, cache), this._setBorderProps(r, c, BORDER_TYPE.TL_MR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BL_TR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.ML_TR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BC_TR, style, cache)), needsRendering === !0)
25433
+ if (cacheItem.border && style && style.bd) {
25434
+ const mergeRange = options == null ? void 0 : options.mergeRange;
25435
+ mergeRange ? (this._setMergeBorderProps(BORDER_TYPE.TOP, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.BOTTOM, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.LEFT, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.RIGHT, cache, mergeRange)) : this.intersectMergeRange(r, c) || (this._setBorderProps(r, c, BORDER_TYPE.TOP, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BOTTOM, style, cache), this._setBorderProps(r, c, BORDER_TYPE.LEFT, style, cache), this._setBorderProps(r, c, BORDER_TYPE.RIGHT, style, cache)), this._setBorderProps(r, c, BORDER_TYPE.TL_BR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.TL_BC, style, cache), this._setBorderProps(r, c, BORDER_TYPE.TL_MR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BL_TR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.ML_TR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BC_TR, style, cache);
25436
+ }
25437
+ if (needsRendering === !0)
25346
25438
  return this._makeDocumentSkeletonDirty(r, c), !0;
25347
25439
  if (isNullCell(cell))
25348
25440
  return;
@@ -25370,7 +25462,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25370
25462
  };
25371
25463
  fontCache2.setValue(r, c, config), this._calculateOverflowCell(r, c, config);
25372
25464
  }
25373
- skipBackgroundAndBorder ? this._renderedCellCache.setValue(r, c, !0) : this._renderedCellCache.setValue(r, c, !1);
25465
+ cacheItem.bg || cacheItem.border ? this._renderedCellCache.setValue(r, c, !1) : this._renderedCellCache.setValue(r, c, !0);
25374
25466
  }
25375
25467
  _updateConfigAndGetDocumentModel(documentData, horizontalAlign, renderConfig) {
25376
25468
  var _a11;
@@ -25584,14 +25676,13 @@ const UNIQUE_KEY$7 = "DefaultFontExtension", EXTENSION_Z_INDEX = 45, _Font = cla
25584
25676
  }
25585
25677
  draw(ctx, parentScale, spreadsheetSkeleton, diffRanges, moreBoundsInfo) {
25586
25678
  const { viewRanges = [], checkOutOfViewBound } = moreBoundsInfo, { stylesCache, dataMergeCache, overflowCache, worksheet } = spreadsheetSkeleton, { font: fontList } = stylesCache;
25587
- if (!spreadsheetSkeleton || !worksheet)
25679
+ if (!spreadsheetSkeleton || !worksheet || !fontList)
25588
25680
  return;
25589
25681
  const { rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;
25590
25682
  if (!rowHeightAccumulation || !columnWidthAccumulation || columnTotalWidth === void 0 || rowTotalHeight === void 0 || !worksheet)
25591
25683
  return;
25592
25684
  ctx.save();
25593
- const scale = this._getScale(parentScale);
25594
- fontList && Object.keys(fontList).forEach((fontFormat) => {
25685
+ const scale = this._getScale(parentScale), renderFontByCell = /* @__PURE__ */ __name((fontFormat) => {
25595
25686
  fontList[fontFormat].forValue((rowIndex, columnIndex, docsConfig) => {
25596
25687
  var _a11, _b, _c, _d, _e;
25597
25688
  if (!checkOutOfViewBound && !inViewRanges(viewRanges, rowIndex, columnIndex))
@@ -25666,7 +25757,8 @@ const UNIQUE_KEY$7 = "DefaultFontExtension", EXTENSION_Z_INDEX = 45, _Font = cla
25666
25757
  ctx.rectByPrecision(startX + 1 / scale, startY + 1 / scale, cellWidth - 2 / scale, cellHeight - 2 / scale), ctx.clip();
25667
25758
  ctx.translate(startX + FIX_ONE_PIXEL_BLUR_OFFSET, startY + FIX_ONE_PIXEL_BLUR_OFFSET), this._renderDocuments(ctx, docsConfig, startX, startY, endX, endY, rowIndex, columnIndex, overflowCache), ctx.closePath(), ctx.restore();
25668
25759
  });
25669
- }), ctx.restore();
25760
+ }, "renderFontByCell");
25761
+ Object.keys(fontList).forEach(renderFontByCell), ctx.restore();
25670
25762
  }
25671
25763
  _renderDocuments(ctx, docsConfig, startX, startY, endX, endY, row, column, overflowCache) {
25672
25764
  const documents = this.getDocuments();
@@ -27334,12 +27426,11 @@ const RICHTEXT_OBJECT_ARRAY = ["text", "richText", "fs"], _RichText = class _Ric
27334
27426
  }), this.setProps(props), this.makeDirty(!0);
27335
27427
  }
27336
27428
  /**
27337
- *
27338
- * it should be invoked when _documentData changed.
27339
- * _documentData changed ---> update _documentSkeleton & _documentSkeleton
27340
- *
27341
- * now it is invoked when transformByState(change editor size) & end of editing
27429
+ * After changing editor size & end of editing, update skeleton of doc.
27342
27430
  */
27431
+ // TODO: This method should be invoked when _documentData changed.
27432
+ // _documentData changed ---> update _documentSkeleton & _documentSkeleton
27433
+ // now it is invoked when transformByState(change editor size) & end of editing
27343
27434
  refreshDocumentByDocData() {
27344
27435
  const docModel = this.documentModel = new DocumentDataModel(this._documentData), docViewModel = new DocumentViewModel(docModel);
27345
27436
  this._documentSkeleton = DocumentSkeleton.create(docViewModel, this._localeService), this._documents = new Documents(`${this.oKey}_DOCUMENTS`, this._documentSkeleton, {
@@ -27746,21 +27837,21 @@ const UNIQUE_KEY = "DefaultDocsLineExtension", DOC_EXTENSION_Z_INDEX = 40, _Line
27746
27837
  const line2 = (_a11 = glyph.parent) == null ? void 0 : _a11.parent, { ts: textStyle, bBox, content } = glyph;
27747
27838
  if (line2 == null || textStyle == null || content === "\r")
27748
27839
  return;
27749
- const { asc, dsc, paddingTop } = line2, { sp: strikeoutPosition, spo, sbo, bd } = bBox, scale = getScale(parentScale), DELTA = 0.5, { ul: underline, st: strikethrough, ol: overline, va: baselineOffset, bbl: bottomBorderLine } = textStyle;
27840
+ const { asc, dsc } = line2, { sp: strikeoutPosition, spo, sbo, bd } = bBox, scale = getScale(parentScale), DELTA = 0.5, { ul: underline, st: strikethrough, ol: overline, va: baselineOffset, bbl: bottomBorderLine } = textStyle;
27750
27841
  if (underline) {
27751
- const startY = asc + dsc + paddingTop;
27842
+ const startY = asc + dsc;
27752
27843
  this._drawLine(ctx, glyph, underline, startY, scale);
27753
27844
  }
27754
27845
  if (bottomBorderLine) {
27755
- const startY = asc + dsc + 3 + paddingTop;
27846
+ const startY = asc + dsc + 3;
27756
27847
  this._drawLine(ctx, glyph, bottomBorderLine, startY, scale, 2);
27757
27848
  }
27758
27849
  if (strikethrough) {
27759
- let startY = asc + bd - strikeoutPosition - DELTA + paddingTop;
27850
+ let startY = asc + bd - strikeoutPosition - DELTA;
27760
27851
  baselineOffset === BaselineOffset.SUPERSCRIPT ? startY -= spo : baselineOffset === BaselineOffset.SUBSCRIPT && (startY += sbo), this._drawLine(ctx, glyph, strikethrough, startY, scale);
27761
27852
  }
27762
27853
  if (overline) {
27763
- const startY = -DEFAULT_OFFSET_SPACING - DELTA + paddingTop;
27854
+ const startY = -DEFAULT_OFFSET_SPACING - DELTA;
27764
27855
  this._drawLine(ctx, glyph, overline, startY, scale);
27765
27856
  }
27766
27857
  }
@@ -28015,7 +28106,7 @@ const _Documents = class _Documents extends DocComponent {
28015
28106
  rotatedHeight > this.height && (vertexAngle < 0 ? exceedHeightFix = this.height - (rotatedHeight + fixOffsetY) : exceedHeightFix = -fixOffsetY), alignOffset = Vector2.create(horizontalOffset + fixOffsetX, exceedHeightFix), this._drawLiquid.translate(0, -rotateTranslateY), rotateTranslateXListApply = rotateTranslateXList;
28016
28107
  } else wrapStrategy === WrapStrategy.WRAP && (horizontalAlign !== HorizontalAlign.UNSPECIFIED || cellValueType !== CellValueType.NUMBER) && (alignOffset.x = pagePaddingLeft);
28017
28108
  for (let i2 = 0; i2 < linesCount; i2++) {
28018
- const line2 = lines[i2], { divides, asc = 0, type, lineHeight = 0, paddingTop } = line2, maxLineAsc = asc, maxLineAscSin = maxLineAsc * Math.sin(centerAngle), maxLineAscCos = maxLineAsc * Math.cos(centerAngle);
28109
+ const line2 = lines[i2], { divides, asc = 0, type, lineHeight = 0 } = line2, maxLineAsc = asc, maxLineAscSin = maxLineAsc * Math.sin(centerAngle), maxLineAscCos = maxLineAsc * Math.cos(centerAngle);
28019
28110
  if (type === LineType.BLOCK)
28020
28111
  for (const extension of extensions)
28021
28112
  extension.type === DOCS_EXTENSION_TYPE.LINE && (extension.extensionOffset = {
@@ -28023,7 +28114,7 @@ const _Documents = class _Documents extends DocComponent {
28023
28114
  renderConfig
28024
28115
  }, extension.draw(ctx, parentScale, line2));
28025
28116
  else {
28026
- this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0), rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i2]);
28117
+ this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0, !0), rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i2]);
28027
28118
  const divideLength = divides.length;
28028
28119
  for (let i3 = 0; i3 < divideLength; i3++) {
28029
28120
  const divide = divides[i3], { glyphGroup } = divide;
@@ -28033,7 +28124,7 @@ const _Documents = class _Documents extends DocComponent {
28033
28124
  continue;
28034
28125
  const { width: spanWidth, left: spanLeft } = glyph, { x: translateX, y: translateY } = this._drawLiquid, originTranslate = Vector2.create(translateX, translateY), centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2), extensionOffset = {
28035
28126
  spanStartPoint: calculateRectRotate(
28036
- originTranslate.addByPoint(spanLeft, paddingTop),
28127
+ originTranslate.addByPoint(spanLeft, 0),
28037
28128
  centerPoint,
28038
28129
  centerAngle,
28039
28130
  vertexAngle,
@@ -28046,7 +28137,7 @@ const _Documents = class _Documents extends DocComponent {
28046
28137
  if (!glyph.content || glyph.content.length === 0)
28047
28138
  continue;
28048
28139
  const { width: spanWidth, left: spanLeft, xOffset } = glyph, { x: translateX, y: translateY } = this._drawLiquid, originTranslate = Vector2.create(translateX, translateY), centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2), spanStartPoint = calculateRectRotate(
28049
- originTranslate.addByPoint(spanLeft + xOffset, paddingTop),
28140
+ originTranslate.addByPoint(spanLeft + xOffset, 0),
28050
28141
  centerPoint,
28051
28142
  centerAngle,
28052
28143
  vertexAngle,
@@ -28054,7 +28145,7 @@ const _Documents = class _Documents extends DocComponent {
28054
28145
  ), spanPointWithFont = calculateRectRotate(
28055
28146
  originTranslate.addByPoint(
28056
28147
  spanLeft + maxLineAscSin + xOffset,
28057
- maxLineAscCos + paddingTop
28148
+ maxLineAscCos
28058
28149
  ),
28059
28150
  centerPoint,
28060
28151
  centerAngle,
@@ -28160,7 +28251,7 @@ const _Documents = class _Documents extends DocComponent {
28160
28251
  this._drawLiquid.translateSave(), this._drawLiquid.translateColumn(column);
28161
28252
  const linesCount = lines.length, alignOffset = alignOffsetNoAngle;
28162
28253
  for (let i = 0; i < linesCount; i++) {
28163
- const line2 = lines[i], { divides, asc = 0, type, lineHeight = 0, paddingTop } = line2, maxLineAsc = asc, maxLineAscSin = maxLineAsc * Math.sin(centerAngle), maxLineAscCos = maxLineAsc * Math.cos(centerAngle);
28254
+ const line2 = lines[i], { divides, asc = 0, type, lineHeight = 0 } = line2, maxLineAsc = asc, maxLineAscSin = maxLineAsc * Math.sin(centerAngle), maxLineAscCos = maxLineAsc * Math.cos(centerAngle);
28164
28255
  if (type === LineType.BLOCK)
28165
28256
  for (const extension of extensions)
28166
28257
  extension.type === DOCS_EXTENSION_TYPE.LINE && (extension.extensionOffset = {
@@ -28168,7 +28259,7 @@ const _Documents = class _Documents extends DocComponent {
28168
28259
  renderConfig
28169
28260
  }, extension.draw(ctx, parentScale, line2));
28170
28261
  else {
28171
- this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0);
28262
+ this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0, !0);
28172
28263
  const divideLength = divides.length;
28173
28264
  for (let i2 = 0; i2 < divideLength; i2++) {
28174
28265
  const divide = divides[i2], { glyphGroup } = divide;
@@ -28178,7 +28269,7 @@ const _Documents = class _Documents extends DocComponent {
28178
28269
  continue;
28179
28270
  const { width: spanWidth, left: spanLeft } = glyph, { x: translateX, y: translateY } = this._drawLiquid, originTranslate = Vector2.create(translateX, translateY), centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2), extensionOffset = {
28180
28271
  spanStartPoint: calculateRectRotate(
28181
- originTranslate.addByPoint(spanLeft, paddingTop),
28272
+ originTranslate.addByPoint(spanLeft, 0),
28182
28273
  centerPoint,
28183
28274
  centerAngle,
28184
28275
  vertexAngle,
@@ -28191,7 +28282,7 @@ const _Documents = class _Documents extends DocComponent {
28191
28282
  if (!glyph.content || glyph.content.length === 0)
28192
28283
  continue;
28193
28284
  const { width: spanWidth, left: spanLeft, xOffset } = glyph, { x: translateX, y: translateY } = this._drawLiquid, originTranslate = Vector2.create(translateX, translateY), centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2), spanStartPoint = calculateRectRotate(
28194
- originTranslate.addByPoint(spanLeft + xOffset, paddingTop),
28285
+ originTranslate.addByPoint(spanLeft + xOffset, 0),
28195
28286
  centerPoint,
28196
28287
  centerAngle,
28197
28288
  vertexAngle,
@@ -28199,7 +28290,7 @@ const _Documents = class _Documents extends DocComponent {
28199
28290
  ), spanPointWithFont = calculateRectRotate(
28200
28291
  originTranslate.addByPoint(
28201
28292
  spanLeft + maxLineAscSin + xOffset,
28202
- maxLineAscCos + paddingTop
28293
+ maxLineAscCos
28203
28294
  ),
28204
28295
  centerPoint,
28205
28296
  centerAngle,
@@ -28265,7 +28356,7 @@ const _Documents = class _Documents extends DocComponent {
28265
28356
  this._drawLiquid.translateSave(), this._drawLiquid.translateColumn(column);
28266
28357
  const linesCount = lines.length, alignOffset = alignOffsetNoAngle;
28267
28358
  for (let i = 0; i < linesCount; i++) {
28268
- const line2 = lines[i], { divides, asc = 0, type, lineHeight = 0, paddingTop } = line2, maxLineAsc = asc, maxLineAscSin = maxLineAsc * Math.sin(centerAngle), maxLineAscCos = maxLineAsc * Math.cos(centerAngle);
28359
+ const line2 = lines[i], { divides, asc = 0, type, lineHeight = 0 } = line2, maxLineAsc = asc, maxLineAscSin = maxLineAsc * Math.sin(centerAngle), maxLineAscCos = maxLineAsc * Math.cos(centerAngle);
28269
28360
  if (type === LineType.BLOCK)
28270
28361
  for (const extension of extensions)
28271
28362
  extension.type === DOCS_EXTENSION_TYPE.LINE && (extension.extensionOffset = {
@@ -28273,7 +28364,7 @@ const _Documents = class _Documents extends DocComponent {
28273
28364
  renderConfig
28274
28365
  }, extension.draw(ctx, parentScale, line2));
28275
28366
  else {
28276
- this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0);
28367
+ this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0, !0);
28277
28368
  const { y } = this._drawLiquid;
28278
28369
  if (isHeader) {
28279
28370
  if (y - originY + alignOffset.y > (parentPage.pageHeight - 100) / 2) {
@@ -28293,7 +28384,7 @@ const _Documents = class _Documents extends DocComponent {
28293
28384
  continue;
28294
28385
  const { width: spanWidth, left: spanLeft } = glyph, { x: translateX, y: translateY } = this._drawLiquid, originTranslate = Vector2.create(translateX, translateY), centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2), extensionOffset = {
28295
28386
  spanStartPoint: calculateRectRotate(
28296
- originTranslate.addByPoint(spanLeft, paddingTop),
28387
+ originTranslate.addByPoint(spanLeft, 0),
28297
28388
  centerPoint,
28298
28389
  centerAngle,
28299
28390
  vertexAngle,
@@ -28306,7 +28397,7 @@ const _Documents = class _Documents extends DocComponent {
28306
28397
  if (!glyph.content || glyph.content.length === 0)
28307
28398
  continue;
28308
28399
  const { width: spanWidth, left: spanLeft, xOffset } = glyph, { x: translateX, y: translateY } = this._drawLiquid, originTranslate = Vector2.create(translateX, translateY), centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2), spanStartPoint = calculateRectRotate(
28309
- originTranslate.addByPoint(spanLeft + xOffset, paddingTop),
28400
+ originTranslate.addByPoint(spanLeft + xOffset, 0),
28310
28401
  centerPoint,
28311
28402
  centerAngle,
28312
28403
  vertexAngle,
@@ -28314,7 +28405,7 @@ const _Documents = class _Documents extends DocComponent {
28314
28405
  ), spanPointWithFont = calculateRectRotate(
28315
28406
  originTranslate.addByPoint(
28316
28407
  spanLeft + maxLineAscSin + xOffset,
28317
- maxLineAscCos + paddingTop
28408
+ maxLineAscCos
28318
28409
  ),
28319
28410
  centerPoint,
28320
28411
  centerAngle,
@@ -28407,8 +28498,6 @@ const OBJECT_KEY = "__SHEET_EXTENSION_FONT_DOCUMENT_INSTANCE__", _Spreadsheet =
28407
28498
  }
28408
28499
  /**
28409
28500
  * draw by viewport
28410
- * cacheBound ---> viewBound
28411
- * diffCacheBounds ---> diffRange
28412
28501
  * @param ctx
28413
28502
  * @param viewportInfo
28414
28503
  */
@@ -29080,9 +29169,17 @@ function getOverflowAncestors(node, list, traverseIframes) {
29080
29169
  var _node$ownerDocument2;
29081
29170
  list === void 0 && (list = []), traverseIframes === void 0 && (traverseIframes = !0);
29082
29171
  const scrollableAncestor = getNearestOverflowAncestor(node), isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body), win = getWindow(scrollableAncestor);
29083
- return isBody ? list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []) : list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
29172
+ if (isBody) {
29173
+ const frameElement = getFrameElement(win);
29174
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
29175
+ }
29176
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
29084
29177
  }
29085
29178
  __name(getOverflowAncestors, "getOverflowAncestors");
29179
+ function getFrameElement(win) {
29180
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
29181
+ }
29182
+ __name(getFrameElement, "getFrameElement");
29086
29183
  function observeClientRect(containerElement) {
29087
29184
  return new Observable((observer) => {
29088
29185
  const disposable = autoClientRect(containerElement, () => observer.next());
@@ -31320,8 +31417,10 @@ const _Scene = class _Scene extends ThinScene {
31320
31417
  scaleX !== void 0 && (this.scaleX = scaleX), scaleY !== void 0 && (this.scaleY = scaleY);
31321
31418
  }
31322
31419
  /**
31323
- * scale to value, absolute
31324
- * setTransform ---> viewport._updateScrollBarPosByViewportScroll ---> scrollTo
31420
+ * Set scale, and then emit event to update Viewport scroll state.
31421
+ * @param scaleX
31422
+ * @param scaleY
31423
+ * @returns Scene
31325
31424
  */
31326
31425
  scale(scaleX, scaleY) {
31327
31426
  const preScaleX = this.scaleX;
@@ -31353,9 +31452,7 @@ const _Scene = class _Scene extends ThinScene {
31353
31452
  }), this;
31354
31453
  }
31355
31454
  /**
31356
- * This sequence will initiate a series of updates:
31357
- * scene._setTransForm --> viewport@resetCanvasSizeAndUpdateScrollBar ---> scrollTo ---> limitedScroll ---> onScrollBeforeObserver ---> setScrollInfo
31358
- * scrollInfo needs accurate scene width & height, limitedScroll depends on scene & engine's width & height
31455
+ * Reset canvas size and update scroll
31359
31456
  * @param state
31360
31457
  */
31361
31458
  transformByState(state) {
@@ -31406,6 +31503,12 @@ const _Scene = class _Scene extends ThinScene {
31406
31503
  var _a11;
31407
31504
  return (_a11 = this.getLayer(zIndex)) == null || _a11.addObjects(objects), this._addObject$.next(this), this;
31408
31505
  }
31506
+ /**
31507
+ * Add object to Layer (Layer is specified by zIndex).
31508
+ * @param o
31509
+ * @param zIndex layer index
31510
+ * @returns scene
31511
+ */
31409
31512
  addObject(o, zIndex = 1) {
31410
31513
  var _a11;
31411
31514
  return (_a11 = this.getLayer(zIndex)) == null || _a11.addObject(o), this._addObject$.next(this), this;
@@ -31833,11 +31936,15 @@ let RenderUnit = (_a7 = class extends Disposable {
31833
31936
  this._injector.dispose(), super.dispose();
31834
31937
  }
31835
31938
  /**
31836
- * Get render controller hold by this render unit.
31939
+ * Get a dependency from the RenderUnit's injector.
31837
31940
  */
31838
31941
  with(dependency) {
31839
31942
  return this._injector.get(dependency);
31840
31943
  }
31944
+ /**
31945
+ * Add render dependencies to the RenderUnit's injector. Note that the dependencies would be initialized immediately
31946
+ * after being added.
31947
+ */
31841
31948
  addRenderDependencies(dependencies) {
31842
31949
  this._initDependencies(dependencies);
31843
31950
  }
@@ -31846,9 +31953,13 @@ let RenderUnit = (_a7 = class extends Disposable {
31846
31953
  dependencies.forEach((dep) => {
31847
31954
  const [identifier, implOrNull] = Array.isArray(dep) ? dep : [dep, null];
31848
31955
  if (!implOrNull)
31849
- j.add([identifier, { useFactory: /* @__PURE__ */ __name(() => j.createInstance(identifier, this._renderContext), "useFactory") }]);
31956
+ j.add([identifier, {
31957
+ useFactory: /* @__PURE__ */ __name(() => j.createInstance(identifier, this._renderContext), "useFactory")
31958
+ }]);
31850
31959
  else if (isClassDependencyItem(implOrNull))
31851
- j.add([identifier, { useFactory: /* @__PURE__ */ __name(() => j.createInstance(implOrNull.useClass, this._renderContext), "useFactory") }]);
31960
+ j.add([identifier, {
31961
+ useFactory: /* @__PURE__ */ __name(() => j.createInstance(implOrNull.useClass, this._renderContext), "useFactory")
31962
+ }]);
31852
31963
  else
31853
31964
  throw new Error("[RenderUnit]: render dependency could only be an class!");
31854
31965
  }), dependencies.forEach((dep) => {
@@ -32320,10 +32431,6 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32320
32431
  disable() {
32321
32432
  this._active = !1;
32322
32433
  }
32323
- /**
32324
- * invoked when canvas element size change
32325
- * engineResizeObserver --> engine.resizeBySize --> scene._setTransForm
32326
- */
32327
32434
  resetCanvasSizeAndUpdateScroll() {
32328
32435
  this._resizeCacheCanvas(), this._updateScrollByViewportScrollValue();
32329
32436
  }
@@ -32359,33 +32466,18 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32359
32466
  });
32360
32467
  }
32361
32468
  /**
32362
- * There are serval cases to call this method.
32363
- * the most common case is scrolling. Other situations include:
32364
- * 1. changing the frozen row & col settings
32365
- * 2. changing curr skeleton
32366
- * 3. changing selection which cross viewport
32367
- * 4. changing the viewport size (also include change window size)
32368
- * 5. changing the scroll bar position
32369
- *
32370
- * when scrolling by trackpad:
32371
- * scene.input-manager@_onMouseWheel --> scene@triggerMouseWheel --> sheet-render.controller@scene.onMouseWheel$.add -->
32372
- * set-scroll.command.ts --> scroll.operation.ts -->
32373
- * scrollManagerService.setScrollInfoAndEmitEvent
32374
- *
32375
- * when change skelenton:
32376
- * _currentSkeletonBefore$ ---> scroll.render-controller@_updateSceneSize --> setSearchParam --> scene@_setTransForm ---> viewport.resetCanvasSizeAndUpdateScrollBar ---> scrollToXX
32377
- * --> onScrollAfterObserver.notifyObservers --> scroll.render-controller@onScrollAfterObserver ---> setScrollInfoToCurrSheetWithoutNotify ---> sms._setScrollInfo
32378
- *
32379
- * _currentSkeleton$ ---> selection.render-controller ---> formula@_autoScroll ---> viewport.resize ---> get scrollXY by viewportScrollXY ---> scrollTo
32380
- * _currentSkeleton$ ---> selection.render-controller ---> setCurrentSelection ---> formula@_autoScroll ---> scrollTo
32381
- * _currentSkeleton$ ---> freeze.render-controller@_refreshFreeze --> viewport.resize ---> scrollTo ---> _scroll
32382
- *
32383
- * Debug
32384
- * window.scene.getViewports()[0].scrollTo({x: 14.2, y: 1.8}, true)
32385
- *
32386
- * @param pos
32387
- *
32469
+ * ScrollBar scroll to certain position.
32470
+ * @param pos position of scrollBar
32388
32471
  */
32472
+ // There are serval cases to call this method.
32473
+ // the most common case is scrolling. Other situations include:
32474
+ // 1. changing the frozen row & col settings
32475
+ // 2. changing curr skeleton
32476
+ // 3. changing selection which cross viewport
32477
+ // 4. changing the viewport size (also include change window size)
32478
+ // 5. changing the scroll bar position
32479
+ // Debug
32480
+ // window.scene.getViewports()[0].scrollTo({x: 14.2, y: 1.8}, true)
32389
32481
  scrollToBarPos(pos) {
32390
32482
  return this._scrollToBarPosCore(pos);
32391
32483
  }
@@ -32416,6 +32508,12 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32416
32508
  isTrigger
32417
32509
  });
32418
32510
  }
32511
+ /**
32512
+ * Viewport scroll to certain position.
32513
+ * @param pos
32514
+ * @param isTrigger
32515
+ * @returns IViewportScrollPosition
32516
+ */
32419
32517
  scrollToViewportPos(pos, isTrigger = !0) {
32420
32518
  if (!this._scrollBar || this.isActive === !1)
32421
32519
  return;
@@ -32477,8 +32575,11 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32477
32575
  getScrollBar() {
32478
32576
  return this._scrollBar;
32479
32577
  }
32480
- // scrollTo ---> _scroll ---> onScrollAfter$.next ---> scroll.render-controller@updateScroll
32481
- // scrollTo ---> _scroll ---> onScrollAfter$.next ---> freeze.render-controller@updateScroll
32578
+ /**
32579
+ * Just record state of scroll. This method won't scroll viewport and scrollbar.
32580
+ * @param current
32581
+ * @returns Viewport
32582
+ */
32482
32583
  updateScrollVal(current) {
32483
32584
  this._preScrollX = this.scrollX, this._preScrollY = this.scrollY;
32484
32585
  const { scrollX, scrollY, viewportScrollX, viewportScrollY } = current;
@@ -32492,8 +32593,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32492
32593
  return !(this.isActive === !1 || this.width == null || this.height == null || this.width <= 1 || this.height <= 1);
32493
32594
  }
32494
32595
  /**
32495
- * call stack: engine.renderLoop ---> scene.render ---> layer.render ---> viewport.render
32496
- * that means each layer call all viewports to render
32596
+ * Render function in each render loop.
32497
32597
  * @param parentCtx parentCtx is cacheCtx from layer when layer._allowCache is true
32498
32598
  * @param objects
32499
32599
  * @param isMaxLayer
@@ -32740,7 +32840,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32740
32840
  (_a11 = this._cacheCanvas) == null || _a11.setSize(canvasW, canvasH), this.cacheBound = this._viewBound, this.preCacheBound = null, this.markForceDirty(!0);
32741
32841
  }
32742
32842
  /**
32743
- * This method will be invoked when viewport is resizing and removing rol & col
32843
+ * Update scroll when viewport is resizing and removing rol & col
32744
32844
  */
32745
32845
  _updateScrollByViewportScrollValue() {
32746
32846
  if (!this.width || this.width < 0 || !this.height || this.height < 0) return;
@@ -33781,7 +33881,7 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
33781
33881
  this._removeAllRanges();
33782
33882
  return;
33783
33883
  }
33784
- (startNode == null ? void 0 : startNode.node.streamType) === DataStreamTreeTokenType.PARAGRAPH && (position.isBack = !0), this._updateTextRangeAnchorPosition(position), this._activeSelectionRefresh(), this._textSelectionInner$.next({
33884
+ (startNode == null ? void 0 : startNode.node.streamType) === DataStreamTreeTokenType.PARAGRAPH && (position.isBack = !0), this._createTextRangeByAnchorPosition(position), this._textSelectionInner$.next({
33785
33885
  textRanges: this._getAllTextRanges(),
33786
33886
  rectRanges: this._getAllRectRanges(),
33787
33887
  segmentId: this._currentSegmentId,
@@ -34075,11 +34175,12 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
34075
34175
  _addRectRanges(rectRanges) {
34076
34176
  rectRanges.length !== 0 && (this._deactivateAllRectRanges(), rectRanges[rectRanges.length - 1].activate(), this._rectRangeList.push(...rectRanges));
34077
34177
  }
34078
- _updateTextRangeAnchorPosition(position) {
34178
+ _createTextRangeByAnchorPosition(position) {
34079
34179
  if (!this._scene)
34080
34180
  return;
34081
- let lastRange = this._rangeList.pop();
34082
- lastRange || (lastRange = new TextRange(this._scene, this._document, this._docSkeleton, position, void 0, this._selectionStyle, this._currentSegmentId)), this._removeAllTextRanges(), lastRange.activate(), lastRange.anchorNodePosition = position, lastRange.focusNodePosition = null, this._rangeList = [lastRange];
34181
+ this._removeAllRanges();
34182
+ const lastRange = new TextRange(this._scene, this._document, this._docSkeleton, position, void 0, this._selectionStyle, this._currentSegmentId);
34183
+ this._addTextRange(lastRange);
34083
34184
  }
34084
34185
  _updateActiveRangePosition(position) {
34085
34186
  if (!this._scene) {