@univerjs/engine-render 0.2.8 → 0.2.10

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() {
@@ -4319,13 +4319,11 @@ const _SpreadsheetColumnHeader = class _SpreadsheetColumnHeader extends Spreadsh
4319
4319
  }
4320
4320
  draw(ctx, bounds) {
4321
4321
  const spreadsheetSkeleton = this.getSkeleton();
4322
- if (!spreadsheetSkeleton)
4323
- return;
4322
+ if (!spreadsheetSkeleton) return;
4324
4323
  const parentScale = this.getParentScale();
4325
4324
  spreadsheetSkeleton.calculateSegment(bounds);
4326
4325
  const segment = spreadsheetSkeleton.rowColumnSegment;
4327
- if (!segment || segment.startColumn === -1 && segment.endColumn === -1)
4328
- return;
4326
+ if (!segment || segment.startColumn === -1 && segment.endColumn === -1) return;
4329
4327
  const { rowHeaderWidth } = spreadsheetSkeleton;
4330
4328
  ctx.translateWithPrecision(rowHeaderWidth, 0);
4331
4329
  const extensions = this.getExtensionsByOrder();
@@ -4346,6 +4344,10 @@ const _SpreadsheetColumnHeader = class _SpreadsheetColumnHeader extends Spreadsh
4346
4344
  "DefaultColumnHeaderLayoutExtension"
4347
4345
  );
4348
4346
  }
4347
+ /**
4348
+ * Custimize column header, such as custom header text and background.
4349
+ * @param cfg
4350
+ */
4349
4351
  setCustomHeader(cfg) {
4350
4352
  this.makeDirty(!0), this._columnHeaderLayoutExtension.configHeaderColumn(cfg);
4351
4353
  }
@@ -4358,6 +4360,16 @@ const _SheetExtension = class _SheetExtension extends ComponentExtension {
4358
4360
  super(...arguments);
4359
4361
  __publicField(this, "type", 0);
4360
4362
  }
4363
+ /**
4364
+ * Get ISelectionCellWithMergeInfo by cell rowIndex and cell columnIndex.
4365
+ * The startXY in return value does not include rowHeader and columnHeader.
4366
+ * @param rowIndex
4367
+ * @param columnIndex
4368
+ * @param rowHeightAccumulation
4369
+ * @param columnWidthAccumulation
4370
+ * @param dataMergeCache
4371
+ * @returns ISelectionCellWithMergeInfo
4372
+ */
4361
4373
  getCellIndex(rowIndex, columnIndex, rowHeightAccumulation, columnWidthAccumulation, dataMergeCache) {
4362
4374
  return getCellByIndex(rowIndex, columnIndex, rowHeightAccumulation, columnWidthAccumulation, dataMergeCache);
4363
4375
  }
@@ -20137,14 +20149,14 @@ function customBlockLineBreakExtension(breaker) {
20137
20149
  breaker.addRule("break_before_and_after_slash_b", (codePoint, lastCodePoint) => codePoint === SLASH_B_CODE_POINT || lastCodePoint === SLASH_B_CODE_POINT);
20138
20150
  }
20139
20151
  __name(customBlockLineBreakExtension, "customBlockLineBreakExtension");
20140
- function otherHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20152
+ function otherHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20141
20153
  const glyphGroup = [];
20142
20154
  let step = 0;
20143
20155
  for (let i = 0; i < charArray.length; i++) {
20144
20156
  const newChar = charArray[i];
20145
20157
  if (hasSpace(newChar) || startWithEmoji(charArray.substring(i)))
20146
20158
  break;
20147
- const config = getFontCreateConfig(index2 + i, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), glyph = createSkeletonLetterGlyph(newChar, config);
20159
+ const config = getFontCreateConfig(index2 + i, viewModel, paragraphNode, sectionBreakConfig, paragraph), glyph = createSkeletonLetterGlyph(newChar, config);
20148
20160
  glyphGroup.push(glyph), step++;
20149
20161
  }
20150
20162
  return {
@@ -20153,8 +20165,8 @@ function otherHandler(index2, charArray, viewModel, paragraphNode, sectionBreakC
20153
20165
  };
20154
20166
  }
20155
20167
  __name(otherHandler, "otherHandler");
20156
- function ArabicHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20157
- const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), glyph = [];
20168
+ function ArabicHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20169
+ const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph), glyph = [];
20158
20170
  let step = 0;
20159
20171
  for (let i = 0; i < charArray.length; i++) {
20160
20172
  const newChar = charArray[i];
@@ -20169,16 +20181,16 @@ function ArabicHandler(index2, charArray, viewModel, paragraphNode, sectionBreak
20169
20181
  };
20170
20182
  }
20171
20183
  __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);
20184
+ function emojiHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20185
+ const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph), match = charArray.match(EMOJI_REG);
20174
20186
  return {
20175
20187
  step: match[0].length,
20176
20188
  glyphGroup: [createSkeletonLetterGlyph(match[0], config)]
20177
20189
  };
20178
20190
  }
20179
20191
  __name(emojiHandler, "emojiHandler");
20180
- function TibetanHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20181
- const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), glyph = [];
20192
+ function TibetanHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20193
+ const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph), glyph = [];
20182
20194
  let step = 0;
20183
20195
  for (let i = 0; i < charArray.length; i++) {
20184
20196
  const newChar = charArray[i];
@@ -20228,7 +20240,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20228
20240
  drawings = {}
20229
20241
  } = sectionBreakConfig, shapedTextList = [];
20230
20242
  let breaker = new LineBreaker(content);
20231
- const { endIndex } = paragraphNode, { paragraphStyle = {} } = viewModel.getParagraph(endIndex) || { startIndex: 0 }, { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
20243
+ const { endIndex } = paragraphNode, paragraph = viewModel.getParagraph(endIndex) || { startIndex: 0 }, { paragraphStyle = {} } = paragraph, { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
20232
20244
  let last = 0, bk, lastGlyphIndex = 0;
20233
20245
  const { hyphen, languageDetector } = ctx, paragraphBody = prepareParagraphBody(viewModel.getBody(), endIndex);
20234
20246
  let glyphInfos = [];
@@ -20247,7 +20259,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20247
20259
  }
20248
20260
  lastGlyphIndex = i;
20249
20261
  for (const glyphInfo of glyphInfosInWord) {
20250
- const { start, char } = glyphInfo, config = getFontCreateConfig(start, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
20262
+ const { start, char } = glyphInfo, config = getFontCreateConfig(start, viewModel, paragraphNode, sectionBreakConfig, paragraph);
20251
20263
  if (char === DataStreamTreeTokenType.TAB) {
20252
20264
  const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid), newSpan = createSkeletonTabGlyph(config, charSpaceApply);
20253
20265
  shapedGlyphs.push(newSpan);
@@ -20266,7 +20278,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20266
20278
  if (char == null)
20267
20279
  break;
20268
20280
  if (char === DataStreamTreeTokenType.CUSTOM_BLOCK) {
20269
- const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
20281
+ const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
20270
20282
  let newGlyph = null;
20271
20283
  const customBlock = viewModel.getCustomBlockWithoutSetCurrentIndex(paragraphNode.startIndex + i);
20272
20284
  if (customBlock != null) {
@@ -20279,7 +20291,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20279
20291
  }
20280
20292
  newGlyph == null && (newGlyph = createSkeletonLetterGlyph(char, config)), shapedGlyphs.push(newGlyph), i += char.length, src = src.substring(char.length);
20281
20293
  } else if (/\s/.test(char) || hasCJK(char)) {
20282
- const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
20294
+ const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
20283
20295
  let newGlyph = null;
20284
20296
  if (char === DataStreamTreeTokenType.TAB) {
20285
20297
  const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
@@ -20294,7 +20306,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20294
20306
  viewModel,
20295
20307
  paragraphNode,
20296
20308
  sectionBreakConfig,
20297
- paragraphStyle
20309
+ paragraph
20298
20310
  );
20299
20311
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20300
20312
  } else if (hasArabic(char)) {
@@ -20304,7 +20316,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20304
20316
  viewModel,
20305
20317
  paragraphNode,
20306
20318
  sectionBreakConfig,
20307
- paragraphStyle
20319
+ paragraph
20308
20320
  );
20309
20321
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20310
20322
  } else if (hasTibetan(char)) {
@@ -20314,7 +20326,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20314
20326
  viewModel,
20315
20327
  paragraphNode,
20316
20328
  sectionBreakConfig,
20317
- paragraphStyle
20329
+ paragraph
20318
20330
  );
20319
20331
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20320
20332
  } else {
@@ -20324,7 +20336,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20324
20336
  viewModel,
20325
20337
  paragraphNode,
20326
20338
  sectionBreakConfig,
20327
- paragraphStyle
20339
+ paragraph
20328
20340
  );
20329
20341
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20330
20342
  }
@@ -20651,8 +20663,8 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
20651
20663
  const { blockId } = customBlock, drawingOrigin = drawings[blockId];
20652
20664
  drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE ? paragraphInlineSkeDrawings.set(blockId, _getDrawingSkeletonFormat(drawingOrigin)) : paragraphAffectSkeDrawings.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
20653
20665
  }
20654
- let allPages = [curPage], paragraphStart = !0;
20655
- for (const { text, glyphs, breakPointType } of shapedTextList) {
20666
+ let allPages = [curPage], isParagraphFirstShapedText = !0;
20667
+ for (const [_index, { text, glyphs, breakPointType }] of shapedTextList.entries()) {
20656
20668
  const pushPending = /* @__PURE__ */ __name(() => {
20657
20669
  glyphs.length !== 0 && (allPages = layoutParagraph(
20658
20670
  ctx,
@@ -20660,9 +20672,9 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
20660
20672
  allPages,
20661
20673
  sectionBreakConfig,
20662
20674
  paragraphConfig,
20663
- paragraphStart,
20675
+ isParagraphFirstShapedText,
20664
20676
  breakPointType
20665
- ), paragraphStart = !1);
20677
+ ), isParagraphFirstShapedText = !1);
20666
20678
  }, "pushPending");
20667
20679
  if (text.endsWith(DataStreamTreeTokenType.PAGE_BREAK)) {
20668
20680
  pushPending(), allPages.push(
@@ -21121,17 +21133,17 @@ function _getVerticalMargin(marginTB, headerOrFooter, pageHeight) {
21121
21133
  return Math.min(maxMargin, Math.max(marginTB, HeaderFooterPageHeight));
21122
21134
  }
21123
21135
  __name(_getVerticalMargin, "_getVerticalMargin");
21124
- function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal) {
21125
- if (paragraphStart)
21136
+ function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal) {
21137
+ if (isParagraphFirstShapedText)
21126
21138
  if (paragraphConfig.bulletSkeleton) {
21127
21139
  const { bulletSkeleton, paragraphStyle = {} } = paragraphConfig, { gridType = GridType.LINES, charSpace = 0, defaultTabStop = 10.5 } = sectionBreakConfig, paragraphProperties = bulletSkeleton.paragraphProperties || {};
21128
21140
  paragraphConfig.paragraphStyle = mergeByV(paragraphConfig.paragraphStyle, paragraphProperties);
21129
21141
  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);
21142
+ _lineOperator(ctx, [bulletGlyph, ...glyphGroup], pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
21131
21143
  } else
21132
- _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21144
+ _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
21133
21145
  else
21134
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21146
+ _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
21135
21147
  return [...pages];
21136
21148
  }
21137
21149
  __name(layoutParagraph, "layoutParagraph");
@@ -21184,7 +21196,7 @@ function _popHyphenSlice(divide) {
21184
21196
  return divide.glyphGroup.length === 0 && (divide.glyphGroup.push(...glyphGroup), glyphGroup.length = 0), glyphGroup;
21185
21197
  }
21186
21198
  __name(_popHyphenSlice, "_popHyphenSlice");
21187
- function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21199
+ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21188
21200
  var _a11;
21189
21201
  const lastPage = getLastPage(pages), divideInfo = getLastNotFullDivideInfo(lastPage);
21190
21202
  if (divideInfo) {
@@ -21222,13 +21234,13 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21222
21234
  const hyphenSliceGlyphGroup = _popHyphenSlice(divide);
21223
21235
  hyphenSliceGlyphGroup.length > 0 && (updateDivideInfo(divide, {
21224
21236
  breakType: BreakPointType.Normal
21225
- }), _divideOperator(ctx, hyphenSliceGlyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, BreakPointType.Hyphen)), _divideOperator(
21237
+ }), _divideOperator(ctx, hyphenSliceGlyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, BreakPointType.Hyphen)), _divideOperator(
21226
21238
  ctx,
21227
21239
  glyphGroup,
21228
21240
  pages,
21229
21241
  sectionBreakConfig,
21230
21242
  paragraphConfig,
21231
- paragraphStart,
21243
+ isParagraphFirstShapedText,
21232
21244
  breakPointType,
21233
21245
  defaultSpanLineHeight
21234
21246
  );
@@ -21239,7 +21251,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21239
21251
  pages,
21240
21252
  sectionBreakConfig,
21241
21253
  paragraphConfig,
21242
- paragraphStart,
21254
+ isParagraphFirstShapedText,
21243
21255
  breakPointType,
21244
21256
  defaultSpanLineHeight
21245
21257
  );
@@ -21255,7 +21267,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21255
21267
  pages,
21256
21268
  sectionBreakConfig,
21257
21269
  paragraphConfig,
21258
- paragraphStart,
21270
+ isParagraphFirstShapedText,
21259
21271
  breakPointType,
21260
21272
  defaultSpanLineHeight
21261
21273
  );
@@ -21272,13 +21284,13 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21272
21284
  snapToGrid
21273
21285
  );
21274
21286
  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]];
21287
+ const spanGroupCached = __getGlyphGroupByLine(currentLine), spanGroupCachedLen = spanGroupCached.length;
21288
+ let newGlyphGroup = [], startIndex = 1;
21289
+ spanGroupCachedLen > 2 && spanGroupCached[0].glyphType === GlyphType.LIST ? (newGlyphGroup = [spanGroupCached[0], spanGroupCached[1]], startIndex = 2) : newGlyphGroup = [spanGroupCached[0]];
21278
21290
  const column = currentLine.parent, { paragraphStart: lineIsStart } = column == null ? void 0 : column.lines.pop();
21279
21291
  _lineOperator(
21280
21292
  ctx,
21281
- newSpanGroup,
21293
+ newGlyphGroup,
21282
21294
  pages,
21283
21295
  sectionBreakConfig,
21284
21296
  paragraphConfig,
@@ -21293,28 +21305,45 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21293
21305
  pages,
21294
21306
  sectionBreakConfig,
21295
21307
  paragraphConfig,
21296
- paragraphStart
21308
+ isParagraphFirstShapedText
21297
21309
  );
21298
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21310
+ _divideOperator(
21311
+ ctx,
21312
+ glyphGroup,
21313
+ pages,
21314
+ sectionBreakConfig,
21315
+ paragraphConfig,
21316
+ isParagraphFirstShapedText,
21317
+ breakPointType
21318
+ );
21299
21319
  return;
21300
21320
  }
21301
21321
  }
21302
21322
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft), updateDivideInfo(divide, { breakType: breakPointType });
21303
21323
  }
21304
21324
  } else
21305
- _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight);
21325
+ _lineOperator(
21326
+ ctx,
21327
+ glyphGroup,
21328
+ pages,
21329
+ sectionBreakConfig,
21330
+ paragraphConfig,
21331
+ isParagraphFirstShapedText,
21332
+ breakPointType,
21333
+ defaultSpanLineHeight
21334
+ );
21306
21335
  }
21307
21336
  __name(_divideOperator, "_divideOperator");
21308
- function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21337
+ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultGlyphLineHeight) {
21309
21338
  var _a11, _b, _c, _d, _e, _f;
21310
21339
  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;
21340
+ if ((!columnInfo || !columnInfo.column) && (_pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, !0, breakPointType), lastPage = getLastPage(pages), columnInfo = getLastNotFullColumnInfo(lastPage)), !columnInfo) return;
21312
21341
  const column = columnInfo.column;
21313
21342
  if (column.width <= 0) {
21314
21343
  console.error("The column width is less than 0, need to adjust page width to make it great than 0");
21315
21344
  return;
21316
21345
  }
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, {
21346
+ 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
21347
  paragraphStyle = {},
21319
21348
  paragraphAffectSkeDrawings,
21320
21349
  skeTablesInParagraph,
@@ -21330,11 +21359,18 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21330
21359
  hanging,
21331
21360
  indentStart,
21332
21361
  indentEnd
21333
- } = paragraphStyle, { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(
21362
+ } = paragraphStyle, {
21363
+ paragraphLineGapDefault,
21364
+ linePitch,
21365
+ lineSpacing,
21366
+ spacingRule,
21367
+ snapToGrid,
21368
+ gridType
21369
+ } = getLineHeightConfig(
21334
21370
  sectionBreakConfig,
21335
21371
  paragraphConfig
21336
21372
  ), { paddingTop, paddingBottom, contentHeight, lineSpacingApply } = __getLineHeight(
21337
- spanLineHeight,
21373
+ glyphLineHeight,
21338
21374
  paragraphLineGapDefault,
21339
21375
  linePitch,
21340
21376
  gridType,
@@ -21342,10 +21378,11 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21342
21378
  spacingRule,
21343
21379
  snapToGrid
21344
21380
  ), { marginTop, spaceBelowApply } = __getParagraphSpace(
21381
+ ctx,
21345
21382
  lineSpacingApply,
21346
21383
  spaceAbove,
21347
21384
  spaceBelow,
21348
- paragraphStart,
21385
+ isParagraphFirstShapedText,
21349
21386
  preLine
21350
21387
  ), lineHeight = marginTop + paddingTop + contentHeight + paddingBottom;
21351
21388
  let section = column.parent;
@@ -21356,12 +21393,12 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21356
21393
  const drawingsInLine = _getCustomBlockIdsInLine(preLine);
21357
21394
  if (drawingsInLine.length > 0) {
21358
21395
  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);
21396
+ relativeLineDrawings.length > 0 && __updateAndPositionDrawings(ctx, preLine.top, preLine.lineHeight, column, relativeLineDrawings, preLine.paragraphIndex, isParagraphFirstShapedText);
21360
21397
  }
21361
21398
  }
21362
21399
  if (paragraphAffectSkeDrawings != null && paragraphAffectSkeDrawings.size > 0) {
21363
21400
  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);
21401
+ __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, (_f = pDrawingAnchor == null ? void 0 : pDrawingAnchor.get(paragraphIndex)) == null ? void 0 : _f.top);
21365
21402
  }
21366
21403
  skeTablesInParagraph != null && skeTablesInParagraph.length > 0 && (needOpenNewPageByTableLayout = _updateAndPositionTable(lineTop, lastPage, section, skeTablesInParagraph));
21367
21404
  const newLineTop = calculateLineTopByDrawings(
@@ -21372,7 +21409,16 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21372
21409
  footerPage
21373
21410
  );
21374
21411
  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)
21412
+ if (setColumnFullState(column, !0), _columnOperator(
21413
+ ctx,
21414
+ glyphGroup,
21415
+ pages,
21416
+ sectionBreakConfig,
21417
+ paragraphConfig,
21418
+ isParagraphFirstShapedText,
21419
+ breakPointType,
21420
+ defaultGlyphLineHeight
21421
+ ), isParagraphFirstShapedText && paragraphAffectSkeDrawings && paragraphAffectSkeDrawings.size > 0)
21376
21422
  for (const drawing of paragraphAffectSkeDrawings.values())
21377
21423
  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
21424
  return;
@@ -21384,7 +21430,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21384
21430
  indentStart,
21385
21431
  indentEnd,
21386
21432
  charSpaceApply,
21387
- paragraphStart
21433
+ isParagraphFirstShapedText
21388
21434
  );
21389
21435
  if (paddingLeft + paddingRight >= column.width) {
21390
21436
  const leftPercent = paddingLeft / (paddingLeft + paddingRight);
@@ -21406,23 +21452,32 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21406
21452
  },
21407
21453
  column.width,
21408
21454
  lineIndex,
21409
- paragraphStart,
21455
+ isParagraphFirstShapedText,
21410
21456
  paragraphConfig,
21411
21457
  lastPage,
21412
21458
  headerPage,
21413
21459
  footerPage
21414
21460
  );
21415
- column.lines.push(newLine), newLine.parent = column, createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor), _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight);
21461
+ column.lines.push(newLine), newLine.parent = column, createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor), _divideOperator(
21462
+ ctx,
21463
+ glyphGroup,
21464
+ pages,
21465
+ sectionBreakConfig,
21466
+ paragraphConfig,
21467
+ isParagraphFirstShapedText,
21468
+ breakPointType,
21469
+ defaultGlyphLineHeight
21470
+ );
21416
21471
  }
21417
21472
  __name(_lineOperator, "_lineOperator");
21418
- function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, paragraphStart, drawingAnchorTop) {
21473
+ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop) {
21419
21474
  if (targetDrawings.length === 0)
21420
21475
  return;
21421
21476
  const drawings = __getDrawingPosition(
21422
21477
  lineTop,
21423
21478
  lineHeight,
21424
21479
  column,
21425
- paragraphStart,
21480
+ isParagraphFirstShapedText,
21426
21481
  drawingAnchorTop,
21427
21482
  targetDrawings
21428
21483
  );
@@ -21552,29 +21607,56 @@ function checkRelativeDrawingNeedRePosition(ctx, drawing) {
21552
21607
  return !1;
21553
21608
  }
21554
21609
  __name(checkRelativeDrawingNeedRePosition, "checkRelativeDrawingNeedRePosition");
21555
- function _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21610
+ function _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21556
21611
  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);
21612
+ isColumnFull(lastPage) === !0 ? _pageOperator(
21613
+ ctx,
21614
+ glyphGroup,
21615
+ pages,
21616
+ sectionBreakConfig,
21617
+ paragraphConfig,
21618
+ isParagraphFirstShapedText,
21619
+ breakPointType,
21620
+ defaultSpanLineHeight
21621
+ ) : _lineOperator(
21622
+ ctx,
21623
+ glyphGroup,
21624
+ pages,
21625
+ sectionBreakConfig,
21626
+ paragraphConfig,
21627
+ isParagraphFirstShapedText,
21628
+ breakPointType,
21629
+ defaultSpanLineHeight
21630
+ );
21558
21631
  }
21559
21632
  __name(_columnOperator, "_columnOperator");
21560
- function _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21633
+ function _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21561
21634
  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);
21635
+ pages.push(createSkeletonPage(ctx, sectionBreakConfig, { skeHeaders, skeFooters }, (curSkeletonPage == null ? void 0 : curSkeletonPage.pageNumber) + 1)), _columnOperator(
21636
+ ctx,
21637
+ glyphGroup,
21638
+ pages,
21639
+ sectionBreakConfig,
21640
+ paragraphConfig,
21641
+ isParagraphFirstShapedText,
21642
+ breakPointType,
21643
+ defaultSpanLineHeight
21644
+ );
21563
21645
  }
21564
21646
  __name(_pageOperator, "_pageOperator");
21565
- function __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, charSpaceApply, paragraphStart = !1) {
21647
+ function __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, charSpaceApply, isParagraphFirstShapedText = !1) {
21566
21648
  const indentFirstLineNumber = getNumberUnitValue(indentFirstLine, charSpaceApply), hangingNumber = getNumberUnitValue(hanging, charSpaceApply), indentStartNumber = getNumberUnitValue(indentStart, charSpaceApply), indentEndNumber = getNumberUnitValue(indentEnd, charSpaceApply);
21567
21649
  let paddingLeft = indentStartNumber;
21568
21650
  const paddingRight = indentEndNumber;
21569
- return indentFirstLineNumber > 0 && paragraphStart && (paddingLeft += indentFirstLineNumber), hangingNumber > 0 && !paragraphStart && (paddingLeft += hangingNumber), {
21651
+ return indentFirstLineNumber > 0 && isParagraphFirstShapedText && (paddingLeft += indentFirstLineNumber), hangingNumber > 0 && !isParagraphFirstShapedText && (paddingLeft += hangingNumber), {
21570
21652
  paddingLeft,
21571
21653
  paddingRight
21572
21654
  };
21573
21655
  }
21574
21656
  __name(__getIndentPadding, "__getIndentPadding");
21575
- function __getParagraphSpace(lineSpacing = 0, spaceAbove, spaceBelow, paragraphStart, preLine) {
21657
+ function __getParagraphSpace(ctx, lineSpacing = 0, spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine) {
21576
21658
  const spaceBelowApply = getNumberUnitValue(spaceBelow, lineSpacing);
21577
- if (paragraphStart) {
21659
+ if (isParagraphFirstShapedText) {
21578
21660
  let marginTop = getNumberUnitValue(spaceAbove, lineSpacing);
21579
21661
  if (preLine) {
21580
21662
  const { spaceBelowApply: preSpaceBelowApply } = preLine;
@@ -21594,25 +21676,25 @@ function __getParagraphSpace(lineSpacing = 0, spaceAbove, spaceBelow, paragraphS
21594
21676
  };
21595
21677
  }
21596
21678
  __name(__getParagraphSpace, "__getParagraphSpace");
21597
- function __getLineHeight(spanLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid) {
21679
+ function __getLineHeight(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid) {
21598
21680
  let paddingTop = paragraphLineGapDefault, paddingBottom = paragraphLineGapDefault;
21599
21681
  if (gridType === GridType.DEFAULT || snapToGrid === BooleanNumber.FALSE)
21600
21682
  return spacingRule === SpacingRule.AUTO ? {
21601
21683
  paddingTop,
21602
21684
  paddingBottom,
21603
- contentHeight: lineSpacing * spanLineHeight,
21604
- lineSpacingApply: spanLineHeight
21685
+ contentHeight: lineSpacing * glyphLineHeight,
21686
+ lineSpacingApply: glyphLineHeight
21605
21687
  } : {
21606
21688
  paddingTop,
21607
21689
  paddingBottom,
21608
- contentHeight: Math.max(lineSpacing, spanLineHeight),
21690
+ contentHeight: Math.max(lineSpacing, glyphLineHeight),
21609
21691
  lineSpacingApply: lineSpacing
21610
21692
  };
21611
21693
  let lineSpacingApply = 0;
21612
- return spacingRule === SpacingRule.AUTO ? lineSpacingApply = lineSpacing * linePitch : lineSpacingApply = lineSpacing, spanLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply && (paddingTop = paddingBottom = (lineSpacingApply - spanLineHeight) / 2), {
21694
+ return spacingRule === SpacingRule.AUTO ? lineSpacingApply = lineSpacing * linePitch : lineSpacingApply = lineSpacing, glyphLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply ? paddingTop = paddingBottom = (lineSpacingApply - glyphLineHeight) / 2 : lineSpacingApply = glyphLineHeight, {
21613
21695
  paddingTop,
21614
21696
  paddingBottom,
21615
- contentHeight: spanLineHeight,
21697
+ contentHeight: glyphLineHeight,
21616
21698
  lineSpacingApply
21617
21699
  };
21618
21700
  }
@@ -21622,7 +21704,7 @@ function updateInlineDrawingPosition(line2, paragraphInlineSkeDrawings, blockAnc
21622
21704
  const column = line2.parent, page = (_b = (_a11 = line2 == null ? void 0 : line2.parent) == null ? void 0 : _a11.parent) == null ? void 0 : _b.parent;
21623
21705
  if (page == null || column == null)
21624
21706
  return;
21625
- const isPageBreak = __checkPageBreak(column), drawings = /* @__PURE__ */ new Map(), { top, lineHeight } = line2;
21707
+ const isPageBreak = __checkPageBreak(column), drawings = /* @__PURE__ */ new Map(), { top, lineHeight, marginBottom = 0 } = line2;
21626
21708
  for (const divide of line2.divides)
21627
21709
  for (const glyph of divide.glyphGroup)
21628
21710
  if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0) {
@@ -21633,19 +21715,19 @@ function updateInlineDrawingPosition(line2, paragraphInlineSkeDrawings, blockAnc
21633
21715
  if (drawingOrigin == null || drawing == null)
21634
21716
  continue;
21635
21717
  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);
21718
+ 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
21719
  }
21638
21720
  const res = new Map([...page.skeDrawings, ...drawings]);
21639
21721
  page.skeDrawings = res;
21640
21722
  }
21641
21723
  __name(updateInlineDrawingPosition, "updateInlineDrawingPosition");
21642
- function __getDrawingPosition(lineTop, lineHeight, column, paragraphStart, blockAnchorTop, needPositionDrawings = []) {
21724
+ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = []) {
21643
21725
  var _a11, _b, _c;
21644
21726
  const page = (_a11 = column.parent) == null ? void 0 : _a11.parent;
21645
21727
  if (page == null || needPositionDrawings.length === 0)
21646
21728
  return;
21647
21729
  const drawings = /* @__PURE__ */ new Map(), isPageBreak = __checkPageBreak(column);
21648
- if (!(isPageBreak && !paragraphStart)) {
21730
+ if (!(isPageBreak && !isParagraphFirstShapedText)) {
21649
21731
  for (const drawing of needPositionDrawings) {
21650
21732
  const { drawingOrigin } = drawing;
21651
21733
  if (!drawingOrigin)
@@ -21721,10 +21803,10 @@ function __maxFontBoundingBoxByGlyphGroup(glyphGroup) {
21721
21803
  return maxBox;
21722
21804
  }
21723
21805
  __name(__maxFontBoundingBoxByGlyphGroup, "__maxFontBoundingBoxByGlyphGroup");
21724
- function __getSpanGroupByLine({ divides }) {
21806
+ function __getGlyphGroupByLine({ divides }) {
21725
21807
  return divides.flatMap((divide) => divide.glyphGroup);
21726
21808
  }
21727
- __name(__getSpanGroupByLine, "__getSpanGroupByLine");
21809
+ __name(__getGlyphGroupByLine, "__getGlyphGroupByLine");
21728
21810
  function __isNullLine(line2) {
21729
21811
  return !line2.divides[0].glyphGroup[0];
21730
21812
  }
@@ -22044,7 +22126,13 @@ function getFontConfigFromLastGlyph(glyph, sectionBreakConfig, paragraphStyle) {
22044
22126
  };
22045
22127
  }
22046
22128
  __name(getFontConfigFromLastGlyph, "getFontConfigFromLastGlyph");
22047
- function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
22129
+ function getBulletParagraphTextStyle(bullet, viewModel) {
22130
+ var _a11;
22131
+ const { listType } = bullet;
22132
+ return (_a11 = viewModel.getDataModel().getBulletPresetList()[listType].nestingLevel[0].paragraphProperties) == null ? void 0 : _a11.textStyle;
22133
+ }
22134
+ __name(getBulletParagraphTextStyle, "getBulletParagraphTextStyle");
22135
+ function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
22048
22136
  const {
22049
22137
  gridType = GridType.LINES,
22050
22138
  charSpace = 0,
@@ -22057,18 +22145,18 @@ function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfi
22057
22145
  marginLeft = 0,
22058
22146
  localeService,
22059
22147
  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;
22148
+ } = 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
22149
  let { ts: textStyle = {} } = textRun;
22062
22150
  const cache = fontCreateConfigCache.getValue(st, ed);
22063
22151
  if (cache && !hasAddonStyle)
22064
22152
  return cache;
22065
- const { snapToGrid = BooleanNumber.TRUE, textStyle: paragraphStyleTextStyle } = paragraphStyle;
22153
+ const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle, bulletTextStyle = bullet ? getBulletParagraphTextStyle(bullet, viewModel) : null;
22066
22154
  textStyle = {
22067
22155
  ...documentTextStyle,
22068
22156
  ...textStyle,
22069
22157
  ...customDecorationStyle,
22070
22158
  ...customRangeStyle,
22071
- ...paragraphStyleTextStyle
22159
+ ...bulletTextStyle
22072
22160
  };
22073
22161
  const fontStyle = getFontStyleString(textStyle), mixTextStyle = {
22074
22162
  ...documentTextStyle,
@@ -22328,14 +22416,14 @@ const _Liquid = class _Liquid {
22328
22416
  y: 0
22329
22417
  };
22330
22418
  }
22331
- translateLine(line2, isDraw = !1) {
22419
+ translateLine(line2, includeMarginTop = !1, includePaddingTop = !1) {
22332
22420
  const {
22333
22421
  top: lineTop,
22334
22422
  marginBottom: _lineMarginBottom = 0,
22335
22423
  marginTop: lineMarginTop = 0,
22336
22424
  paddingTop: linePaddingTop = 0,
22337
22425
  paddingBottom: _linePaddingBottom = 0
22338
- } = line2, lineOffset = lineTop + (isDraw === !0 ? lineMarginTop : 0) + linePaddingTop;
22426
+ } = line2, lineOffset = lineTop + (includeMarginTop ? lineMarginTop : 0) + (includePaddingTop ? linePaddingTop : 0);
22339
22427
  return this.translate(0, lineOffset), {
22340
22428
  x: 0,
22341
22429
  y: lineOffset
@@ -22544,6 +22632,8 @@ const _DocumentViewModel = class _DocumentViewModel {
22544
22632
  __publicField(this, "editAreaChange$", this._editAreaChange$.asObservable());
22545
22633
  __publicField(this, "headerTreeMap", /* @__PURE__ */ new Map());
22546
22634
  __publicField(this, "footerTreeMap", /* @__PURE__ */ new Map());
22635
+ __publicField(this, "_segmentViewModels$", new BehaviorSubject([]));
22636
+ __publicField(this, "segmentViewModels$", this._segmentViewModels$.asObservable());
22547
22637
  this._documentDataModel = _documentDataModel, _documentDataModel.getBody() != null && (this.children = parseDataStreamToTree(_documentDataModel.getBody().dataStream), this._buildHeaderFooterViewModel());
22548
22638
  }
22549
22639
  registerCustomRangeInterceptor(interceptor) {
@@ -22783,11 +22873,12 @@ const _DocumentViewModel = class _DocumentViewModel {
22783
22873
  return this._interceptor ? this._interceptor.getCustomDecoration(index2) : this.getCustomDecorationRaw(index2);
22784
22874
  }
22785
22875
  _buildHeaderFooterViewModel() {
22786
- const { headerModelMap, footerModelMap } = this._documentDataModel;
22876
+ const { headerModelMap, footerModelMap } = this._documentDataModel, viewModels = [];
22787
22877
  for (const [headerId, headerModel] of headerModelMap)
22788
- this.headerTreeMap.set(headerId, new _DocumentViewModel(headerModel));
22878
+ this.headerTreeMap.set(headerId, new _DocumentViewModel(headerModel)), viewModels.push(this.headerTreeMap.get(headerId));
22789
22879
  for (const [footerId, footerModel] of footerModelMap)
22790
- this.footerTreeMap.set(footerId, new _DocumentViewModel(footerModel));
22880
+ this.footerTreeMap.set(footerId, new _DocumentViewModel(footerModel)), viewModels.push(this.footerTreeMap.get(footerId));
22881
+ this._segmentViewModels$.next(viewModels);
22791
22882
  }
22792
22883
  _getParagraphByIndex(nodes, insertIndex) {
22793
22884
  for (const node of nodes) {
@@ -22995,7 +23086,7 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
22995
23086
  );
22996
23087
  const { start, end } = compareNodePosition(startOrigin, endOrigin);
22997
23088
  return this._selectionIterator(start, end, (start_sp, end_sp, isFirst, isLast, divide, line2) => {
22998
- const { lineHeight, marginTop, asc, paddingTop } = line2, { glyphGroup, st } = divide;
23089
+ const { lineHeight, asc, paddingTop, marginTop, marginBottom } = line2, { glyphGroup, st } = divide;
22999
23090
  if (glyphGroup.length === 0)
23000
23091
  return;
23001
23092
  const { x: startX, y: startY } = this._liquid;
@@ -23005,13 +23096,13 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
23005
23096
  borderBoxPosition = {
23006
23097
  startX: startX + firstGlyphLeft + (isCurrentList ? firstGlyphWidth : 0),
23007
23098
  startY,
23008
- endX: startX + lastGlyphLeft + lastGlyphWidth,
23009
- endY: startY + lineHeight
23099
+ endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
23100
+ endY: startY + lineHeight - marginTop - marginBottom
23010
23101
  }, contentBoxPosition = {
23011
23102
  startX: startX + firstGlyphLeft + (isCurrentList ? firstGlyphWidth : 0),
23012
- startY: startY + marginTop + paddingTop + asc - anchorGlyph.bBox.ba,
23013
- endX: startX + lastGlyphLeft + lastGlyphWidth,
23014
- endY: startY + marginTop + paddingTop + asc + anchorGlyph.bBox.bd
23103
+ startY: startY + paddingTop + asc - anchorGlyph.bBox.ba,
23104
+ endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
23105
+ endY: startY + paddingTop + asc + anchorGlyph.bBox.bd
23015
23106
  };
23016
23107
  else {
23017
23108
  const isStartBackFin = isStartBack && !isCurrentList;
@@ -23019,12 +23110,12 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
23019
23110
  startX: startX + firstGlyphLeft + (isStartBackFin ? 0 : firstGlyphWidth),
23020
23111
  startY,
23021
23112
  endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
23022
- endY: startY + lineHeight
23113
+ endY: startY + lineHeight - marginTop - marginBottom
23023
23114
  }, contentBoxPosition = {
23024
23115
  startX: startX + firstGlyphLeft + (isStartBackFin ? 0 : firstGlyphWidth),
23025
- startY: startY + marginTop + paddingTop + asc - anchorGlyph.bBox.ba,
23116
+ startY: startY + paddingTop + asc - anchorGlyph.bBox.ba,
23026
23117
  endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
23027
- endY: startY + marginTop + paddingTop + asc + anchorGlyph.bBox.bd
23118
+ endY: startY + paddingTop + asc + anchorGlyph.bBox.bd
23028
23119
  };
23029
23120
  }
23030
23121
  borderBoxPointGroup.push(pushToPoints(borderBoxPosition)), contentBoxPointGroup.push(pushToPoints(contentBoxPosition)), cursorList.push({
@@ -23175,7 +23266,7 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
23175
23266
  divides.length - 1,
23176
23267
  l
23177
23268
  );
23178
- this._liquid.translateSave(), this._liquid.translateLine(line2);
23269
+ this._liquid.translateSave(), this._liquid.translateLine(line2, !0, !1);
23179
23270
  for (let d = start_d; d <= end_d; d++) {
23180
23271
  const divide = divides[d];
23181
23272
  this._liquid.translateSave(), this._liquid.translateDivide(divide);
@@ -23778,6 +23869,8 @@ __name(getPagePath, "getPagePath");
23778
23869
  const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
23779
23870
  constructor(_docViewModel, localeService) {
23780
23871
  super(localeService);
23872
+ __publicField(this, "_dirty$", new Subject());
23873
+ __publicField(this, "dirty$", this._dirty$.asObservable());
23781
23874
  __publicField(this, "_skeletonData");
23782
23875
  __publicField(this, "_findLiquid", new Liquid());
23783
23876
  // Use for hyphenation.
@@ -23800,7 +23893,7 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
23800
23893
  if (!this.dirty)
23801
23894
  return;
23802
23895
  const ctx = this._prepareLayoutContext();
23803
- this._skeletonData = this._createSkeleton(ctx, bounds);
23896
+ this._skeletonData = this._createSkeleton(ctx, bounds), this._dirty$.next(!0);
23804
23897
  }
23805
23898
  getSkeletonData() {
23806
23899
  return this._skeletonData;
@@ -23879,7 +23972,7 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
23879
23972
  break;
23880
23973
  index2 += g.count;
23881
23974
  }
23882
- return index2;
23975
+ return position.isBack ? index2 : index2 + glyph.count;
23883
23976
  }
23884
23977
  findNodePositionByCharIndex(charIndex, isBack = !0, segmentId = "", segmentPIndex = -1) {
23885
23978
  const nodes = this._findNodeByIndex(charIndex, segmentId, segmentPIndex);
@@ -23931,10 +24024,8 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
23931
24024
  const skeletonData = this.getSkeletonData();
23932
24025
  if (skeletonData == null)
23933
24026
  return;
23934
- const { pages, skeFooters, skeHeaders } = skeletonData, { divide, line: line2, column, section, isBack, segmentPage, pageType, path } = position;
23935
- let { glyph } = position;
23936
- isBack === !1 && (glyph += 1);
23937
- let skePage = null;
24027
+ const { pages, skeFooters, skeHeaders } = skeletonData, { divide, line: line2, column, section, segmentPage, pageType, path } = position;
24028
+ let { glyph } = position, skePage = null;
23938
24029
  if (pageType === DocumentSkeletonPageType.HEADER || pageType === DocumentSkeletonPageType.FOOTER) {
23939
24030
  skePage = pages[segmentPage];
23940
24031
  const { headerId, footerId, pageWidth } = skePage;
@@ -23997,8 +24088,7 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
23997
24088
  return;
23998
24089
  const cache = {
23999
24090
  nearestNodeList: [],
24000
- nearestNodeDistanceList: [],
24001
- nearestNodeDistanceY: Number.POSITIVE_INFINITY
24091
+ nearestNodeDistanceList: []
24002
24092
  }, { pages, skeHeaders, skeFooters } = skeletonData, editArea = this.findEditAreaByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop).editArea;
24003
24093
  if (this._findLiquid.reset(), restrictions == null)
24004
24094
  for (let pi = 0, len = pages.length; pi < len; pi++) {
@@ -24126,7 +24216,9 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24126
24216
  _collectNearestNode(segmentPage, pageType, page, segmentId, pi, cache, x, y, nestLevel = 0) {
24127
24217
  var _a11, _b, _c, _d, _e, _f, _g, _h, _i;
24128
24218
  const { sections, skeTables } = segmentPage;
24129
- switch (this._findLiquid.translateSave(), pageType) {
24219
+ this._findLiquid.translateSave();
24220
+ 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;
24221
+ switch (pageType) {
24130
24222
  case DocumentSkeletonPageType.HEADER: {
24131
24223
  this._findLiquid.translatePagePadding({
24132
24224
  ...segmentPage,
@@ -24145,8 +24237,8 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24145
24237
  break;
24146
24238
  }
24147
24239
  }
24148
- const pointInPage = x >= this._findLiquid.x && x <= this._findLiquid.x + segmentPage.pageWidth && y >= this._findLiquid.y && y <= this._findLiquid.y + segmentPage.pageHeight;
24149
- if (pointInPage)
24240
+ if (pointInPage) {
24241
+ let nearestNodeDistanceY = Number.POSITIVE_INFINITY;
24150
24242
  for (const section of sections) {
24151
24243
  const { columns } = section;
24152
24244
  this._findLiquid.translateSave(), this._findLiquid.translateSection(section);
@@ -24175,7 +24267,7 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24175
24267
  ratioX: x / (startX_fin + endX_fin),
24176
24268
  ratioY: y / (startY_fin + endY_fin)
24177
24269
  };
24178
- cache.nearestNodeDistanceY !== Number.NEGATIVE_INFINITY && (cache.nearestNodeList = [], cache.nearestNodeDistanceList = []), cache.nearestNodeList.push({
24270
+ nearestNodeDistanceY !== Number.NEGATIVE_INFINITY && (cache.nearestNodeList = [], cache.nearestNodeDistanceList = []), cache.nearestNodeList.push({
24179
24271
  node: glyph,
24180
24272
  segmentPage: pageType === DocumentSkeletonPageType.BODY ? -1 : pi,
24181
24273
  segmentId,
@@ -24185,10 +24277,10 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24185
24277
  coordInPage: pointInPage,
24186
24278
  distance: distanceX,
24187
24279
  nestLevel
24188
- }), cache.nearestNodeDistanceY = Number.NEGATIVE_INFINITY;
24280
+ }), nearestNodeDistanceY = Number.NEGATIVE_INFINITY;
24189
24281
  continue;
24190
24282
  }
24191
- distanceY < cache.nearestNodeDistanceY && (cache.nearestNodeDistanceY = distanceY, cache.nearestNodeList = [], cache.nearestNodeDistanceList = []), distanceY === cache.nearestNodeDistanceY && (cache.nearestNodeList.push({
24283
+ distanceY < nearestNodeDistanceY && (nearestNodeDistanceY = distanceY, cache.nearestNodeList = [], cache.nearestNodeDistanceList = []), distanceY === nearestNodeDistanceY && (cache.nearestNodeList.push({
24192
24284
  node: glyph,
24193
24285
  segmentPage: pageType === DocumentSkeletonPageType.BODY ? -1 : pi,
24194
24286
  segmentId,
@@ -24209,6 +24301,7 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24209
24301
  }
24210
24302
  this._findLiquid.translateRestore();
24211
24303
  }
24304
+ }
24212
24305
  let exactMatch = null;
24213
24306
  if (skeTables.size > 0)
24214
24307
  for (const table2 of skeTables.values()) {
@@ -24498,7 +24591,7 @@ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPrope
24498
24591
  function getDocsSkeletonPageSize(documentSkeleton, angleInDegree = 0) {
24499
24592
  const skeletonData = documentSkeleton == null ? void 0 : documentSkeleton.getSkeletonData(), angle = degToRad(angleInDegree);
24500
24593
  if (!skeletonData)
24501
- return;
24594
+ return null;
24502
24595
  const { pages } = skeletonData, lastPage = pages[pages.length - 1], { width, height } = lastPage;
24503
24596
  if (angle === 0)
24504
24597
  return { width, height };
@@ -24647,8 +24740,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24647
24740
  this._marginTop = top;
24648
24741
  }
24649
24742
  calculateSegment(bounds) {
24650
- if (this._worksheetData && (this._updateLayout(), !(!this._rowHeightAccumulation || !this._columnWidthAccumulation)))
24651
- return bounds != null && (this._rowColumnSegment = this.getRowColumnSegment(bounds)), !0;
24743
+ return !this._worksheetData || (this._updateLayout(), !this._rowHeightAccumulation || !this._columnWidthAccumulation) ? !1 : (bounds != null && (this._rowColumnSegment = this.getRowColumnSegment(bounds)), !0);
24652
24744
  }
24653
24745
  calculateWithoutClearingCache(bounds) {
24654
24746
  if (!this.calculateSegment(bounds))
@@ -24694,8 +24786,11 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24694
24786
  continue;
24695
24787
  const cell = worksheet.getCell(rowNum, i);
24696
24788
  if (cell != null && cell.interceptorAutoHeight) {
24697
- height = Math.max(height, cell.interceptorAutoHeight);
24698
- continue;
24789
+ const cellHeight = cell.interceptorAutoHeight();
24790
+ if (cellHeight) {
24791
+ height = Math.max(height, cellHeight);
24792
+ continue;
24793
+ }
24699
24794
  }
24700
24795
  const modelObject = cell && this._getCellDocumentModel(cell);
24701
24796
  if (modelObject == null)
@@ -24721,6 +24816,9 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24721
24816
  }
24722
24817
  return Math.min(height, MAXIMUM_ROW_HEIGHT);
24723
24818
  }
24819
+ /**
24820
+ * Calculate data for row col & cell position, then update position value to this._rowHeaderWidth & this._rowHeightAccumulation & this._columnHeaderHeight & this._columnWidthAccumulation.
24821
+ */
24724
24822
  _updateLayout() {
24725
24823
  if (!this.dirty)
24726
24824
  return;
@@ -24743,7 +24841,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24743
24841
  columnData,
24744
24842
  defaultColumnWidth
24745
24843
  );
24746
- return this._rowHeaderWidth = rowHeader.hidden !== BooleanNumber.TRUE ? this._dynamicallyUpdateRowHeaderWidth(rowHeader) : 0, this._columnHeaderHeight = columnHeader.hidden !== BooleanNumber.TRUE ? columnHeader.height : 0, this._rowTotalHeight = rowTotalHeight, this._rowHeightAccumulation = rowHeightAccumulation, this._columnTotalWidth = columnTotalWidth, this._columnWidthAccumulation = columnWidthAccumulation, this._showGridlines = showGridlines, this.makeDirty(!1), this;
24844
+ this._rowHeaderWidth = rowHeader.hidden !== BooleanNumber.TRUE ? this._dynamicallyUpdateRowHeaderWidth(rowHeader) : 0, this._columnHeaderHeight = columnHeader.hidden !== BooleanNumber.TRUE ? columnHeader.height : 0, this._rowTotalHeight = rowTotalHeight, this._rowHeightAccumulation = rowHeightAccumulation, this._columnTotalWidth = columnTotalWidth, this._columnWidthAccumulation = columnWidthAccumulation, this._showGridlines = showGridlines, this.makeDirty(!1);
24747
24845
  }
24748
24846
  _dynamicallyUpdateRowHeaderWidth(rowHeader) {
24749
24847
  const widthByComputation = `${this.worksheet.getRowCount()}`.length * 8;
@@ -24819,7 +24917,8 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24819
24917
  return this._rowHeightAccumulation.length;
24820
24918
  }
24821
24919
  getOverflowPosition(contentSize, horizontalAlign, row, column, columnCount) {
24822
- const { width: contentWidth } = contentSize;
24920
+ var _a11;
24921
+ const contentWidth = (_a11 = contentSize == null ? void 0 : contentSize.width) != null ? _a11 : 0;
24823
24922
  let startColumn = column, endColumn = column;
24824
24923
  return horizontalAlign === HorizontalAlign.CENTER ? (startColumn = this._getOverflowBound(row, column, 0, contentWidth / 2, horizontalAlign), endColumn = this._getOverflowBound(row, column, columnCount - 1, contentWidth / 2, horizontalAlign)) : horizontalAlign === HorizontalAlign.RIGHT ? startColumn = this._getOverflowBound(row, column, 0, contentWidth) : endColumn = this._getOverflowBound(row, column, columnCount - 1, contentWidth), {
24825
24924
  startColumn,
@@ -24861,7 +24960,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24861
24960
  };
24862
24961
  }
24863
24962
  /**
24864
- *
24963
+ * Get cell by pos(offsetX, offsetY).
24865
24964
  * @param offsetX HTML coordinate system, mouse position x.
24866
24965
  * @param offsetY HTML coordinate system, mouse position y.
24867
24966
  * @param scaleX render scene scale x-axis, scene.getAncestorScale
@@ -25006,14 +25105,14 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25006
25105
  getBlankCellDocumentModel(cell) {
25007
25106
  const documentModelObject = this._getCellDocumentModel(cell, {
25008
25107
  ignoreTextRotation: !0
25009
- });
25108
+ }), style = this._styles.getStyleByCell(cell), textStyle = this._getFontFormat(style);
25010
25109
  if (documentModelObject != null)
25011
- return documentModelObject.documentModel == null && (documentModelObject.documentModel = this._getDocumentDataByStyle("", {}, {})), documentModelObject;
25110
+ return documentModelObject.documentModel == null && (documentModelObject.documentModel = this._getDocumentDataByStyle("", textStyle, {})), documentModelObject;
25012
25111
  const content = "";
25013
25112
  let fontString = "document";
25014
25113
  const textRotation = DEFAULT_STYLES.tr, horizontalAlign = DEFAULT_STYLES.ht, verticalAlign = DEFAULT_STYLES.vt, wrapStrategy = DEFAULT_STYLES.tb, paddingData = DEFAULT_PADDING_DATA;
25015
25114
  return fontString = getFontStyleString({}, this._localService).fontCache, {
25016
- documentModel: this._getDocumentDataByStyle(content, {}, {}),
25115
+ documentModel: this._getDocumentDataByStyle(content, textStyle, {}),
25017
25116
  fontString,
25018
25117
  textRotation,
25019
25118
  wrapStrategy,
@@ -25146,6 +25245,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25146
25245
  return !0;
25147
25246
  this.appendToOverflowCache(row, column, startColumn, endColumn);
25148
25247
  }
25248
+ return !1;
25149
25249
  }
25150
25250
  /**
25151
25251
  *
@@ -25213,6 +25313,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25213
25313
  columnWidthAccumulation
25214
25314
  };
25215
25315
  }
25316
+ //eslint-disable-next-line complexity
25216
25317
  _getOverflowBound(row, startColumn, endColumn, contentWidth, horizontalAlign = HorizontalAlign.LEFT) {
25217
25318
  let cumWidth = 0;
25218
25319
  if (startColumn > endColumn) {
@@ -25275,18 +25376,20 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25275
25376
  // return mergeRangeCache;
25276
25377
  // }
25277
25378
  _calculateStylesCache() {
25278
- const dataMergeCache = this._dataMergeCache, rowColumnSegment = this._rowColumnSegment, columnWidthAccumulation = this.columnWidthAccumulation, { startRow, endRow, startColumn, endColumn } = rowColumnSegment;
25379
+ const dataMergeCaches = this._dataMergeCache, rowColumnSegment = this._rowColumnSegment, columnWidthAccumulation = this.columnWidthAccumulation, { startRow, endRow, startColumn, endColumn } = rowColumnSegment;
25279
25380
  if (!(endColumn === -1 || endRow === -1)) {
25280
- for (const data2 of dataMergeCache)
25281
- this._setCellCache(data2.startRow, data2.startColumn, !1, data2);
25381
+ for (const mergeRange of dataMergeCaches)
25382
+ this._setCellStylesCache(mergeRange.startRow, mergeRange.startColumn, {
25383
+ mergeRange
25384
+ });
25282
25385
  for (let r = startRow; r <= endRow; r++) {
25283
25386
  for (let c = startColumn; c <= endColumn; c++)
25284
- this._setCellCache(r, c, !1);
25387
+ this._setCellStylesCache(r, c);
25285
25388
  for (let c = 0; c < startColumn; c++)
25286
- this._setCellCache(r, c, !0);
25389
+ this._setCellStylesCache(r, c, { cacheItem: { bg: !1, border: !1 } });
25287
25390
  if (endColumn !== 0)
25288
25391
  for (let c = endColumn + 1; c < columnWidthAccumulation.length; c++)
25289
- this._setCellCache(r, c, !0);
25392
+ this._setCellStylesCache(r, c, { cacheItem: { bg: !1, border: !1 } });
25290
25393
  }
25291
25394
  }
25292
25395
  }
@@ -25314,11 +25417,11 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25314
25417
  }
25315
25418
  }
25316
25419
  // eslint-disable-next-line complexity
25317
- _setCellCache(r, c, skipBackgroundAndBorder, mergeRange) {
25420
+ _setCellStylesCache(r, c, options) {
25318
25421
  var _a11;
25319
- const needsRendering = this._renderedCellCache.getValue(r, c);
25320
25422
  if (r === -1 || c === -1)
25321
25423
  return !0;
25424
+ const needsRendering = this._renderedCellCache.getValue(r, c);
25322
25425
  if (needsRendering === !1)
25323
25426
  return this._makeDocumentSkeletonDirty(r, c), !0;
25324
25427
  const cell = this.worksheet.getCell(r, c) || this.worksheet.getCellRaw(r, c);
@@ -25335,14 +25438,18 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25335
25438
  if (!isMergedMainCell)
25336
25439
  return !0;
25337
25440
  }
25338
- const cache = this._stylesCache, style = this._styles.getStyleByCell(cell);
25339
- if (!skipBackgroundAndBorder && style && style.bg && style.bg.rgb) {
25441
+ const cache = this._stylesCache, style = this._styles.getStyleByCell(cell), cacheItem = (options == null ? void 0 : options.cacheItem) || { bg: !0, border: !0 };
25442
+ if (cacheItem.bg && style && style.bg && style.bg.rgb) {
25340
25443
  const rgb = style.bg.rgb;
25341
25444
  cache.background[rgb] || (cache.background[rgb] = new ObjectMatrix()), cache.background[rgb].setValue(r, c, rgb);
25342
25445
  const cellInfo = this.getCellByIndexWithNoHeader(r, c);
25343
25446
  (_a11 = cache.backgroundPositions) == null || _a11.setValue(r, c, cellInfo);
25344
25447
  }
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)
25448
+ if (cacheItem.border && style && style.bd) {
25449
+ const mergeRange = options == null ? void 0 : options.mergeRange;
25450
+ 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);
25451
+ }
25452
+ if (needsRendering === !0)
25346
25453
  return this._makeDocumentSkeletonDirty(r, c), !0;
25347
25454
  if (isNullCell(cell))
25348
25455
  return;
@@ -25370,7 +25477,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25370
25477
  };
25371
25478
  fontCache2.setValue(r, c, config), this._calculateOverflowCell(r, c, config);
25372
25479
  }
25373
- skipBackgroundAndBorder ? this._renderedCellCache.setValue(r, c, !0) : this._renderedCellCache.setValue(r, c, !1);
25480
+ cacheItem.bg || cacheItem.border ? this._renderedCellCache.setValue(r, c, !1) : this._renderedCellCache.setValue(r, c, !0);
25374
25481
  }
25375
25482
  _updateConfigAndGetDocumentModel(documentData, horizontalAlign, renderConfig) {
25376
25483
  var _a11;
@@ -25391,7 +25498,8 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25391
25498
  paddingData = {
25392
25499
  t: 0,
25393
25500
  r: 2,
25394
- b: 1,
25501
+ b: 2,
25502
+ // must over 1, see https://github.com/dream-num/univer/issues/2727
25395
25503
  l: 2
25396
25504
  },
25397
25505
  horizontalAlign = HorizontalAlign.UNSPECIFIED,
@@ -25416,7 +25524,10 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25416
25524
  horizontalAlign
25417
25525
  }
25418
25526
  }
25419
- ]
25527
+ ],
25528
+ sectionBreaks: [{
25529
+ startIndex: contentLength + 1
25530
+ }]
25420
25531
  },
25421
25532
  documentStyle: {
25422
25533
  pageSize: {
@@ -25489,13 +25600,13 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25489
25600
  var _a11, _b, _c;
25490
25601
  const props = (_a11 = style.bd) == null ? void 0 : _a11[type];
25491
25602
  if (!props || !cache.border)
25492
- return !0;
25603
+ return;
25493
25604
  const rgb = getColorStyle(props.cl) || COLOR_BLACK_RGB, borderCache = cache.border;
25494
25605
  if (borderCache.getValue(r, c) || borderCache.setValue(r, c, { [type]: {} }), type === BORDER_TYPE.TOP) {
25495
25606
  if (((_b = borderCache.getValue(r - 1, c)) == null ? void 0 : _b[BORDER_TYPE.BOTTOM]) && isWhiteColor(rgb))
25496
- return !0;
25607
+ return;
25497
25608
  } else if (type === BORDER_TYPE.LEFT && ((_c = borderCache.getValue(r, c - 1)) == null ? void 0 : _c[BORDER_TYPE.RIGHT]) && isWhiteColor(rgb))
25498
- return !0;
25609
+ return;
25499
25610
  borderCache.getValue(r, c)[type] = {
25500
25611
  type,
25501
25612
  style: props.s,
@@ -25584,14 +25695,13 @@ const UNIQUE_KEY$7 = "DefaultFontExtension", EXTENSION_Z_INDEX = 45, _Font = cla
25584
25695
  }
25585
25696
  draw(ctx, parentScale, spreadsheetSkeleton, diffRanges, moreBoundsInfo) {
25586
25697
  const { viewRanges = [], checkOutOfViewBound } = moreBoundsInfo, { stylesCache, dataMergeCache, overflowCache, worksheet } = spreadsheetSkeleton, { font: fontList } = stylesCache;
25587
- if (!spreadsheetSkeleton || !worksheet)
25698
+ if (!spreadsheetSkeleton || !worksheet || !fontList)
25588
25699
  return;
25589
25700
  const { rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;
25590
25701
  if (!rowHeightAccumulation || !columnWidthAccumulation || columnTotalWidth === void 0 || rowTotalHeight === void 0 || !worksheet)
25591
25702
  return;
25592
25703
  ctx.save();
25593
- const scale = this._getScale(parentScale);
25594
- fontList && Object.keys(fontList).forEach((fontFormat) => {
25704
+ const scale = this._getScale(parentScale), renderFontByCell = /* @__PURE__ */ __name((fontFormat) => {
25595
25705
  fontList[fontFormat].forValue((rowIndex, columnIndex, docsConfig) => {
25596
25706
  var _a11, _b, _c, _d, _e;
25597
25707
  if (!checkOutOfViewBound && !inViewRanges(viewRanges, rowIndex, columnIndex))
@@ -25666,13 +25776,14 @@ const UNIQUE_KEY$7 = "DefaultFontExtension", EXTENSION_Z_INDEX = 45, _Font = cla
25666
25776
  ctx.rectByPrecision(startX + 1 / scale, startY + 1 / scale, cellWidth - 2 / scale, cellHeight - 2 / scale), ctx.clip();
25667
25777
  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
25778
  });
25669
- }), ctx.restore();
25779
+ }, "renderFontByCell");
25780
+ Object.keys(fontList).forEach(renderFontByCell), ctx.restore();
25670
25781
  }
25671
25782
  _renderDocuments(ctx, docsConfig, startX, startY, endX, endY, row, column, overflowCache) {
25672
25783
  const documents = this.getDocuments();
25673
25784
  if (documents == null)
25674
25785
  throw new Error("documents is null");
25675
- const { documentSkeleton, vertexAngle = 0, wrapStrategy } = docsConfig, cellWidth = endX - startX, cellHeight = endY - startY;
25786
+ const { documentSkeleton, vertexAngle = 0, wrapStrategy } = docsConfig, cellHeight = endY - startY, cellWidth = endX - startX;
25676
25787
  wrapStrategy === WrapStrategy.WRAP && vertexAngle === 0 ? (documentSkeleton.getViewModel().getDataModel().updateDocumentDataPageSize(cellWidth), documentSkeleton.calculate()) : documentSkeleton.getViewModel().getDataModel().updateDocumentDataPageSize(Number.POSITIVE_INFINITY);
25677
25788
  const overflowRectangle = overflowCache.getValue(row, column);
25678
25789
  if (!(wrapStrategy === WrapStrategy.WRAP && !overflowRectangle && vertexAngle === 0)) {
@@ -26210,16 +26321,19 @@ const SHAPE_OBJECT_ARRAY = [
26210
26321
  const m = this.transform.getMatrix();
26211
26322
  return mainCtx.save(), mainCtx.transform(m[0], m[1], m[2], m[3], m[4], m[5]), this._draw(mainCtx, bounds), mainCtx.restore(), this.makeDirty(!1), this;
26212
26323
  }
26324
+ /**
26325
+ * this[_key] = props[key]
26326
+ * @param props
26327
+ */
26213
26328
  setProps(props) {
26214
26329
  if (!props)
26215
- return;
26330
+ return this;
26216
26331
  const themeKeys = Object.keys(props);
26217
- if (themeKeys.length !== 0)
26218
- return themeKeys.forEach((key) => {
26219
- if (props[key] === void 0)
26220
- return !0;
26221
- BASE_OBJECT_ARRAY.indexOf(key) === -1 && (this[`_${key}`] = props[key]);
26222
- }), this.makeDirty(!0), this;
26332
+ return themeKeys.length === 0 ? this : (themeKeys.forEach((key) => {
26333
+ if (props[key] === void 0)
26334
+ return !0;
26335
+ BASE_OBJECT_ARRAY.indexOf(key) === -1 && (this[`_${key}`] = props[key]);
26336
+ }), this.makeDirty(!0), this);
26223
26337
  }
26224
26338
  toJson() {
26225
26339
  const props = {};
@@ -27334,12 +27448,11 @@ const RICHTEXT_OBJECT_ARRAY = ["text", "richText", "fs"], _RichText = class _Ric
27334
27448
  }), this.setProps(props), this.makeDirty(!0);
27335
27449
  }
27336
27450
  /**
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
27451
+ * After changing editor size & end of editing, update skeleton of doc.
27342
27452
  */
27453
+ // TODO: This method should be invoked when _documentData changed.
27454
+ // _documentData changed ---> update _documentSkeleton & _documentSkeleton
27455
+ // now it is invoked when transformByState(change editor size) & end of editing
27343
27456
  refreshDocumentByDocData() {
27344
27457
  const docModel = this.documentModel = new DocumentDataModel(this._documentData), docViewModel = new DocumentViewModel(docModel);
27345
27458
  this._documentSkeleton = DocumentSkeleton.create(docViewModel, this._localeService), this._documents = new Documents(`${this.oKey}_DOCUMENTS`, this._documentSkeleton, {
@@ -27746,21 +27859,21 @@ const UNIQUE_KEY = "DefaultDocsLineExtension", DOC_EXTENSION_Z_INDEX = 40, _Line
27746
27859
  const line2 = (_a11 = glyph.parent) == null ? void 0 : _a11.parent, { ts: textStyle, bBox, content } = glyph;
27747
27860
  if (line2 == null || textStyle == null || content === "\r")
27748
27861
  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;
27862
+ 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
27863
  if (underline) {
27751
- const startY = asc + dsc + paddingTop;
27864
+ const startY = asc + dsc;
27752
27865
  this._drawLine(ctx, glyph, underline, startY, scale);
27753
27866
  }
27754
27867
  if (bottomBorderLine) {
27755
- const startY = asc + dsc + 3 + paddingTop;
27868
+ const startY = asc + dsc + 3;
27756
27869
  this._drawLine(ctx, glyph, bottomBorderLine, startY, scale, 2);
27757
27870
  }
27758
27871
  if (strikethrough) {
27759
- let startY = asc + bd - strikeoutPosition - DELTA + paddingTop;
27872
+ let startY = asc + bd - strikeoutPosition - DELTA;
27760
27873
  baselineOffset === BaselineOffset.SUPERSCRIPT ? startY -= spo : baselineOffset === BaselineOffset.SUBSCRIPT && (startY += sbo), this._drawLine(ctx, glyph, strikethrough, startY, scale);
27761
27874
  }
27762
27875
  if (overline) {
27763
- const startY = -DEFAULT_OFFSET_SPACING - DELTA + paddingTop;
27876
+ const startY = -DEFAULT_OFFSET_SPACING - DELTA;
27764
27877
  this._drawLine(ctx, glyph, overline, startY, scale);
27765
27878
  }
27766
27879
  }
@@ -28015,7 +28128,7 @@ const _Documents = class _Documents extends DocComponent {
28015
28128
  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
28129
  } else wrapStrategy === WrapStrategy.WRAP && (horizontalAlign !== HorizontalAlign.UNSPECIFIED || cellValueType !== CellValueType.NUMBER) && (alignOffset.x = pagePaddingLeft);
28017
28130
  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);
28131
+ const line2 = lines[i2], { divides, asc = 0, type, lineHeight = 0 } = line2, maxLineAsc = asc, maxLineAscSin = maxLineAsc * Math.sin(centerAngle), maxLineAscCos = maxLineAsc * Math.cos(centerAngle);
28019
28132
  if (type === LineType.BLOCK)
28020
28133
  for (const extension of extensions)
28021
28134
  extension.type === DOCS_EXTENSION_TYPE.LINE && (extension.extensionOffset = {
@@ -28023,7 +28136,7 @@ const _Documents = class _Documents extends DocComponent {
28023
28136
  renderConfig
28024
28137
  }, extension.draw(ctx, parentScale, line2));
28025
28138
  else {
28026
- this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0), rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i2]);
28139
+ this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0, !0), rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i2]);
28027
28140
  const divideLength = divides.length;
28028
28141
  for (let i3 = 0; i3 < divideLength; i3++) {
28029
28142
  const divide = divides[i3], { glyphGroup } = divide;
@@ -28033,7 +28146,7 @@ const _Documents = class _Documents extends DocComponent {
28033
28146
  continue;
28034
28147
  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
28148
  spanStartPoint: calculateRectRotate(
28036
- originTranslate.addByPoint(spanLeft, paddingTop),
28149
+ originTranslate.addByPoint(spanLeft, 0),
28037
28150
  centerPoint,
28038
28151
  centerAngle,
28039
28152
  vertexAngle,
@@ -28046,7 +28159,7 @@ const _Documents = class _Documents extends DocComponent {
28046
28159
  if (!glyph.content || glyph.content.length === 0)
28047
28160
  continue;
28048
28161
  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),
28162
+ originTranslate.addByPoint(spanLeft + xOffset, 0),
28050
28163
  centerPoint,
28051
28164
  centerAngle,
28052
28165
  vertexAngle,
@@ -28054,7 +28167,7 @@ const _Documents = class _Documents extends DocComponent {
28054
28167
  ), spanPointWithFont = calculateRectRotate(
28055
28168
  originTranslate.addByPoint(
28056
28169
  spanLeft + maxLineAscSin + xOffset,
28057
- maxLineAscCos + paddingTop
28170
+ maxLineAscCos
28058
28171
  ),
28059
28172
  centerPoint,
28060
28173
  centerAngle,
@@ -28160,7 +28273,7 @@ const _Documents = class _Documents extends DocComponent {
28160
28273
  this._drawLiquid.translateSave(), this._drawLiquid.translateColumn(column);
28161
28274
  const linesCount = lines.length, alignOffset = alignOffsetNoAngle;
28162
28275
  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);
28276
+ const line2 = lines[i], { divides, asc = 0, type, lineHeight = 0 } = line2, maxLineAsc = asc, maxLineAscSin = maxLineAsc * Math.sin(centerAngle), maxLineAscCos = maxLineAsc * Math.cos(centerAngle);
28164
28277
  if (type === LineType.BLOCK)
28165
28278
  for (const extension of extensions)
28166
28279
  extension.type === DOCS_EXTENSION_TYPE.LINE && (extension.extensionOffset = {
@@ -28168,7 +28281,7 @@ const _Documents = class _Documents extends DocComponent {
28168
28281
  renderConfig
28169
28282
  }, extension.draw(ctx, parentScale, line2));
28170
28283
  else {
28171
- this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0);
28284
+ this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0, !0);
28172
28285
  const divideLength = divides.length;
28173
28286
  for (let i2 = 0; i2 < divideLength; i2++) {
28174
28287
  const divide = divides[i2], { glyphGroup } = divide;
@@ -28178,7 +28291,7 @@ const _Documents = class _Documents extends DocComponent {
28178
28291
  continue;
28179
28292
  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
28293
  spanStartPoint: calculateRectRotate(
28181
- originTranslate.addByPoint(spanLeft, paddingTop),
28294
+ originTranslate.addByPoint(spanLeft, 0),
28182
28295
  centerPoint,
28183
28296
  centerAngle,
28184
28297
  vertexAngle,
@@ -28191,7 +28304,7 @@ const _Documents = class _Documents extends DocComponent {
28191
28304
  if (!glyph.content || glyph.content.length === 0)
28192
28305
  continue;
28193
28306
  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),
28307
+ originTranslate.addByPoint(spanLeft + xOffset, 0),
28195
28308
  centerPoint,
28196
28309
  centerAngle,
28197
28310
  vertexAngle,
@@ -28199,7 +28312,7 @@ const _Documents = class _Documents extends DocComponent {
28199
28312
  ), spanPointWithFont = calculateRectRotate(
28200
28313
  originTranslate.addByPoint(
28201
28314
  spanLeft + maxLineAscSin + xOffset,
28202
- maxLineAscCos + paddingTop
28315
+ maxLineAscCos
28203
28316
  ),
28204
28317
  centerPoint,
28205
28318
  centerAngle,
@@ -28265,7 +28378,7 @@ const _Documents = class _Documents extends DocComponent {
28265
28378
  this._drawLiquid.translateSave(), this._drawLiquid.translateColumn(column);
28266
28379
  const linesCount = lines.length, alignOffset = alignOffsetNoAngle;
28267
28380
  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);
28381
+ const line2 = lines[i], { divides, asc = 0, type, lineHeight = 0 } = line2, maxLineAsc = asc, maxLineAscSin = maxLineAsc * Math.sin(centerAngle), maxLineAscCos = maxLineAsc * Math.cos(centerAngle);
28269
28382
  if (type === LineType.BLOCK)
28270
28383
  for (const extension of extensions)
28271
28384
  extension.type === DOCS_EXTENSION_TYPE.LINE && (extension.extensionOffset = {
@@ -28273,7 +28386,7 @@ const _Documents = class _Documents extends DocComponent {
28273
28386
  renderConfig
28274
28387
  }, extension.draw(ctx, parentScale, line2));
28275
28388
  else {
28276
- this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0);
28389
+ this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0, !0);
28277
28390
  const { y } = this._drawLiquid;
28278
28391
  if (isHeader) {
28279
28392
  if (y - originY + alignOffset.y > (parentPage.pageHeight - 100) / 2) {
@@ -28293,7 +28406,7 @@ const _Documents = class _Documents extends DocComponent {
28293
28406
  continue;
28294
28407
  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
28408
  spanStartPoint: calculateRectRotate(
28296
- originTranslate.addByPoint(spanLeft, paddingTop),
28409
+ originTranslate.addByPoint(spanLeft, 0),
28297
28410
  centerPoint,
28298
28411
  centerAngle,
28299
28412
  vertexAngle,
@@ -28306,7 +28419,7 @@ const _Documents = class _Documents extends DocComponent {
28306
28419
  if (!glyph.content || glyph.content.length === 0)
28307
28420
  continue;
28308
28421
  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),
28422
+ originTranslate.addByPoint(spanLeft + xOffset, 0),
28310
28423
  centerPoint,
28311
28424
  centerAngle,
28312
28425
  vertexAngle,
@@ -28314,7 +28427,7 @@ const _Documents = class _Documents extends DocComponent {
28314
28427
  ), spanPointWithFont = calculateRectRotate(
28315
28428
  originTranslate.addByPoint(
28316
28429
  spanLeft + maxLineAscSin + xOffset,
28317
- maxLineAscCos + paddingTop
28430
+ maxLineAscCos
28318
28431
  ),
28319
28432
  centerPoint,
28320
28433
  centerAngle,
@@ -28407,8 +28520,6 @@ const OBJECT_KEY = "__SHEET_EXTENSION_FONT_DOCUMENT_INSTANCE__", _Spreadsheet =
28407
28520
  }
28408
28521
  /**
28409
28522
  * draw by viewport
28410
- * cacheBound ---> viewBound
28411
- * diffCacheBounds ---> diffRange
28412
28523
  * @param ctx
28413
28524
  * @param viewportInfo
28414
28525
  */
@@ -29080,9 +29191,17 @@ function getOverflowAncestors(node, list, traverseIframes) {
29080
29191
  var _node$ownerDocument2;
29081
29192
  list === void 0 && (list = []), traverseIframes === void 0 && (traverseIframes = !0);
29082
29193
  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));
29194
+ if (isBody) {
29195
+ const frameElement = getFrameElement(win);
29196
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
29197
+ }
29198
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
29084
29199
  }
29085
29200
  __name(getOverflowAncestors, "getOverflowAncestors");
29201
+ function getFrameElement(win) {
29202
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
29203
+ }
29204
+ __name(getFrameElement, "getFrameElement");
29086
29205
  function observeClientRect(containerElement) {
29087
29206
  return new Observable((observer) => {
29088
29207
  const disposable = autoClientRect(containerElement, () => observer.next());
@@ -29187,7 +29306,7 @@ const _Engine = class _Engine extends ThinEngine {
29187
29306
  __publicField(this, "_dropEvent");
29188
29307
  __publicField(this, "_remainCapture", -1);
29189
29308
  /** previous pointer position */
29190
- __publicField(this, "pointer", {});
29309
+ __publicField(this, "_pointer", {});
29191
29310
  __publicField(this, "_mouseId", -1);
29192
29311
  __publicField(this, "_isUsingFirefox", navigator.userAgent.indexOf("Firefox") !== -1);
29193
29312
  __publicField(this, "_previousWidth", -1e3);
@@ -29388,21 +29507,21 @@ const _Engine = class _Engine extends ThinEngine {
29388
29507
  const eventPrefix = getPointerPrefix();
29389
29508
  this._pointerMoveEvent = (e) => {
29390
29509
  const evt = e, deviceType = this._getPointerType(evt);
29391
- this.pointer[PointerInput.Horizontal] = evt.clientX, this.pointer[PointerInput.Vertical] = evt.clientY, this.pointer[PointerInput.DeltaHorizontal] = evt.movementX, this.pointer[PointerInput.DeltaVertical] = evt.movementY;
29510
+ this._pointer[PointerInput.Horizontal] = evt.clientX, this._pointer[PointerInput.Vertical] = evt.clientY, this._pointer[PointerInput.DeltaHorizontal] = evt.movementX, this._pointer[PointerInput.DeltaVertical] = evt.movementY;
29392
29511
  const deviceEvent = evt;
29393
- deviceEvent.deviceType = deviceType, deviceEvent.inputIndex = PointerInput.Horizontal, this.onInputChanged$.emitEvent(deviceEvent), !this._usingSafari && evt.button !== -1 && (deviceEvent.inputIndex = evt.button + 2, deviceEvent.previousState = this.pointer[evt.button + 2], this.pointer[evt.button + 2] = this.pointer[evt.button + 2] ? 0 : 1, deviceEvent.currentState = this.pointer[evt.button + 2], this.onInputChanged$.emitEvent(deviceEvent));
29512
+ deviceEvent.deviceType = deviceType, deviceEvent.inputIndex = PointerInput.Horizontal, this.onInputChanged$.emitEvent(deviceEvent), !this._usingSafari && evt.button !== -1 && (deviceEvent.inputIndex = evt.button + 2, deviceEvent.previousState = this._pointer[evt.button + 2], this._pointer[evt.button + 2] = this._pointer[evt.button + 2] ? 0 : 1, deviceEvent.currentState = this._pointer[evt.button + 2], this.onInputChanged$.emitEvent(deviceEvent));
29394
29513
  }, this._pointerDownEvent = (nativeEvent) => {
29395
- const evt = nativeEvent, deviceType = this._getPointerType(evt), previousHorizontal = this.pointer[PointerInput.Horizontal], previousVertical = this.pointer[PointerInput.Vertical], previousButton = this.pointer[evt.button + 2];
29396
- deviceType === DeviceType.Mouse ? (this._mouseId === -1 && (evt.pointerId === void 0 ? this._mouseId = this._isUsingFirefox ? 0 : 1 : this._mouseId = evt.pointerId), document.pointerLockElement || (this._remainCapture = this._mouseId, this.getCanvasElement().setPointerCapture(this._mouseId))) : evt.pointerId && !document.pointerLockElement && (this._remainCapture = evt.pointerId, this.getCanvasElement().setPointerCapture(evt.pointerId)), this.pointer[PointerInput.Horizontal] = evt.clientX, this.pointer[PointerInput.Vertical] = evt.clientY, this.pointer[evt.button + 2] = 1;
29514
+ const evt = nativeEvent, deviceType = this._getPointerType(evt), previousHorizontal = this._pointer[PointerInput.Horizontal], previousVertical = this._pointer[PointerInput.Vertical], previousButton = this._pointer[evt.button + 2];
29515
+ deviceType === DeviceType.Mouse ? (this._mouseId === -1 && (evt.pointerId === void 0 ? this._mouseId = this._isUsingFirefox ? 0 : 1 : this._mouseId = evt.pointerId), document.pointerLockElement || (this._remainCapture = this._mouseId, this.getCanvasElement().setPointerCapture(this._mouseId))) : evt.pointerId && !document.pointerLockElement && (this._remainCapture = evt.pointerId, this.getCanvasElement().setPointerCapture(evt.pointerId)), this._pointer[PointerInput.Horizontal] = evt.clientX, this._pointer[PointerInput.Vertical] = evt.clientY, this._pointer[evt.button + 2] = 1;
29397
29516
  const deviceEvent = evt;
29398
- deviceEvent.deviceType = deviceType, previousHorizontal !== evt.clientX && (deviceEvent.inputIndex = PointerInput.Horizontal, deviceEvent.previousState = previousHorizontal, deviceEvent.currentState = this.pointer[PointerInput.Horizontal], this.onInputChanged$.emitEvent(deviceEvent)), previousVertical !== evt.clientY && (deviceEvent.inputIndex = PointerInput.Vertical, deviceEvent.previousState = previousVertical, deviceEvent.currentState = this.pointer[PointerInput.Vertical], this.onInputChanged$.emitEvent(deviceEvent)), deviceEvent.inputIndex = evt.button + 2, deviceEvent.previousState = previousButton, deviceEvent.currentState = this.pointer[evt.button + 2], this.onInputChanged$.emitEvent(deviceEvent);
29517
+ deviceEvent.deviceType = deviceType, previousHorizontal !== evt.clientX && (deviceEvent.inputIndex = PointerInput.Horizontal, deviceEvent.previousState = previousHorizontal, deviceEvent.currentState = this._pointer[PointerInput.Horizontal], this.onInputChanged$.emitEvent(deviceEvent)), previousVertical !== evt.clientY && (deviceEvent.inputIndex = PointerInput.Vertical, deviceEvent.previousState = previousVertical, deviceEvent.currentState = this._pointer[PointerInput.Vertical], this.onInputChanged$.emitEvent(deviceEvent)), deviceEvent.inputIndex = evt.button + 2, deviceEvent.previousState = previousButton, deviceEvent.currentState = this._pointer[evt.button + 2], this.onInputChanged$.emitEvent(deviceEvent);
29399
29518
  }, this._pointerUpEvent = (_evt) => {
29400
- const evt = _evt, deviceType = this._getPointerType(evt), previousHorizontal = this.pointer[PointerInput.Horizontal], previousVertical = this.pointer[PointerInput.Vertical], previousButton = this.pointer[evt.button + 2];
29401
- this.pointer[PointerInput.Horizontal] = evt.clientX, this.pointer[PointerInput.Vertical] = evt.clientY, this.pointer[evt.button + 2] = 0;
29519
+ const evt = _evt, deviceType = this._getPointerType(evt), previousHorizontal = this._pointer[PointerInput.Horizontal], previousVertical = this._pointer[PointerInput.Vertical], previousButton = this._pointer[evt.button + 2];
29520
+ this._pointer[PointerInput.Horizontal] = evt.clientX, this._pointer[PointerInput.Vertical] = evt.clientY, this._pointer[evt.button + 2] = 0;
29402
29521
  const deviceEvent = evt;
29403
- deviceEvent.deviceType = deviceType, previousHorizontal !== evt.clientX && (deviceEvent.inputIndex = PointerInput.Horizontal, deviceEvent.previousState = previousHorizontal, deviceEvent.currentState = this.pointer[PointerInput.Horizontal], this.onInputChanged$.emitEvent(deviceEvent)), previousVertical !== evt.clientY && (deviceEvent.inputIndex = PointerInput.Vertical, deviceEvent.previousState = previousVertical, deviceEvent.currentState = this.pointer[PointerInput.Vertical], this.onInputChanged$.emitEvent(deviceEvent)), deviceEvent.inputIndex = evt.button + 2, deviceEvent.previousState = previousButton, deviceEvent.currentState = this.pointer[evt.button + 2];
29522
+ deviceEvent.deviceType = deviceType, previousHorizontal !== evt.clientX && (deviceEvent.inputIndex = PointerInput.Horizontal, deviceEvent.previousState = previousHorizontal, deviceEvent.currentState = this._pointer[PointerInput.Horizontal], this.onInputChanged$.emitEvent(deviceEvent)), previousVertical !== evt.clientY && (deviceEvent.inputIndex = PointerInput.Vertical, deviceEvent.previousState = previousVertical, deviceEvent.currentState = this._pointer[PointerInput.Vertical], this.onInputChanged$.emitEvent(deviceEvent)), deviceEvent.inputIndex = evt.button + 2, deviceEvent.previousState = previousButton, deviceEvent.currentState = this._pointer[evt.button + 2];
29404
29523
  const canvasEle2 = this.getCanvasElement();
29405
- deviceType === DeviceType.Mouse && this._mouseId >= 0 && canvasEle2.hasPointerCapture(this._mouseId) ? (this._remainCapture = this._mouseId, canvasEle2.releasePointerCapture(this._mouseId)) : deviceEvent.pointerId && canvasEle2.hasPointerCapture(deviceEvent.pointerId) && (this._remainCapture = deviceEvent.pointerId, canvasEle2.releasePointerCapture(deviceEvent.pointerId)), this.onInputChanged$.emitEvent(deviceEvent), deviceType !== DeviceType.Mouse && (this.pointer = {});
29524
+ deviceType === DeviceType.Mouse && this._mouseId >= 0 && canvasEle2.hasPointerCapture(this._mouseId) ? (this._remainCapture = this._mouseId, canvasEle2.releasePointerCapture(this._mouseId)) : deviceEvent.pointerId && canvasEle2.hasPointerCapture(deviceEvent.pointerId) && (this._remainCapture = deviceEvent.pointerId, canvasEle2.releasePointerCapture(deviceEvent.pointerId)), this.onInputChanged$.emitEvent(deviceEvent), deviceType !== DeviceType.Mouse && (this._pointer = {});
29406
29525
  }, this._pointerEnterEvent = (evt) => {
29407
29526
  const deviceType = this._getPointerType(evt), deviceEvent = evt;
29408
29527
  deviceEvent.deviceType = deviceType, deviceEvent.currentState = 2, this.onInputChanged$.emitEvent(deviceEvent);
@@ -29416,12 +29535,12 @@ const _Engine = class _Engine extends ThinEngine {
29416
29535
  const deviceType = this._getPointerType(evt), deviceEvent = evt;
29417
29536
  deviceEvent.deviceType = deviceType, deviceEvent.currentState = 3, this.onInputChanged$.emitEvent(deviceEvent);
29418
29537
  }, this._pointerBlurEvent = () => {
29419
- this._mouseId >= 0 && this.getCanvasElement().hasPointerCapture(this._mouseId), this.pointer = {};
29538
+ this._mouseId >= 0 && this.getCanvasElement().hasPointerCapture(this._mouseId), this._pointer = {};
29420
29539
  }, this._pointerWheelEvent = (evt) => {
29421
- const deviceType = DeviceType.Mouse, previousWheelScrollX = this.pointer[PointerInput.MouseWheelX], previousWheelScrollY = this.pointer[PointerInput.MouseWheelY], previousWheelScrollZ = this.pointer[PointerInput.MouseWheelZ];
29422
- this.pointer[PointerInput.MouseWheelX] = evt.deltaX || 0, this.pointer[PointerInput.MouseWheelY] = evt.deltaY || evt.wheelDelta || 0, this.pointer[PointerInput.MouseWheelZ] = evt.deltaZ || 0;
29540
+ const deviceType = DeviceType.Mouse, previousWheelScrollX = this._pointer[PointerInput.MouseWheelX], previousWheelScrollY = this._pointer[PointerInput.MouseWheelY], previousWheelScrollZ = this._pointer[PointerInput.MouseWheelZ];
29541
+ this._pointer[PointerInput.MouseWheelX] = evt.deltaX || 0, this._pointer[PointerInput.MouseWheelY] = evt.deltaY || evt.wheelDelta || 0, this._pointer[PointerInput.MouseWheelZ] = evt.deltaZ || 0;
29423
29542
  const deviceEvent = evt;
29424
- deviceEvent.deviceType = deviceType, this.pointer[PointerInput.MouseWheelX] !== 0 && (deviceEvent.inputIndex = PointerInput.MouseWheelX, deviceEvent.previousState = previousWheelScrollX, deviceEvent.currentState = this.pointer[PointerInput.MouseWheelX], this.onInputChanged$.emitEvent(deviceEvent)), this.pointer[PointerInput.MouseWheelY] !== 0 && (deviceEvent.inputIndex = PointerInput.MouseWheelY, deviceEvent.previousState = previousWheelScrollY, deviceEvent.currentState = this.pointer[PointerInput.MouseWheelY], this.onInputChanged$.emitEvent(deviceEvent)), this.pointer[PointerInput.MouseWheelZ] !== 0 && (deviceEvent.inputIndex = PointerInput.MouseWheelZ, deviceEvent.previousState = previousWheelScrollZ, deviceEvent.currentState = this.pointer[PointerInput.MouseWheelZ], this.onInputChanged$.emitEvent(deviceEvent));
29543
+ deviceEvent.deviceType = deviceType, this._pointer[PointerInput.MouseWheelX] !== 0 && (deviceEvent.inputIndex = PointerInput.MouseWheelX, deviceEvent.previousState = previousWheelScrollX, deviceEvent.currentState = this._pointer[PointerInput.MouseWheelX], this.onInputChanged$.emitEvent(deviceEvent)), this._pointer[PointerInput.MouseWheelY] !== 0 && (deviceEvent.inputIndex = PointerInput.MouseWheelY, deviceEvent.previousState = previousWheelScrollY, deviceEvent.currentState = this._pointer[PointerInput.MouseWheelY], this.onInputChanged$.emitEvent(deviceEvent)), this._pointer[PointerInput.MouseWheelZ] !== 0 && (deviceEvent.inputIndex = PointerInput.MouseWheelZ, deviceEvent.previousState = previousWheelScrollZ, deviceEvent.currentState = this._pointer[PointerInput.MouseWheelZ], this.onInputChanged$.emitEvent(deviceEvent));
29425
29544
  };
29426
29545
  const canvasEle = this.getCanvasElement();
29427
29546
  canvasEle.addEventListener(`${eventPrefix}enter`, this._pointerEnterEvent), canvasEle.addEventListener(`${eventPrefix}leave`, this._pointerLeaveEvent), canvasEle.addEventListener(`${eventPrefix}move`, this._pointerMoveEvent), canvasEle.addEventListener(`${eventPrefix}down`, this._pointerDownEvent), canvasEle.addEventListener(`${eventPrefix}up`, this._pointerUpEvent), canvasEle.addEventListener(`${eventPrefix}out`, this._pointerOutEvent), canvasEle.addEventListener(`${eventPrefix}cancel`, this._pointerCancelEvent), canvasEle.addEventListener("blur", this._pointerBlurEvent), canvasEle.addEventListener(
@@ -29440,10 +29559,10 @@ const _Engine = class _Engine extends ThinEngine {
29440
29559
  deviceEvent.deviceType = deviceType, deviceEvent.currentState = 5, this.onInputChanged$.emitEvent(deviceEvent);
29441
29560
  }, this._dragOverEvent = (evt) => {
29442
29561
  evt.preventDefault();
29443
- const deviceType = this._getPointerType(evt), previousHorizontal = this.pointer[PointerInput.Horizontal], previousVertical = this.pointer[PointerInput.Vertical], previousDeltaHorizontal = this.pointer[PointerInput.DeltaHorizontal], previousDeltaVertical = this.pointer[PointerInput.DeltaVertical];
29444
- this.pointer[PointerInput.Horizontal] = evt.clientX, this.pointer[PointerInput.Vertical] = evt.clientY, this.pointer[PointerInput.DeltaHorizontal] = evt.movementX, this.pointer[PointerInput.DeltaVertical] = evt.movementY;
29562
+ const deviceType = this._getPointerType(evt), previousHorizontal = this._pointer[PointerInput.Horizontal], previousVertical = this._pointer[PointerInput.Vertical], previousDeltaHorizontal = this._pointer[PointerInput.DeltaHorizontal], previousDeltaVertical = this._pointer[PointerInput.DeltaVertical];
29563
+ this._pointer[PointerInput.Horizontal] = evt.clientX, this._pointer[PointerInput.Vertical] = evt.clientY, this._pointer[PointerInput.DeltaHorizontal] = evt.movementX, this._pointer[PointerInput.DeltaVertical] = evt.movementY;
29445
29564
  const deviceEvent = evt;
29446
- deviceEvent.deviceType = deviceType, previousHorizontal !== evt.clientX && (deviceEvent.inputIndex = PointerInput.Horizontal, deviceEvent.previousState = previousHorizontal, deviceEvent.currentState = this.pointer[PointerInput.Horizontal], this.onInputChanged$.emitEvent(deviceEvent)), previousVertical !== evt.clientY && (deviceEvent.inputIndex = PointerInput.Vertical, deviceEvent.previousState = previousVertical, deviceEvent.currentState = this.pointer[PointerInput.Vertical], this.onInputChanged$.emitEvent(deviceEvent)), this.pointer[PointerInput.DeltaHorizontal] !== 0 && (deviceEvent.inputIndex = PointerInput.DeltaHorizontal, deviceEvent.previousState = previousDeltaHorizontal, deviceEvent.currentState = this.pointer[PointerInput.DeltaHorizontal], this.onInputChanged$.emitEvent(deviceEvent)), this.pointer[PointerInput.DeltaVertical] !== 0 && (deviceEvent.inputIndex = PointerInput.DeltaVertical, deviceEvent.previousState = previousDeltaVertical, deviceEvent.currentState = this.pointer[PointerInput.DeltaVertical], this.onInputChanged$.emitEvent(deviceEvent)), !this._usingSafari && evt.button !== -1 && (deviceEvent.inputIndex = evt.button + 2, deviceEvent.previousState = this.pointer[evt.button + 2], this.pointer[evt.button + 2] = this.pointer[evt.button + 2] ? 0 : 1, deviceEvent.currentState = this.pointer[evt.button + 2], this.onInputChanged$.emitEvent(deviceEvent));
29565
+ deviceEvent.deviceType = deviceType, previousHorizontal !== evt.clientX && (deviceEvent.inputIndex = PointerInput.Horizontal, deviceEvent.previousState = previousHorizontal, deviceEvent.currentState = this._pointer[PointerInput.Horizontal], this.onInputChanged$.emitEvent(deviceEvent)), previousVertical !== evt.clientY && (deviceEvent.inputIndex = PointerInput.Vertical, deviceEvent.previousState = previousVertical, deviceEvent.currentState = this._pointer[PointerInput.Vertical], this.onInputChanged$.emitEvent(deviceEvent)), this._pointer[PointerInput.DeltaHorizontal] !== 0 && (deviceEvent.inputIndex = PointerInput.DeltaHorizontal, deviceEvent.previousState = previousDeltaHorizontal, deviceEvent.currentState = this._pointer[PointerInput.DeltaHorizontal], this.onInputChanged$.emitEvent(deviceEvent)), this._pointer[PointerInput.DeltaVertical] !== 0 && (deviceEvent.inputIndex = PointerInput.DeltaVertical, deviceEvent.previousState = previousDeltaVertical, deviceEvent.currentState = this._pointer[PointerInput.DeltaVertical], this.onInputChanged$.emitEvent(deviceEvent)), !this._usingSafari && evt.button !== -1 && (deviceEvent.inputIndex = evt.button + 2, deviceEvent.previousState = this._pointer[evt.button + 2], this._pointer[evt.button + 2] = this._pointer[evt.button + 2] ? 0 : 1, deviceEvent.currentState = this._pointer[evt.button + 2], this.onInputChanged$.emitEvent(deviceEvent));
29447
29566
  }, this._dropEvent = (evt) => {
29448
29567
  const deviceType = this._getPointerType(evt), deviceEvent = evt;
29449
29568
  deviceEvent.deviceType = deviceType, deviceEvent.currentState = 6, this.onInputChanged$.emitEvent(deviceEvent);
@@ -29684,8 +29803,8 @@ const _Layer = class _Layer extends Disposable {
29684
29803
  return this._allowCache;
29685
29804
  }
29686
29805
  /**
29687
- * get objects which is visible and not in a group.
29688
- * @returns BaseObject[]
29806
+ * Get direct visible children in order. (direct means object is not in group), default order is ascending by z-index.
29807
+ * @returns {BaseObject[]} objects
29689
29808
  */
29690
29809
  getObjectsByOrder() {
29691
29810
  const objects = [];
@@ -29694,6 +29813,10 @@ const _Layer = class _Layer extends Disposable {
29694
29813
  !o.isInGroup && o.visible && objects.push(o);
29695
29814
  return objects;
29696
29815
  }
29816
+ /**
29817
+ * Get visible and evented objects.
29818
+ * @returns {BaseObject[]} objects
29819
+ */
29697
29820
  getObjectsByOrderForPick() {
29698
29821
  const objects = [];
29699
29822
  this._objects.sort(sortRules);
@@ -29705,10 +29828,9 @@ const _Layer = class _Layer extends Disposable {
29705
29828
  return this._objects;
29706
29829
  }
29707
29830
  /**
29708
- * insert o to _objects[]
29709
- * if o is a group, insert all its children and group itself to _objects[]
29831
+ * Insert object to this._objects, if object is a group, insert all its children and group itself to _objects[]
29710
29832
  * @param o
29711
- * @returns this
29833
+ * @returns {Layer} this
29712
29834
  */
29713
29835
  addObject(o) {
29714
29836
  if (o.classType === RENDER_CLASS_TYPE.GROUP) {
@@ -29733,6 +29855,11 @@ const _Layer = class _Layer extends Disposable {
29733
29855
  return;
29734
29856
  }
29735
29857
  }
29858
+ /**
29859
+ * Insert objects to this._objects, if object is a group, insert all its children and group itself to _objects[]
29860
+ * @param objects
29861
+ * @returns {Layer} this
29862
+ */
29736
29863
  addObjects(objects) {
29737
29864
  return objects.forEach((o) => {
29738
29865
  this.addObject(o);
@@ -31320,8 +31447,10 @@ const _Scene = class _Scene extends ThinScene {
31320
31447
  scaleX !== void 0 && (this.scaleX = scaleX), scaleY !== void 0 && (this.scaleY = scaleY);
31321
31448
  }
31322
31449
  /**
31323
- * scale to value, absolute
31324
- * setTransform ---> viewport._updateScrollBarPosByViewportScroll ---> scrollTo
31450
+ * Set scale, and then emit event to update Viewport scroll state.
31451
+ * @param scaleX
31452
+ * @param scaleY
31453
+ * @returns Scene
31325
31454
  */
31326
31455
  scale(scaleX, scaleY) {
31327
31456
  const preScaleX = this.scaleX;
@@ -31353,9 +31482,7 @@ const _Scene = class _Scene extends ThinScene {
31353
31482
  }), this;
31354
31483
  }
31355
31484
  /**
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
31485
+ * Reset canvas size and update scroll
31359
31486
  * @param state
31360
31487
  */
31361
31488
  transformByState(state) {
@@ -31402,21 +31529,37 @@ const _Scene = class _Scene extends ThinScene {
31402
31529
  addLayer(...argument2) {
31403
31530
  this._layers.push(...argument2);
31404
31531
  }
31532
+ /**
31533
+ * Add objects to Layer( Layer is specfied by zIndex)
31534
+ * If object is a group, insert all its children and group itself to _objects[].
31535
+ * @param objects
31536
+ * @param zIndex
31537
+ * @returns {Scene} this
31538
+ */
31405
31539
  addObjects(objects, zIndex = 1) {
31406
31540
  var _a11;
31407
31541
  return (_a11 = this.getLayer(zIndex)) == null || _a11.addObjects(objects), this._addObject$.next(this), this;
31408
31542
  }
31543
+ /**
31544
+ * Add object to Layer (Layer is specified by zIndex).
31545
+ * If object is a group, insert all its children and group itself to _objects[].
31546
+ * @param o
31547
+ * @param zIndex layer index
31548
+ * @returns {Scene} scene
31549
+ */
31409
31550
  addObject(o, zIndex = 1) {
31410
31551
  var _a11;
31411
31552
  return (_a11 = this.getLayer(zIndex)) == null || _a11.addObject(o), this._addObject$.next(this), this;
31412
31553
  }
31413
31554
  /**
31414
- * make object parent to scene
31555
+ * Set Scene as object parent, if object has no parent.
31415
31556
  * @param o
31557
+ * @returns {void}
31416
31558
  */
31417
31559
  setObjectBehavior(o) {
31418
31560
  o.parent || (o.parent = this), o.onIsAddedToParent$.emitEvent(this);
31419
31561
  }
31562
+ // Why? return values is so strange! removeObject should return true/false, or didn't return anything.
31420
31563
  removeObject(object) {
31421
31564
  if (object == null)
31422
31565
  return;
@@ -31453,10 +31596,21 @@ const _Scene = class _Scene extends ThinScene {
31453
31596
  return objects;
31454
31597
  }
31455
31598
  /**
31456
- * get objects which is visible and not in a group in each layer.
31457
- * @returns BaseObject[]
31599
+ * Get all objects of each Layer.
31600
+ * @returns {BaseObject[]} objects
31458
31601
  */
31459
31602
  getAllObjects() {
31603
+ const objects = [];
31604
+ this._layers.sort(sortRules);
31605
+ for (const layer of this._layers)
31606
+ objects.push(...layer.getObjects());
31607
+ return objects;
31608
+ }
31609
+ /**
31610
+ * Get objects which is visible and not in a group in each layer.
31611
+ * @returns BaseObject[]
31612
+ */
31613
+ getAllObjectsByOrder() {
31460
31614
  const objects = [];
31461
31615
  this._layers.sort(sortRules);
31462
31616
  for (const layer of this._layers)
@@ -31468,13 +31622,18 @@ const _Scene = class _Scene extends ThinScene {
31468
31622
  * @param isDesc
31469
31623
  * @returns BaseObject[]
31470
31624
  */
31471
- getAllObjectsByOrder(isDesc = !1) {
31625
+ getAllObjectsByDescOrder(isDesc = !1) {
31472
31626
  const objects = [], useSortRules = isDesc ? sortRulesByDesc : sortRules;
31473
31627
  this._layers.sort(useSortRules);
31474
31628
  for (const layer of this._layers)
31475
31629
  objects.push(...layer.getObjectsByOrder().sort(useSortRules));
31476
31630
  return objects;
31477
31631
  }
31632
+ /**
31633
+ * Get visible and evented objects.
31634
+ * @param isDesc
31635
+ * @returns {BaseObject[]} objects
31636
+ */
31478
31637
  getAllObjectsByOrderForPick(isDesc = !1) {
31479
31638
  const objects = [], useSortRules = isDesc ? sortRulesByDesc : sortRules;
31480
31639
  this._layers.sort(useSortRules);
@@ -31833,11 +31992,15 @@ let RenderUnit = (_a7 = class extends Disposable {
31833
31992
  this._injector.dispose(), super.dispose();
31834
31993
  }
31835
31994
  /**
31836
- * Get render controller hold by this render unit.
31995
+ * Get a dependency from the RenderUnit's injector.
31837
31996
  */
31838
31997
  with(dependency) {
31839
31998
  return this._injector.get(dependency);
31840
31999
  }
32000
+ /**
32001
+ * Add render dependencies to the RenderUnit's injector. Note that the dependencies would be initialized immediately
32002
+ * after being added.
32003
+ */
31841
32004
  addRenderDependencies(dependencies) {
31842
32005
  this._initDependencies(dependencies);
31843
32006
  }
@@ -31846,9 +32009,13 @@ let RenderUnit = (_a7 = class extends Disposable {
31846
32009
  dependencies.forEach((dep) => {
31847
32010
  const [identifier, implOrNull] = Array.isArray(dep) ? dep : [dep, null];
31848
32011
  if (!implOrNull)
31849
- j.add([identifier, { useFactory: /* @__PURE__ */ __name(() => j.createInstance(identifier, this._renderContext), "useFactory") }]);
32012
+ j.add([identifier, {
32013
+ useFactory: /* @__PURE__ */ __name(() => j.createInstance(identifier, this._renderContext), "useFactory")
32014
+ }]);
31850
32015
  else if (isClassDependencyItem(implOrNull))
31851
- j.add([identifier, { useFactory: /* @__PURE__ */ __name(() => j.createInstance(implOrNull.useClass, this._renderContext), "useFactory") }]);
32016
+ j.add([identifier, {
32017
+ useFactory: /* @__PURE__ */ __name(() => j.createInstance(implOrNull.useClass, this._renderContext), "useFactory")
32018
+ }]);
31852
32019
  else
31853
32020
  throw new Error("[RenderUnit]: render dependency could only be an class!");
31854
32021
  }), dependencies.forEach((dep) => {
@@ -31981,7 +32148,7 @@ let RenderManagerService = (_a8 = class extends Disposable {
31981
32148
  engine,
31982
32149
  scene,
31983
32150
  isMainScene
31984
- }), this._tryAddRenderDependencies(renderUnit, ctorOfDeps);
32151
+ }), this._addRenderUnit(unitId, renderUnit), this._tryAddRenderDependencies(renderUnit, ctorOfDeps);
31985
32152
  } else
31986
32153
  renderUnit = {
31987
32154
  isThumbNail: !0,
@@ -31996,14 +32163,14 @@ let RenderManagerService = (_a8 = class extends Disposable {
31996
32163
  with(_dependency) {
31997
32164
  return null;
31998
32165
  }
31999
- };
32000
- return this._addRenderUnit(unitId, renderUnit), renderUnit;
32166
+ }, this._addRenderUnit(unitId, renderUnit);
32167
+ return renderUnit;
32001
32168
  }
32002
- addRender(unitId, item) {
32003
- this._addRenderUnit(unitId, item);
32169
+ addRender(unitId, renderUnit) {
32170
+ this._addRenderUnit(unitId, renderUnit);
32004
32171
  }
32005
- _addRenderUnit(unitId, item) {
32006
- this._renderMap.set(unitId, item);
32172
+ _addRenderUnit(unitId, renderUnit) {
32173
+ this._renderMap.set(unitId, renderUnit);
32007
32174
  }
32008
32175
  removeRender(unitId) {
32009
32176
  const item = this._renderMap.get(unitId);
@@ -32320,10 +32487,6 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32320
32487
  disable() {
32321
32488
  this._active = !1;
32322
32489
  }
32323
- /**
32324
- * invoked when canvas element size change
32325
- * engineResizeObserver --> engine.resizeBySize --> scene._setTransForm
32326
- */
32327
32490
  resetCanvasSizeAndUpdateScroll() {
32328
32491
  this._resizeCacheCanvas(), this._updateScrollByViewportScrollValue();
32329
32492
  }
@@ -32359,33 +32522,18 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32359
32522
  });
32360
32523
  }
32361
32524
  /**
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
- *
32525
+ * ScrollBar scroll to certain position.
32526
+ * @param pos position of scrollBar
32388
32527
  */
32528
+ // There are serval cases to call this method.
32529
+ // the most common case is scrolling. Other situations include:
32530
+ // 1. changing the frozen row & col settings
32531
+ // 2. changing curr skeleton
32532
+ // 3. changing selection which cross viewport
32533
+ // 4. changing the viewport size (also include change window size)
32534
+ // 5. changing the scroll bar position
32535
+ // Debug
32536
+ // window.scene.getViewports()[0].scrollTo({x: 14.2, y: 1.8}, true)
32389
32537
  scrollToBarPos(pos) {
32390
32538
  return this._scrollToBarPosCore(pos);
32391
32539
  }
@@ -32416,6 +32564,12 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32416
32564
  isTrigger
32417
32565
  });
32418
32566
  }
32567
+ /**
32568
+ * Viewport scroll to certain position.
32569
+ * @param pos
32570
+ * @param isTrigger
32571
+ * @returns IViewportScrollPosition
32572
+ */
32419
32573
  scrollToViewportPos(pos, isTrigger = !0) {
32420
32574
  if (!this._scrollBar || this.isActive === !1)
32421
32575
  return;
@@ -32477,8 +32631,11 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32477
32631
  getScrollBar() {
32478
32632
  return this._scrollBar;
32479
32633
  }
32480
- // scrollTo ---> _scroll ---> onScrollAfter$.next ---> scroll.render-controller@updateScroll
32481
- // scrollTo ---> _scroll ---> onScrollAfter$.next ---> freeze.render-controller@updateScroll
32634
+ /**
32635
+ * Just record state of scroll. This method won't scroll viewport and scrollbar.
32636
+ * @param current
32637
+ * @returns Viewport
32638
+ */
32482
32639
  updateScrollVal(current) {
32483
32640
  this._preScrollX = this.scrollX, this._preScrollY = this.scrollY;
32484
32641
  const { scrollX, scrollY, viewportScrollX, viewportScrollY } = current;
@@ -32492,8 +32649,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32492
32649
  return !(this.isActive === !1 || this.width == null || this.height == null || this.width <= 1 || this.height <= 1);
32493
32650
  }
32494
32651
  /**
32495
- * call stack: engine.renderLoop ---> scene.render ---> layer.render ---> viewport.render
32496
- * that means each layer call all viewports to render
32652
+ * Render function in each render loop.
32497
32653
  * @param parentCtx parentCtx is cacheCtx from layer when layer._allowCache is true
32498
32654
  * @param objects
32499
32655
  * @param isMaxLayer
@@ -32740,7 +32896,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32740
32896
  (_a11 = this._cacheCanvas) == null || _a11.setSize(canvasW, canvasH), this.cacheBound = this._viewBound, this.preCacheBound = null, this.markForceDirty(!0);
32741
32897
  }
32742
32898
  /**
32743
- * This method will be invoked when viewport is resizing and removing rol & col
32899
+ * Update scroll when viewport is resizing and removing rol & col
32744
32900
  */
32745
32901
  _updateScrollByViewportScrollValue() {
32746
32902
  if (!this.width || this.width < 0 || !this.height || this.height < 0) return;
@@ -33187,7 +33343,14 @@ function isInSameTableCell(anchorNodePosition, focusNodePosition) {
33187
33343
  }
33188
33344
  __name(isInSameTableCell, "isInSameTableCell");
33189
33345
  function compareNodePositionInTable(a, b) {
33190
- const { path: aPath } = a, { path: bPath } = b, aRowCount = aPath[aPath.length - 3], bRowCount = bPath[bPath.length - 3], aCellCount = aPath[aPath.length - 1], bCellCount = bPath[bPath.length - 1];
33346
+ if (isInSameTableCell(a, b))
33347
+ return compareNodePositionLogic(a, b);
33348
+ const { path: aPath } = a, { path: bPath } = b, aTableId = aPath[aPath.length - 5], bTableId = bPath[bPath.length - 5];
33349
+ if (aTableId !== bTableId && typeof aTableId == "string" && typeof bTableId == "string") {
33350
+ const aSlideId = aTableId.split("#-#")[1], bSlideId = bTableId.split("#-#")[1];
33351
+ return +aSlideId < +bSlideId;
33352
+ }
33353
+ const aRowCount = aPath[aPath.length - 3], bRowCount = bPath[bPath.length - 3], aCellCount = aPath[aPath.length - 1], bCellCount = bPath[bPath.length - 1];
33191
33354
  return aRowCount < bRowCount ? !0 : aRowCount > bRowCount ? !1 : aCellCount <= bCellCount;
33192
33355
  }
33193
33356
  __name(compareNodePositionInTable, "compareNodePositionInTable");
@@ -33553,13 +33716,13 @@ function getRangeListFromSelection(anchorPosition, focusPosition, scene, documen
33553
33716
  tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, !0, segmentId, segmentPage), tableEndPosition = skeleton.findNodePositionByCharIndex(endRow.endIndex - 3, !0, segmentId, segmentPage), end = tableStart - 1, endInTable = !0;
33554
33717
  else if (tableStart > startOffset && tableEnd < endOffset) {
33555
33718
  if (tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, !0, segmentId, segmentPage), tableEndPosition = skeleton.findNodePositionByCharIndex(tableEnd - 4, !0, segmentId, segmentPage), start <= tableStart - 1) {
33556
- const sp = skeleton.findNodePositionByCharIndex(start, !0, segmentId, segmentPage), ep = skeleton.findNodePositionByCharIndex(tableStart - 1, !1, segmentId, segmentPage), ap = direction ? sp : ep, fp = direction ? ep : sp;
33719
+ const sp = skeleton.findNodePositionByCharIndex(start, !0, segmentId, segmentPage), ep = skeleton.findNodePositionByCharIndex(tableStart - 1, !1, segmentId, segmentPage), ap = direction === RANGE_DIRECTION.FORWARD ? sp : ep, fp = direction === RANGE_DIRECTION.FORWARD ? ep : sp;
33557
33720
  textRanges.push(new TextRange(scene, document2, skeleton, ap, fp, style, segmentId));
33558
33721
  }
33559
33722
  start = tableEnd + 1;
33560
33723
  }
33561
33724
  if (tableStartPosition && tableEndPosition) {
33562
- const ap = direction ? tableStartPosition : tableEndPosition, fp = direction ? tableEndPosition : tableStartPosition;
33725
+ const ap = direction === RANGE_DIRECTION.FORWARD ? tableStartPosition : tableEndPosition, fp = direction === RANGE_DIRECTION.FORWARD ? tableEndPosition : tableStartPosition;
33563
33726
  rectRanges.push(...convertPositionsToRectRanges(
33564
33727
  scene,
33565
33728
  document2,
@@ -33572,7 +33735,7 @@ function getRangeListFromSelection(anchorPosition, focusPosition, scene, documen
33572
33735
  }
33573
33736
  }
33574
33737
  if (end >= startIndex && end <= endIndex || endInTable) {
33575
- const sp = skeleton.findNodePositionByCharIndex(start, !0, segmentId, segmentPage), ep = skeleton.findNodePositionByCharIndex(end, !endInTable, segmentId, segmentPage), ap = direction ? sp : ep, fp = direction ? ep : sp;
33738
+ const sp = skeleton.findNodePositionByCharIndex(start, !0, segmentId, segmentPage), ep = skeleton.findNodePositionByCharIndex(end, !endInTable, segmentId, segmentPage), ap = direction === RANGE_DIRECTION.FORWARD ? sp : ep, fp = direction === RANGE_DIRECTION.FORWARD ? ep : sp;
33576
33739
  if (rectRanges.length && Tools.diffValue(ap, fp))
33577
33740
  continue;
33578
33741
  textRanges.push(new TextRange(scene, document2, skeleton, ap, fp, style, segmentId));
@@ -33772,7 +33935,7 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
33772
33935
  }), this._updateInputPosition();
33773
33936
  }
33774
33937
  setCursorManually(evtOffsetX, evtOffsetY) {
33775
- const startNode = this.findNodeByCoord(evtOffsetX, evtOffsetY, {
33938
+ const startNode = this._findNodeByCoord(evtOffsetX, evtOffsetY, {
33776
33939
  strict: !0,
33777
33940
  segmentId: this._currentSegmentId,
33778
33941
  segmentPage: this._currentSegmentPage
@@ -33781,7 +33944,7 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
33781
33944
  this._removeAllRanges();
33782
33945
  return;
33783
33946
  }
33784
- (startNode == null ? void 0 : startNode.node.streamType) === DataStreamTreeTokenType.PARAGRAPH && (position.isBack = !0), this._updateTextRangeAnchorPosition(position), this._activeSelectionRefresh(), this._textSelectionInner$.next({
33947
+ (startNode == null ? void 0 : startNode.node.streamType) === DataStreamTreeTokenType.PARAGRAPH && (position.isBack = !0), this._createTextRangeByAnchorPosition(position), this._textSelectionInner$.next({
33785
33948
  textRanges: this._getAllTextRanges(),
33786
33949
  rectRanges: this._getAllRectRanges(),
33787
33950
  segmentId: this._currentSegmentId,
@@ -33823,7 +33986,7 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
33823
33986
  handleDblClick(evt) {
33824
33987
  if (!this._scene || !this._isSelectionEnabled)
33825
33988
  return;
33826
- const { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, startNode = this.findNodeByCoord(evtOffsetX, evtOffsetY, {
33989
+ const { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, startNode = this._findNodeByCoord(evtOffsetX, evtOffsetY, {
33827
33990
  strict: !1,
33828
33991
  segmentId: this._currentSegmentId,
33829
33992
  segmentPage: this._currentSegmentPage
@@ -33857,7 +34020,7 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
33857
34020
  handleTripleClick(evt) {
33858
34021
  if (!this._scene || !this._isSelectionEnabled)
33859
34022
  return;
33860
- const { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, startNode = this.findNodeByCoord(evtOffsetX, evtOffsetY, {
34023
+ const { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, startNode = this._findNodeByCoord(evtOffsetX, evtOffsetY, {
33861
34024
  strict: !1,
33862
34025
  segmentId: this._currentSegmentId,
33863
34026
  segmentPage: this._currentSegmentPage
@@ -33883,7 +34046,7 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
33883
34046
  if (!this._scene || !this._isSelectionEnabled)
33884
34047
  return;
33885
34048
  this._editorFocusing = !0;
33886
- const scene = this._scene, { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, startNode = this.findNodeByCoord(evtOffsetX, evtOffsetY, {
34049
+ const scene = this._scene, { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt, startNode = this._findNodeByCoord(evtOffsetX, evtOffsetY, {
33887
34050
  strict: !1,
33888
34051
  segmentId: this._currentSegmentId,
33889
34052
  segmentPage: this._currentSegmentPage
@@ -34075,11 +34238,12 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
34075
34238
  _addRectRanges(rectRanges) {
34076
34239
  rectRanges.length !== 0 && (this._deactivateAllRectRanges(), rectRanges[rectRanges.length - 1].activate(), this._rectRangeList.push(...rectRanges));
34077
34240
  }
34078
- _updateTextRangeAnchorPosition(position) {
34241
+ _createTextRangeByAnchorPosition(position) {
34079
34242
  if (!this._scene)
34080
34243
  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];
34244
+ this._removeAllRanges();
34245
+ const lastRange = new TextRange(this._scene, this._document, this._docSkeleton, position, void 0, this._selectionStyle, this._currentSegmentId);
34246
+ this._addTextRange(lastRange);
34083
34247
  }
34084
34248
  _updateActiveRangePosition(position) {
34085
34249
  if (!this._scene) {
@@ -34134,7 +34298,7 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
34134
34298
  var _a11, _b;
34135
34299
  if (this._docSkeleton == null)
34136
34300
  return;
34137
- const focusNode = this.findNodeByCoord(moveOffsetX, moveOffsetY, {
34301
+ const focusNode = this._findNodeByCoord(moveOffsetX, moveOffsetY, {
34138
34302
  strict: !0,
34139
34303
  segmentId: this._currentSegmentId,
34140
34304
  segmentPage: this._currentSegmentPage
@@ -34274,7 +34438,7 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
34274
34438
  if (originCoord)
34275
34439
  return documentTransform.clone().invert().applyPoint(originCoord);
34276
34440
  }
34277
- findNodeByCoord(evtOffsetX, evtOffsetY, restrictions) {
34441
+ _findNodeByCoord(evtOffsetX, evtOffsetY, restrictions) {
34278
34442
  var _a11;
34279
34443
  const coord = this._getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY);
34280
34444
  if (coord == null)
@@ -34292,18 +34456,9 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
34292
34456
  restrictions
34293
34457
  );
34294
34458
  }
34295
- _getNodeIndex(node) {
34296
- return node.node.parent.st + node.node.parent.glyphGroup.indexOf(node.node);
34297
- }
34298
34459
  _detachEvent() {
34299
34460
  this._onInputBefore$.complete(), this._onKeydown$.complete(), this._onInput$.complete(), this._onCompositionstart$.complete(), this._onCompositionupdate$.complete(), this._onCompositionend$.complete(), this._onSelectionStart$.complete();
34300
34461
  }
34301
- _activeSelectionRefresh() {
34302
- if (this._docSkeleton == null)
34303
- return;
34304
- const activeRangeInstance = this._getActiveRangeInstance();
34305
- activeRangeInstance == null || activeRangeInstance.refresh();
34306
- }
34307
34462
  }, __name(_a10, "TextSelectionRenderManager"), _a10);
34308
34463
  TextSelectionRenderManager = __decorateClass([
34309
34464
  __decorateParam(0, ILogService)