@univerjs/engine-render 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/lib/cjs/index.js +4 -2
  2. package/lib/es/index.js +339 -189
  3. package/lib/types/base-object.d.ts +4 -3
  4. package/lib/types/basics/cell-data.d.ts +0 -1
  5. package/lib/types/basics/document-node-tools.d.ts +0 -1
  6. package/lib/types/basics/draw.d.ts +0 -1
  7. package/lib/types/basics/group-transform.d.ts +0 -1
  8. package/lib/types/basics/i-document-skeleton-cached.d.ts +0 -1
  9. package/lib/types/basics/i-events.d.ts +0 -1
  10. package/lib/types/basics/interfaces.d.ts +0 -1
  11. package/lib/types/basics/offset-rotation-axis.d.ts +0 -1
  12. package/lib/types/basics/path2.d.ts +0 -1
  13. package/lib/types/basics/position.d.ts +0 -1
  14. package/lib/types/basics/quick-event.d.ts +0 -1
  15. package/lib/types/basics/range.d.ts +0 -1
  16. package/lib/types/basics/text-rotation.d.ts +0 -1
  17. package/lib/types/basics/tools.d.ts +0 -1
  18. package/lib/types/basics/transform.d.ts +0 -1
  19. package/lib/types/basics/transformer-config.d.ts +0 -1
  20. package/lib/types/basics/vector2.d.ts +0 -1
  21. package/lib/types/basics/viewport-subtract.d.ts +0 -1
  22. package/lib/types/canvas.d.ts +0 -1
  23. package/lib/types/components/component.d.ts +0 -1
  24. package/lib/types/components/docs/doc-background.d.ts +0 -1
  25. package/lib/types/components/docs/doc-component.d.ts +0 -1
  26. package/lib/types/components/docs/doc-extension.d.ts +0 -1
  27. package/lib/types/components/docs/document.d.ts +1 -3
  28. package/lib/types/components/docs/extensions/background.d.ts +0 -1
  29. package/lib/types/components/docs/extensions/border.d.ts +0 -1
  30. package/lib/types/components/docs/extensions/font-and-base-line.d.ts +0 -1
  31. package/lib/types/components/docs/extensions/line.d.ts +0 -1
  32. package/lib/types/components/docs/layout/block/paragraph/bullet-ruler.d.ts +0 -1
  33. package/lib/types/components/docs/layout/block/paragraph/bullet.d.ts +0 -1
  34. package/lib/types/components/docs/layout/block/paragraph/language-ruler.d.ts +5 -6
  35. package/lib/types/components/docs/layout/block/paragraph/layout-ruler.d.ts +1 -2
  36. package/lib/types/components/docs/layout/block/paragraph/line-adjustment.d.ts +0 -1
  37. package/lib/types/components/docs/layout/block/paragraph/linebreaking.d.ts +0 -1
  38. package/lib/types/components/docs/layout/block/paragraph/paragraph-layout.d.ts +0 -1
  39. package/lib/types/components/docs/layout/block/paragraph/shaping.d.ts +0 -1
  40. package/lib/types/components/docs/layout/block/section.d.ts +0 -1
  41. package/lib/types/components/docs/layout/block/table.d.ts +0 -1
  42. package/lib/types/components/docs/layout/doc-skeleton.d.ts +2 -1
  43. package/lib/types/components/docs/layout/hyphenation/hyphen.d.ts +0 -1
  44. package/lib/types/components/docs/layout/hyphenation/language-detector.d.ts +0 -1
  45. package/lib/types/components/docs/layout/line-breaker/enhancers/hyphen-enhancer.d.ts +0 -1
  46. package/lib/types/components/docs/layout/line-breaker/extensions/custom-block-linebreak-extension.d.ts +0 -1
  47. package/lib/types/components/docs/layout/line-breaker/extensions/tab-linebreak-extension.d.ts +0 -1
  48. package/lib/types/components/docs/layout/line-breaker/line-breaker.d.ts +0 -1
  49. package/lib/types/components/docs/layout/line-breaker/rule.d.ts +0 -1
  50. package/lib/types/components/docs/layout/model/column.d.ts +0 -1
  51. package/lib/types/components/docs/layout/model/glyph.d.ts +0 -1
  52. package/lib/types/components/docs/layout/model/line.d.ts +0 -1
  53. package/lib/types/components/docs/layout/model/page.d.ts +0 -1
  54. package/lib/types/components/docs/layout/model/section.d.ts +0 -1
  55. package/lib/types/components/docs/layout/shaping-engine/font-cache.d.ts +0 -1
  56. package/lib/types/components/docs/layout/shaping-engine/font-library.d.ts +0 -1
  57. package/lib/types/components/docs/layout/shaping-engine/text-shaping.d.ts +0 -1
  58. package/lib/types/components/docs/layout/shaping-engine/utils.d.ts +0 -1
  59. package/lib/types/components/docs/layout/style/custom-decoration.d.ts +0 -1
  60. package/lib/types/components/docs/layout/style/custom-range.d.ts +0 -1
  61. package/lib/types/components/docs/layout/tools.d.ts +2 -3
  62. package/lib/types/components/docs/liquid.d.ts +1 -2
  63. package/lib/types/components/docs/text-selection/convert-rect-range.d.ts +0 -1
  64. package/lib/types/components/docs/text-selection/convert-text-range.d.ts +0 -1
  65. package/lib/types/components/docs/text-selection/range-interface.d.ts +0 -1
  66. package/lib/types/components/docs/text-selection/rect-range.d.ts +0 -1
  67. package/lib/types/components/docs/text-selection/selection-utils.d.ts +0 -1
  68. package/lib/types/components/docs/text-selection/text-range.d.ts +0 -1
  69. package/lib/types/components/docs/text-selection/text-selection-render-manager.d.ts +1 -2
  70. package/lib/types/components/docs/view-model/data-stream-tree-node.d.ts +0 -1
  71. package/lib/types/components/docs/view-model/document-view-model.d.ts +2 -1
  72. package/lib/types/components/extension.d.ts +0 -1
  73. package/lib/types/components/sheets/column-header.d.ts +0 -1
  74. package/lib/types/components/sheets/extensions/background.d.ts +0 -1
  75. package/lib/types/components/sheets/extensions/border.d.ts +0 -1
  76. package/lib/types/components/sheets/extensions/column-header-layout.d.ts +0 -1
  77. package/lib/types/components/sheets/extensions/custom.d.ts +0 -1
  78. package/lib/types/components/sheets/extensions/font.d.ts +0 -1
  79. package/lib/types/components/sheets/extensions/marker.d.ts +0 -1
  80. package/lib/types/components/sheets/extensions/row-header-layout.d.ts +0 -1
  81. package/lib/types/components/sheets/extensions/sheet-extension.d.ts +0 -1
  82. package/lib/types/components/sheets/interfaces.d.ts +0 -1
  83. package/lib/types/components/sheets/row-header.d.ts +0 -1
  84. package/lib/types/components/sheets/sheet-component.d.ts +0 -1
  85. package/lib/types/components/sheets/sheet-skeleton.d.ts +10 -2
  86. package/lib/types/components/sheets/spreadsheet.d.ts +0 -3
  87. package/lib/types/components/skeleton.d.ts +0 -1
  88. package/lib/types/components/slides/slide.d.ts +6 -2
  89. package/lib/types/custom/custom-object.d.ts +0 -1
  90. package/lib/types/engine.d.ts +0 -1
  91. package/lib/types/floating/util.d.ts +0 -1
  92. package/lib/types/group.d.ts +0 -1
  93. package/lib/types/layer.d.ts +0 -1
  94. package/lib/types/render-engine.d.ts +0 -1
  95. package/lib/types/render-manager/render-manager.service.d.ts +44 -3
  96. package/lib/types/render-manager/render-unit.d.ts +17 -4
  97. package/lib/types/scene-viewer.d.ts +0 -1
  98. package/lib/types/scene.d.ts +17 -7
  99. package/lib/types/scene.input-manager.d.ts +0 -1
  100. package/lib/types/scene.transformer.d.ts +0 -1
  101. package/lib/types/scroll-timer.d.ts +0 -1
  102. package/lib/types/shape/base-scroll-bar.d.ts +0 -1
  103. package/lib/types/shape/checkbox.d.ts +0 -1
  104. package/lib/types/shape/circle.d.ts +0 -1
  105. package/lib/types/shape/dashedrect.d.ts +0 -1
  106. package/lib/types/shape/dropdown-item.d.ts +0 -1
  107. package/lib/types/shape/image.d.ts +0 -1
  108. package/lib/types/shape/path.d.ts +0 -1
  109. package/lib/types/shape/rect.d.ts +0 -1
  110. package/lib/types/shape/regular-polygon.d.ts +0 -1
  111. package/lib/types/shape/rich-text.d.ts +3 -7
  112. package/lib/types/shape/scroll-bar.d.ts +0 -1
  113. package/lib/types/shape/shape.d.ts +0 -1
  114. package/lib/types/shape/text.d.ts +0 -1
  115. package/lib/types/thin-engine.d.ts +0 -1
  116. package/lib/types/thin-scene.d.ts +0 -1
  117. package/lib/types/viewport.d.ts +15 -34
  118. package/lib/umd/index.js +4 -2
  119. package/package.json +7 -7
package/lib/es/index.js CHANGED
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
5
  import { Tools, DEFAULT_STYLES, FontStyleType, BaselineOffset, getCellInfoInMergeData, Rectangle, ColorKit, Disposable, EventSubject, checkParagraphHasIndentByStyle, DataStreamTreeTokenType, BorderStyleTypes, BooleanNumber, DisposableCollection, toDisposable, sortRules, Registry, numberToABC, CustomDecorationType, CustomRangeType, PositionedObjectLayoutType, WrapTextType, TableAlignmentType, GridType, BulletAlignment, ColumnSeparatorType, GlyphType as GlyphType$1, numberToListABC, HorizontalAlign, DataStreamTreeNodeType, PageOrientType, ObjectRelativeFromV, TableTextWrapType, SpacingRule, ObjectMatrix, SectionType, NumberUnitType, VerticalAlign, WrapStrategy, AlignTypeH, ObjectRelativeFromH, AlignTypeV, Inject, LocaleService, insertTextToContent, horizontalLineSegmentsSubtraction, deleteContent, DocumentDataModel, PRESET_LIST_TYPE, searchArray, extractPureTextFromCell, CellValueType, isCellCoverable, isNullCell, getColorStyle, isWhiteColor, IContextService, DEFAULT_EMPTY_DOCUMENT_VALUE, Range, TextDecoration, COLORS, requestImmediateMacroTask, MOVE_BUFFER_VALUE, sortRulesByDesc, Injector, isClassDependencyItem, createIdentifier, remove, UniverInstanceType, IUniverInstanceService, Plugin, RxDisposable, ILogService, DocumentFlavor } from "@univerjs/core";
6
- import { BehaviorSubject, startWith, distinctUntilChanged, Subscription, Subject, Observable, shareReplay, fromEvent } from "rxjs";
6
+ import { BehaviorSubject, Subject, startWith, distinctUntilChanged, Subscription, Observable, shareReplay, fromEvent } from "rxjs";
7
7
  var SHAPE_TYPE = /* @__PURE__ */ ((SHAPE_TYPE2) => (SHAPE_TYPE2.RECT = "rect", SHAPE_TYPE2.CIRCLE = "circle", SHAPE_TYPE2.PATH = "path", SHAPE_TYPE2))(SHAPE_TYPE || {}), LINK_VIEW_PORT_TYPE = /* @__PURE__ */ ((LINK_VIEW_PORT_TYPE2) => (LINK_VIEW_PORT_TYPE2[LINK_VIEW_PORT_TYPE2.XY = 0] = "XY", LINK_VIEW_PORT_TYPE2[LINK_VIEW_PORT_TYPE2.X = 1] = "X", LINK_VIEW_PORT_TYPE2[LINK_VIEW_PORT_TYPE2.Y = 2] = "Y", LINK_VIEW_PORT_TYPE2))(LINK_VIEW_PORT_TYPE || {});
8
8
  const MIDDLE_CELL_POS_MAGIC_NUMBER = 1, DEFAULT_FONTFACE_PLANE = '"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif', DEFAULT_SKELETON_HEADER_FOOTER = {
9
9
  lines: [],
@@ -2980,14 +2980,14 @@ const _BaseObject = class _BaseObject extends Disposable {
2980
2980
  }
2981
2981
  getScene() {
2982
2982
  let parent = this.parent;
2983
- if (parent != null) {
2983
+ if (parent == null)
2984
+ return null;
2985
+ if (parent.classType === RENDER_CLASS_TYPE.SCENE)
2986
+ return parent;
2987
+ for (; parent; ) {
2984
2988
  if (parent.classType === RENDER_CLASS_TYPE.SCENE)
2985
2989
  return parent;
2986
- for (; parent; ) {
2987
- if (parent.classType === RENDER_CLASS_TYPE.SCENE)
2988
- return parent;
2989
- parent = parent.getParent();
2990
- }
2990
+ parent = parent.getParent();
2991
2991
  }
2992
2992
  }
2993
2993
  resetCursor() {
@@ -20137,14 +20137,14 @@ function customBlockLineBreakExtension(breaker) {
20137
20137
  breaker.addRule("break_before_and_after_slash_b", (codePoint, lastCodePoint) => codePoint === SLASH_B_CODE_POINT || lastCodePoint === SLASH_B_CODE_POINT);
20138
20138
  }
20139
20139
  __name(customBlockLineBreakExtension, "customBlockLineBreakExtension");
20140
- function otherHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20140
+ function otherHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20141
20141
  const glyphGroup = [];
20142
20142
  let step = 0;
20143
20143
  for (let i = 0; i < charArray.length; i++) {
20144
20144
  const newChar = charArray[i];
20145
20145
  if (hasSpace(newChar) || startWithEmoji(charArray.substring(i)))
20146
20146
  break;
20147
- const config = getFontCreateConfig(index2 + i, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), glyph = createSkeletonLetterGlyph(newChar, config);
20147
+ const config = getFontCreateConfig(index2 + i, viewModel, paragraphNode, sectionBreakConfig, paragraph), glyph = createSkeletonLetterGlyph(newChar, config);
20148
20148
  glyphGroup.push(glyph), step++;
20149
20149
  }
20150
20150
  return {
@@ -20153,8 +20153,8 @@ function otherHandler(index2, charArray, viewModel, paragraphNode, sectionBreakC
20153
20153
  };
20154
20154
  }
20155
20155
  __name(otherHandler, "otherHandler");
20156
- function ArabicHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20157
- const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), glyph = [];
20156
+ function ArabicHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20157
+ const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph), glyph = [];
20158
20158
  let step = 0;
20159
20159
  for (let i = 0; i < charArray.length; i++) {
20160
20160
  const newChar = charArray[i];
@@ -20169,16 +20169,16 @@ function ArabicHandler(index2, charArray, viewModel, paragraphNode, sectionBreak
20169
20169
  };
20170
20170
  }
20171
20171
  __name(ArabicHandler, "ArabicHandler");
20172
- function emojiHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20173
- const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), match = charArray.match(EMOJI_REG);
20172
+ function emojiHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20173
+ const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph), match = charArray.match(EMOJI_REG);
20174
20174
  return {
20175
20175
  step: match[0].length,
20176
20176
  glyphGroup: [createSkeletonLetterGlyph(match[0], config)]
20177
20177
  };
20178
20178
  }
20179
20179
  __name(emojiHandler, "emojiHandler");
20180
- function TibetanHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
20181
- const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle), glyph = [];
20180
+ function TibetanHandler(index2, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
20181
+ const config = getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph), glyph = [];
20182
20182
  let step = 0;
20183
20183
  for (let i = 0; i < charArray.length; i++) {
20184
20184
  const newChar = charArray[i];
@@ -20228,7 +20228,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20228
20228
  drawings = {}
20229
20229
  } = sectionBreakConfig, shapedTextList = [];
20230
20230
  let breaker = new LineBreaker(content);
20231
- const { endIndex } = paragraphNode, { paragraphStyle = {} } = viewModel.getParagraph(endIndex) || { startIndex: 0 }, { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
20231
+ const { endIndex } = paragraphNode, paragraph = viewModel.getParagraph(endIndex) || { startIndex: 0 }, { paragraphStyle = {} } = paragraph, { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
20232
20232
  let last = 0, bk, lastGlyphIndex = 0;
20233
20233
  const { hyphen, languageDetector } = ctx, paragraphBody = prepareParagraphBody(viewModel.getBody(), endIndex);
20234
20234
  let glyphInfos = [];
@@ -20247,7 +20247,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20247
20247
  }
20248
20248
  lastGlyphIndex = i;
20249
20249
  for (const glyphInfo of glyphInfosInWord) {
20250
- const { start, char } = glyphInfo, config = getFontCreateConfig(start, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
20250
+ const { start, char } = glyphInfo, config = getFontCreateConfig(start, viewModel, paragraphNode, sectionBreakConfig, paragraph);
20251
20251
  if (char === DataStreamTreeTokenType.TAB) {
20252
20252
  const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid), newSpan = createSkeletonTabGlyph(config, charSpaceApply);
20253
20253
  shapedGlyphs.push(newSpan);
@@ -20266,7 +20266,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20266
20266
  if (char == null)
20267
20267
  break;
20268
20268
  if (char === DataStreamTreeTokenType.CUSTOM_BLOCK) {
20269
- const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
20269
+ const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
20270
20270
  let newGlyph = null;
20271
20271
  const customBlock = viewModel.getCustomBlockWithoutSetCurrentIndex(paragraphNode.startIndex + i);
20272
20272
  if (customBlock != null) {
@@ -20279,7 +20279,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20279
20279
  }
20280
20280
  newGlyph == null && (newGlyph = createSkeletonLetterGlyph(char, config)), shapedGlyphs.push(newGlyph), i += char.length, src = src.substring(char.length);
20281
20281
  } else if (/\s/.test(char) || hasCJK(char)) {
20282
- const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
20282
+ const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
20283
20283
  let newGlyph = null;
20284
20284
  if (char === DataStreamTreeTokenType.TAB) {
20285
20285
  const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
@@ -20294,7 +20294,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20294
20294
  viewModel,
20295
20295
  paragraphNode,
20296
20296
  sectionBreakConfig,
20297
- paragraphStyle
20297
+ paragraph
20298
20298
  );
20299
20299
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20300
20300
  } else if (hasArabic(char)) {
@@ -20304,7 +20304,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20304
20304
  viewModel,
20305
20305
  paragraphNode,
20306
20306
  sectionBreakConfig,
20307
- paragraphStyle
20307
+ paragraph
20308
20308
  );
20309
20309
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20310
20310
  } else if (hasTibetan(char)) {
@@ -20314,7 +20314,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20314
20314
  viewModel,
20315
20315
  paragraphNode,
20316
20316
  sectionBreakConfig,
20317
- paragraphStyle
20317
+ paragraph
20318
20318
  );
20319
20319
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20320
20320
  } else {
@@ -20324,7 +20324,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
20324
20324
  viewModel,
20325
20325
  paragraphNode,
20326
20326
  sectionBreakConfig,
20327
- paragraphStyle
20327
+ paragraph
20328
20328
  );
20329
20329
  shapedGlyphs.push(...glyphGroup), i += step, src = src.substring(step);
20330
20330
  }
@@ -20651,8 +20651,8 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
20651
20651
  const { blockId } = customBlock, drawingOrigin = drawings[blockId];
20652
20652
  drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE ? paragraphInlineSkeDrawings.set(blockId, _getDrawingSkeletonFormat(drawingOrigin)) : paragraphAffectSkeDrawings.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
20653
20653
  }
20654
- let allPages = [curPage], paragraphStart = !0;
20655
- for (const { text, glyphs, breakPointType } of shapedTextList) {
20654
+ let allPages = [curPage], isParagraphFirstShapedText = !0;
20655
+ for (const [_index, { text, glyphs, breakPointType }] of shapedTextList.entries()) {
20656
20656
  const pushPending = /* @__PURE__ */ __name(() => {
20657
20657
  glyphs.length !== 0 && (allPages = layoutParagraph(
20658
20658
  ctx,
@@ -20660,9 +20660,9 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
20660
20660
  allPages,
20661
20661
  sectionBreakConfig,
20662
20662
  paragraphConfig,
20663
- paragraphStart,
20663
+ isParagraphFirstShapedText,
20664
20664
  breakPointType
20665
- ), paragraphStart = !1);
20665
+ ), isParagraphFirstShapedText = !1);
20666
20666
  }, "pushPending");
20667
20667
  if (text.endsWith(DataStreamTreeTokenType.PAGE_BREAK)) {
20668
20668
  pushPending(), allPages.push(
@@ -21121,17 +21121,17 @@ function _getVerticalMargin(marginTB, headerOrFooter, pageHeight) {
21121
21121
  return Math.min(maxMargin, Math.max(marginTB, HeaderFooterPageHeight));
21122
21122
  }
21123
21123
  __name(_getVerticalMargin, "_getVerticalMargin");
21124
- function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal) {
21125
- if (paragraphStart)
21124
+ function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal) {
21125
+ if (isParagraphFirstShapedText)
21126
21126
  if (paragraphConfig.bulletSkeleton) {
21127
21127
  const { bulletSkeleton, paragraphStyle = {} } = paragraphConfig, { gridType = GridType.LINES, charSpace = 0, defaultTabStop = 10.5 } = sectionBreakConfig, paragraphProperties = bulletSkeleton.paragraphProperties || {};
21128
21128
  paragraphConfig.paragraphStyle = mergeByV(paragraphConfig.paragraphStyle, paragraphProperties);
21129
21129
  const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle, charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid), bulletGlyph = createSkeletonBulletGlyph(glyphGroup[0], bulletSkeleton, charSpaceApply);
21130
- _lineOperator(ctx, [bulletGlyph, ...glyphGroup], pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21130
+ _lineOperator(ctx, [bulletGlyph, ...glyphGroup], pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
21131
21131
  } else
21132
- _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21132
+ _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
21133
21133
  else
21134
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21134
+ _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
21135
21135
  return [...pages];
21136
21136
  }
21137
21137
  __name(layoutParagraph, "layoutParagraph");
@@ -21184,7 +21184,7 @@ function _popHyphenSlice(divide) {
21184
21184
  return divide.glyphGroup.length === 0 && (divide.glyphGroup.push(...glyphGroup), glyphGroup.length = 0), glyphGroup;
21185
21185
  }
21186
21186
  __name(_popHyphenSlice, "_popHyphenSlice");
21187
- function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21187
+ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21188
21188
  var _a11;
21189
21189
  const lastPage = getLastPage(pages), divideInfo = getLastNotFullDivideInfo(lastPage);
21190
21190
  if (divideInfo) {
@@ -21222,13 +21222,13 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21222
21222
  const hyphenSliceGlyphGroup = _popHyphenSlice(divide);
21223
21223
  hyphenSliceGlyphGroup.length > 0 && (updateDivideInfo(divide, {
21224
21224
  breakType: BreakPointType.Normal
21225
- }), _divideOperator(ctx, hyphenSliceGlyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, BreakPointType.Hyphen)), _divideOperator(
21225
+ }), _divideOperator(ctx, hyphenSliceGlyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, BreakPointType.Hyphen)), _divideOperator(
21226
21226
  ctx,
21227
21227
  glyphGroup,
21228
21228
  pages,
21229
21229
  sectionBreakConfig,
21230
21230
  paragraphConfig,
21231
- paragraphStart,
21231
+ isParagraphFirstShapedText,
21232
21232
  breakPointType,
21233
21233
  defaultSpanLineHeight
21234
21234
  );
@@ -21239,7 +21239,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21239
21239
  pages,
21240
21240
  sectionBreakConfig,
21241
21241
  paragraphConfig,
21242
- paragraphStart,
21242
+ isParagraphFirstShapedText,
21243
21243
  breakPointType,
21244
21244
  defaultSpanLineHeight
21245
21245
  );
@@ -21255,7 +21255,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21255
21255
  pages,
21256
21256
  sectionBreakConfig,
21257
21257
  paragraphConfig,
21258
- paragraphStart,
21258
+ isParagraphFirstShapedText,
21259
21259
  breakPointType,
21260
21260
  defaultSpanLineHeight
21261
21261
  );
@@ -21272,13 +21272,13 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21272
21272
  snapToGrid
21273
21273
  );
21274
21274
  if (currentLine.contentHeight < contentHeight) {
21275
- const spanGroupCached = __getSpanGroupByLine(currentLine), spanGroupCachedLen = spanGroupCached.length;
21276
- let newSpanGroup = [], startIndex = 1;
21277
- spanGroupCachedLen > 2 && spanGroupCached[0].glyphType === GlyphType.LIST ? (newSpanGroup = [spanGroupCached[0], spanGroupCached[1]], startIndex = 2) : newSpanGroup = [spanGroupCached[0]];
21275
+ const spanGroupCached = __getGlyphGroupByLine(currentLine), spanGroupCachedLen = spanGroupCached.length;
21276
+ let newGlyphGroup = [], startIndex = 1;
21277
+ spanGroupCachedLen > 2 && spanGroupCached[0].glyphType === GlyphType.LIST ? (newGlyphGroup = [spanGroupCached[0], spanGroupCached[1]], startIndex = 2) : newGlyphGroup = [spanGroupCached[0]];
21278
21278
  const column = currentLine.parent, { paragraphStart: lineIsStart } = column == null ? void 0 : column.lines.pop();
21279
21279
  _lineOperator(
21280
21280
  ctx,
21281
- newSpanGroup,
21281
+ newGlyphGroup,
21282
21282
  pages,
21283
21283
  sectionBreakConfig,
21284
21284
  paragraphConfig,
@@ -21293,28 +21293,45 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
21293
21293
  pages,
21294
21294
  sectionBreakConfig,
21295
21295
  paragraphConfig,
21296
- paragraphStart
21296
+ isParagraphFirstShapedText
21297
21297
  );
21298
- _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType);
21298
+ _divideOperator(
21299
+ ctx,
21300
+ glyphGroup,
21301
+ pages,
21302
+ sectionBreakConfig,
21303
+ paragraphConfig,
21304
+ isParagraphFirstShapedText,
21305
+ breakPointType
21306
+ );
21299
21307
  return;
21300
21308
  }
21301
21309
  }
21302
21310
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft), updateDivideInfo(divide, { breakType: breakPointType });
21303
21311
  }
21304
21312
  } else
21305
- _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight);
21313
+ _lineOperator(
21314
+ ctx,
21315
+ glyphGroup,
21316
+ pages,
21317
+ sectionBreakConfig,
21318
+ paragraphConfig,
21319
+ isParagraphFirstShapedText,
21320
+ breakPointType,
21321
+ defaultSpanLineHeight
21322
+ );
21306
21323
  }
21307
21324
  __name(_divideOperator, "_divideOperator");
21308
- function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21325
+ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultGlyphLineHeight) {
21309
21326
  var _a11, _b, _c, _d, _e, _f;
21310
21327
  let lastPage = getLastPage(pages), columnInfo = getLastNotFullColumnInfo(lastPage);
21311
- if ((!columnInfo || !columnInfo.column) && (_pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, void 0, breakPointType), lastPage = getLastPage(pages), columnInfo = getLastNotFullColumnInfo(lastPage)), !columnInfo) return;
21328
+ if ((!columnInfo || !columnInfo.column) && (_pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, !0, breakPointType), lastPage = getLastPage(pages), columnInfo = getLastNotFullColumnInfo(lastPage)), !columnInfo) return;
21312
21329
  const column = columnInfo.column;
21313
21330
  if (column.width <= 0) {
21314
21331
  console.error("The column width is less than 0, need to adjust page width to make it great than 0");
21315
21332
  return;
21316
21333
  }
21317
- const preLine = getLastLineByColumn(column), ascent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.ba)), descent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.bd)), spanLineHeight = defaultSpanLineHeight || ascent + descent, {
21334
+ const preLine = getLastLineByColumn(column), ascent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.ba)), descent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.bd)), glyphLineHeight = defaultGlyphLineHeight || ascent + descent, {
21318
21335
  paragraphStyle = {},
21319
21336
  paragraphAffectSkeDrawings,
21320
21337
  skeTablesInParagraph,
@@ -21330,11 +21347,18 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21330
21347
  hanging,
21331
21348
  indentStart,
21332
21349
  indentEnd
21333
- } = paragraphStyle, { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(
21350
+ } = paragraphStyle, {
21351
+ paragraphLineGapDefault,
21352
+ linePitch,
21353
+ lineSpacing,
21354
+ spacingRule,
21355
+ snapToGrid,
21356
+ gridType
21357
+ } = getLineHeightConfig(
21334
21358
  sectionBreakConfig,
21335
21359
  paragraphConfig
21336
21360
  ), { paddingTop, paddingBottom, contentHeight, lineSpacingApply } = __getLineHeight(
21337
- spanLineHeight,
21361
+ glyphLineHeight,
21338
21362
  paragraphLineGapDefault,
21339
21363
  linePitch,
21340
21364
  gridType,
@@ -21342,10 +21366,11 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21342
21366
  spacingRule,
21343
21367
  snapToGrid
21344
21368
  ), { marginTop, spaceBelowApply } = __getParagraphSpace(
21369
+ ctx,
21345
21370
  lineSpacingApply,
21346
21371
  spaceAbove,
21347
21372
  spaceBelow,
21348
- paragraphStart,
21373
+ isParagraphFirstShapedText,
21349
21374
  preLine
21350
21375
  ), lineHeight = marginTop + paddingTop + contentHeight + paddingBottom;
21351
21376
  let section = column.parent;
@@ -21356,12 +21381,12 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21356
21381
  const drawingsInLine = _getCustomBlockIdsInLine(preLine);
21357
21382
  if (drawingsInLine.length > 0) {
21358
21383
  const affectDrawings = (_d = (_c = ctx.paragraphConfigCache.get(segmentId)) == null ? void 0 : _c.get(preLine.paragraphIndex)) == null ? void 0 : _d.paragraphAffectSkeDrawings, relativeLineDrawings = [...(_e = affectDrawings == null ? void 0 : affectDrawings.values()) != null ? _e : []].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom === ObjectRelativeFromV.LINE).filter((drawing) => drawingsInLine.includes(drawing.drawingId));
21359
- relativeLineDrawings.length > 0 && __updateAndPositionDrawings(ctx, preLine.top, preLine.lineHeight, column, relativeLineDrawings, preLine.paragraphIndex, paragraphStart);
21384
+ relativeLineDrawings.length > 0 && __updateAndPositionDrawings(ctx, preLine.top, preLine.lineHeight, column, relativeLineDrawings, preLine.paragraphIndex, isParagraphFirstShapedText);
21360
21385
  }
21361
21386
  }
21362
21387
  if (paragraphAffectSkeDrawings != null && paragraphAffectSkeDrawings.size > 0) {
21363
21388
  const targetDrawings = [...paragraphAffectSkeDrawings.values()].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom !== ObjectRelativeFromV.LINE);
21364
- __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphConfig.paragraphIndex, paragraphStart, (_f = pDrawingAnchor == null ? void 0 : pDrawingAnchor.get(paragraphIndex)) == null ? void 0 : _f.top);
21389
+ __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, (_f = pDrawingAnchor == null ? void 0 : pDrawingAnchor.get(paragraphIndex)) == null ? void 0 : _f.top);
21365
21390
  }
21366
21391
  skeTablesInParagraph != null && skeTablesInParagraph.length > 0 && (needOpenNewPageByTableLayout = _updateAndPositionTable(lineTop, lastPage, section, skeTablesInParagraph));
21367
21392
  const newLineTop = calculateLineTopByDrawings(
@@ -21372,7 +21397,16 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21372
21397
  footerPage
21373
21398
  );
21374
21399
  if (lineHeight + newLineTop > section.height && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
21375
- if (setColumnFullState(column, !0), _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight), paragraphStart && paragraphAffectSkeDrawings && paragraphAffectSkeDrawings.size > 0)
21400
+ if (setColumnFullState(column, !0), _columnOperator(
21401
+ ctx,
21402
+ glyphGroup,
21403
+ pages,
21404
+ sectionBreakConfig,
21405
+ paragraphConfig,
21406
+ isParagraphFirstShapedText,
21407
+ breakPointType,
21408
+ defaultGlyphLineHeight
21409
+ ), isParagraphFirstShapedText && paragraphAffectSkeDrawings && paragraphAffectSkeDrawings.size > 0)
21376
21410
  for (const drawing of paragraphAffectSkeDrawings.values())
21377
21411
  lastPage.skeDrawings.has(drawing.drawingId) && lastPage.skeDrawings.delete(drawing.drawingId), ctx.drawingsCache.has(drawing.drawingId) && (ctx.drawingsCache.delete(drawing.drawingId), ctx.isDirty = !1, ctx.layoutStartPointer[segmentId] = null);
21378
21412
  return;
@@ -21384,7 +21418,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21384
21418
  indentStart,
21385
21419
  indentEnd,
21386
21420
  charSpaceApply,
21387
- paragraphStart
21421
+ isParagraphFirstShapedText
21388
21422
  );
21389
21423
  if (paddingLeft + paddingRight >= column.width) {
21390
21424
  const leftPercent = paddingLeft / (paddingLeft + paddingRight);
@@ -21406,23 +21440,32 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
21406
21440
  },
21407
21441
  column.width,
21408
21442
  lineIndex,
21409
- paragraphStart,
21443
+ isParagraphFirstShapedText,
21410
21444
  paragraphConfig,
21411
21445
  lastPage,
21412
21446
  headerPage,
21413
21447
  footerPage
21414
21448
  );
21415
- column.lines.push(newLine), newLine.parent = column, createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor), _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight);
21449
+ column.lines.push(newLine), newLine.parent = column, createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor), _divideOperator(
21450
+ ctx,
21451
+ glyphGroup,
21452
+ pages,
21453
+ sectionBreakConfig,
21454
+ paragraphConfig,
21455
+ isParagraphFirstShapedText,
21456
+ breakPointType,
21457
+ defaultGlyphLineHeight
21458
+ );
21416
21459
  }
21417
21460
  __name(_lineOperator, "_lineOperator");
21418
- function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, paragraphStart, drawingAnchorTop) {
21461
+ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop) {
21419
21462
  if (targetDrawings.length === 0)
21420
21463
  return;
21421
21464
  const drawings = __getDrawingPosition(
21422
21465
  lineTop,
21423
21466
  lineHeight,
21424
21467
  column,
21425
- paragraphStart,
21468
+ isParagraphFirstShapedText,
21426
21469
  drawingAnchorTop,
21427
21470
  targetDrawings
21428
21471
  );
@@ -21552,29 +21595,56 @@ function checkRelativeDrawingNeedRePosition(ctx, drawing) {
21552
21595
  return !1;
21553
21596
  }
21554
21597
  __name(checkRelativeDrawingNeedRePosition, "checkRelativeDrawingNeedRePosition");
21555
- function _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21598
+ function _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21556
21599
  const lastPage = getLastPage(pages);
21557
- isColumnFull(lastPage) === !0 ? _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight) : _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight);
21600
+ isColumnFull(lastPage) === !0 ? _pageOperator(
21601
+ ctx,
21602
+ glyphGroup,
21603
+ pages,
21604
+ sectionBreakConfig,
21605
+ paragraphConfig,
21606
+ isParagraphFirstShapedText,
21607
+ breakPointType,
21608
+ defaultSpanLineHeight
21609
+ ) : _lineOperator(
21610
+ ctx,
21611
+ glyphGroup,
21612
+ pages,
21613
+ sectionBreakConfig,
21614
+ paragraphConfig,
21615
+ isParagraphFirstShapedText,
21616
+ breakPointType,
21617
+ defaultSpanLineHeight
21618
+ );
21558
21619
  }
21559
21620
  __name(_columnOperator, "_columnOperator");
21560
- function _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart = !1, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21621
+ function _pageOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = BreakPointType.Normal, defaultSpanLineHeight) {
21561
21622
  const curSkeletonPage = getLastPage(pages), { skeHeaders, skeFooters } = paragraphConfig;
21562
- pages.push(createSkeletonPage(ctx, sectionBreakConfig, { skeHeaders, skeFooters }, (curSkeletonPage == null ? void 0 : curSkeletonPage.pageNumber) + 1)), _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, paragraphStart, breakPointType, defaultSpanLineHeight);
21623
+ pages.push(createSkeletonPage(ctx, sectionBreakConfig, { skeHeaders, skeFooters }, (curSkeletonPage == null ? void 0 : curSkeletonPage.pageNumber) + 1)), _columnOperator(
21624
+ ctx,
21625
+ glyphGroup,
21626
+ pages,
21627
+ sectionBreakConfig,
21628
+ paragraphConfig,
21629
+ isParagraphFirstShapedText,
21630
+ breakPointType,
21631
+ defaultSpanLineHeight
21632
+ );
21563
21633
  }
21564
21634
  __name(_pageOperator, "_pageOperator");
21565
- function __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, charSpaceApply, paragraphStart = !1) {
21635
+ function __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, charSpaceApply, isParagraphFirstShapedText = !1) {
21566
21636
  const indentFirstLineNumber = getNumberUnitValue(indentFirstLine, charSpaceApply), hangingNumber = getNumberUnitValue(hanging, charSpaceApply), indentStartNumber = getNumberUnitValue(indentStart, charSpaceApply), indentEndNumber = getNumberUnitValue(indentEnd, charSpaceApply);
21567
21637
  let paddingLeft = indentStartNumber;
21568
21638
  const paddingRight = indentEndNumber;
21569
- return indentFirstLineNumber > 0 && paragraphStart && (paddingLeft += indentFirstLineNumber), hangingNumber > 0 && !paragraphStart && (paddingLeft += hangingNumber), {
21639
+ return indentFirstLineNumber > 0 && isParagraphFirstShapedText && (paddingLeft += indentFirstLineNumber), hangingNumber > 0 && !isParagraphFirstShapedText && (paddingLeft += hangingNumber), {
21570
21640
  paddingLeft,
21571
21641
  paddingRight
21572
21642
  };
21573
21643
  }
21574
21644
  __name(__getIndentPadding, "__getIndentPadding");
21575
- function __getParagraphSpace(lineSpacing = 0, spaceAbove, spaceBelow, paragraphStart, preLine) {
21645
+ function __getParagraphSpace(ctx, lineSpacing = 0, spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine) {
21576
21646
  const spaceBelowApply = getNumberUnitValue(spaceBelow, lineSpacing);
21577
- if (paragraphStart) {
21647
+ if (isParagraphFirstShapedText) {
21578
21648
  let marginTop = getNumberUnitValue(spaceAbove, lineSpacing);
21579
21649
  if (preLine) {
21580
21650
  const { spaceBelowApply: preSpaceBelowApply } = preLine;
@@ -21594,25 +21664,25 @@ function __getParagraphSpace(lineSpacing = 0, spaceAbove, spaceBelow, paragraphS
21594
21664
  };
21595
21665
  }
21596
21666
  __name(__getParagraphSpace, "__getParagraphSpace");
21597
- function __getLineHeight(spanLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid) {
21667
+ function __getLineHeight(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid) {
21598
21668
  let paddingTop = paragraphLineGapDefault, paddingBottom = paragraphLineGapDefault;
21599
21669
  if (gridType === GridType.DEFAULT || snapToGrid === BooleanNumber.FALSE)
21600
21670
  return spacingRule === SpacingRule.AUTO ? {
21601
21671
  paddingTop,
21602
21672
  paddingBottom,
21603
- contentHeight: lineSpacing * spanLineHeight,
21604
- lineSpacingApply: spanLineHeight
21673
+ contentHeight: lineSpacing * glyphLineHeight,
21674
+ lineSpacingApply: glyphLineHeight
21605
21675
  } : {
21606
21676
  paddingTop,
21607
21677
  paddingBottom,
21608
- contentHeight: Math.max(lineSpacing, spanLineHeight),
21678
+ contentHeight: Math.max(lineSpacing, glyphLineHeight),
21609
21679
  lineSpacingApply: lineSpacing
21610
21680
  };
21611
21681
  let lineSpacingApply = 0;
21612
- return spacingRule === SpacingRule.AUTO ? lineSpacingApply = lineSpacing * linePitch : lineSpacingApply = lineSpacing, spanLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply && (paddingTop = paddingBottom = (lineSpacingApply - spanLineHeight) / 2), {
21682
+ return spacingRule === SpacingRule.AUTO ? lineSpacingApply = lineSpacing * linePitch : lineSpacingApply = lineSpacing, glyphLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply ? paddingTop = paddingBottom = (lineSpacingApply - glyphLineHeight) / 2 : lineSpacingApply = glyphLineHeight, {
21613
21683
  paddingTop,
21614
21684
  paddingBottom,
21615
- contentHeight: spanLineHeight,
21685
+ contentHeight: glyphLineHeight,
21616
21686
  lineSpacingApply
21617
21687
  };
21618
21688
  }
@@ -21622,7 +21692,7 @@ function updateInlineDrawingPosition(line2, paragraphInlineSkeDrawings, blockAnc
21622
21692
  const column = line2.parent, page = (_b = (_a11 = line2 == null ? void 0 : line2.parent) == null ? void 0 : _a11.parent) == null ? void 0 : _b.parent;
21623
21693
  if (page == null || column == null)
21624
21694
  return;
21625
- const isPageBreak = __checkPageBreak(column), drawings = /* @__PURE__ */ new Map(), { top, lineHeight } = line2;
21695
+ const isPageBreak = __checkPageBreak(column), drawings = /* @__PURE__ */ new Map(), { top, lineHeight, marginBottom = 0 } = line2;
21626
21696
  for (const divide of line2.divides)
21627
21697
  for (const glyph of divide.glyphGroup)
21628
21698
  if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0) {
@@ -21633,19 +21703,19 @@ function updateInlineDrawingPosition(line2, paragraphInlineSkeDrawings, blockAnc
21633
21703
  if (drawingOrigin == null || drawing == null)
21634
21704
  continue;
21635
21705
  const { docTransform } = drawingOrigin, { size, angle } = docTransform, { width = 0, height = 0 } = size, glyphHeight = glyph.bBox.bd + glyph.bBox.ba;
21636
- drawing.aLeft = divide.left + divide.paddingLeft + glyph.left + 0.5 * glyph.width - 0.5 * width || 0, drawing.aTop = top + lineHeight - 0.5 * glyphHeight - 0.5 * height || 0, drawing.width = width, drawing.height = height, drawing.angle = angle, drawing.isPageBreak = isPageBreak, drawing.lineTop = top, drawing.columnLeft = column.left, drawing.blockAnchorTop = blockAnchorTop != null ? blockAnchorTop : top, drawing.lineHeight = line2.lineHeight, drawings.set(drawing.drawingId, drawing);
21706
+ drawing.aLeft = divide.left + divide.paddingLeft + glyph.left + 0.5 * glyph.width - 0.5 * width || 0, drawing.aTop = top + lineHeight - 0.5 * glyphHeight - 0.5 * height - marginBottom, drawing.width = width, drawing.height = height, drawing.angle = angle, drawing.isPageBreak = isPageBreak, drawing.lineTop = top, drawing.columnLeft = column.left, drawing.blockAnchorTop = blockAnchorTop != null ? blockAnchorTop : top, drawing.lineHeight = line2.lineHeight, drawings.set(drawing.drawingId, drawing);
21637
21707
  }
21638
21708
  const res = new Map([...page.skeDrawings, ...drawings]);
21639
21709
  page.skeDrawings = res;
21640
21710
  }
21641
21711
  __name(updateInlineDrawingPosition, "updateInlineDrawingPosition");
21642
- function __getDrawingPosition(lineTop, lineHeight, column, paragraphStart, blockAnchorTop, needPositionDrawings = []) {
21712
+ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = []) {
21643
21713
  var _a11, _b, _c;
21644
21714
  const page = (_a11 = column.parent) == null ? void 0 : _a11.parent;
21645
21715
  if (page == null || needPositionDrawings.length === 0)
21646
21716
  return;
21647
21717
  const drawings = /* @__PURE__ */ new Map(), isPageBreak = __checkPageBreak(column);
21648
- if (!(isPageBreak && !paragraphStart)) {
21718
+ if (!(isPageBreak && !isParagraphFirstShapedText)) {
21649
21719
  for (const drawing of needPositionDrawings) {
21650
21720
  const { drawingOrigin } = drawing;
21651
21721
  if (!drawingOrigin)
@@ -21721,10 +21791,10 @@ function __maxFontBoundingBoxByGlyphGroup(glyphGroup) {
21721
21791
  return maxBox;
21722
21792
  }
21723
21793
  __name(__maxFontBoundingBoxByGlyphGroup, "__maxFontBoundingBoxByGlyphGroup");
21724
- function __getSpanGroupByLine({ divides }) {
21794
+ function __getGlyphGroupByLine({ divides }) {
21725
21795
  return divides.flatMap((divide) => divide.glyphGroup);
21726
21796
  }
21727
- __name(__getSpanGroupByLine, "__getSpanGroupByLine");
21797
+ __name(__getGlyphGroupByLine, "__getGlyphGroupByLine");
21728
21798
  function __isNullLine(line2) {
21729
21799
  return !line2.divides[0].glyphGroup[0];
21730
21800
  }
@@ -22044,7 +22114,13 @@ function getFontConfigFromLastGlyph(glyph, sectionBreakConfig, paragraphStyle) {
22044
22114
  };
22045
22115
  }
22046
22116
  __name(getFontConfigFromLastGlyph, "getFontConfigFromLastGlyph");
22047
- function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle) {
22117
+ function getBulletParagraphTextStyle(bullet, viewModel) {
22118
+ var _a11;
22119
+ const { listType } = bullet;
22120
+ return (_a11 = viewModel.getDataModel().getBulletPresetList()[listType].nestingLevel[0].paragraphProperties) == null ? void 0 : _a11.textStyle;
22121
+ }
22122
+ __name(getBulletParagraphTextStyle, "getBulletParagraphTextStyle");
22123
+ function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
22048
22124
  const {
22049
22125
  gridType = GridType.LINES,
22050
22126
  charSpace = 0,
@@ -22057,18 +22133,18 @@ function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfi
22057
22133
  marginLeft = 0,
22058
22134
  localeService,
22059
22135
  renderConfig = {}
22060
- } = sectionBreakConfig, { isRenderStyle } = renderConfig, { startIndex } = paragraphNode, textRun = isRenderStyle === BooleanNumber.FALSE ? { ts: {}, st: 0, ed: 0 } : viewModel.getTextRun(index2 + startIndex) || { ts: {}, st: 0, ed: 0 }, customDecoration = viewModel.getCustomDecoration(index2 + startIndex), showCustomDecoration = customDecoration && customDecoration.show !== !1, customDecorationStyle = showCustomDecoration ? getCustomDecorationStyle(customDecoration) : null, customRange = viewModel.getCustomRange(index2 + startIndex), showCustomRange = customRange && customRange.show !== !1, customRangeStyle = showCustomRange ? getCustomRangeStyle(customRange) : null, hasAddonStyle = showCustomRange || showCustomDecoration, { st, ed } = textRun;
22136
+ } = sectionBreakConfig, { paragraphStyle = {}, bullet } = paragraph, { isRenderStyle } = renderConfig, { startIndex } = paragraphNode, textRun = isRenderStyle === BooleanNumber.FALSE ? { ts: {}, st: 0, ed: 0 } : viewModel.getTextRun(index2 + startIndex) || { ts: {}, st: 0, ed: 0 }, customDecoration = viewModel.getCustomDecoration(index2 + startIndex), showCustomDecoration = customDecoration && customDecoration.show !== !1, customDecorationStyle = showCustomDecoration ? getCustomDecorationStyle(customDecoration) : null, customRange = viewModel.getCustomRange(index2 + startIndex), showCustomRange = customRange && customRange.show !== !1, customRangeStyle = showCustomRange ? getCustomRangeStyle(customRange) : null, hasAddonStyle = showCustomRange || showCustomDecoration, { st, ed } = textRun;
22061
22137
  let { ts: textStyle = {} } = textRun;
22062
22138
  const cache = fontCreateConfigCache.getValue(st, ed);
22063
22139
  if (cache && !hasAddonStyle)
22064
22140
  return cache;
22065
- const { snapToGrid = BooleanNumber.TRUE, textStyle: paragraphStyleTextStyle } = paragraphStyle;
22141
+ const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle, bulletTextStyle = bullet ? getBulletParagraphTextStyle(bullet, viewModel) : null;
22066
22142
  textStyle = {
22067
22143
  ...documentTextStyle,
22068
22144
  ...textStyle,
22069
22145
  ...customDecorationStyle,
22070
22146
  ...customRangeStyle,
22071
- ...paragraphStyleTextStyle
22147
+ ...bulletTextStyle
22072
22148
  };
22073
22149
  const fontStyle = getFontStyleString(textStyle), mixTextStyle = {
22074
22150
  ...documentTextStyle,
@@ -22328,14 +22404,14 @@ const _Liquid = class _Liquid {
22328
22404
  y: 0
22329
22405
  };
22330
22406
  }
22331
- translateLine(line2, isDraw = !1) {
22407
+ translateLine(line2, includeMarginTop = !1, includePaddingTop = !1) {
22332
22408
  const {
22333
22409
  top: lineTop,
22334
22410
  marginBottom: _lineMarginBottom = 0,
22335
22411
  marginTop: lineMarginTop = 0,
22336
22412
  paddingTop: linePaddingTop = 0,
22337
22413
  paddingBottom: _linePaddingBottom = 0
22338
- } = line2, lineOffset = lineTop + (isDraw === !0 ? lineMarginTop : 0) + linePaddingTop;
22414
+ } = line2, lineOffset = lineTop + (includeMarginTop ? lineMarginTop : 0) + (includePaddingTop ? linePaddingTop : 0);
22339
22415
  return this.translate(0, lineOffset), {
22340
22416
  x: 0,
22341
22417
  y: lineOffset
@@ -22544,6 +22620,8 @@ const _DocumentViewModel = class _DocumentViewModel {
22544
22620
  __publicField(this, "editAreaChange$", this._editAreaChange$.asObservable());
22545
22621
  __publicField(this, "headerTreeMap", /* @__PURE__ */ new Map());
22546
22622
  __publicField(this, "footerTreeMap", /* @__PURE__ */ new Map());
22623
+ __publicField(this, "_segmentViewModels$", new BehaviorSubject([]));
22624
+ __publicField(this, "segmentViewModels$", this._segmentViewModels$.asObservable());
22547
22625
  this._documentDataModel = _documentDataModel, _documentDataModel.getBody() != null && (this.children = parseDataStreamToTree(_documentDataModel.getBody().dataStream), this._buildHeaderFooterViewModel());
22548
22626
  }
22549
22627
  registerCustomRangeInterceptor(interceptor) {
@@ -22783,11 +22861,12 @@ const _DocumentViewModel = class _DocumentViewModel {
22783
22861
  return this._interceptor ? this._interceptor.getCustomDecoration(index2) : this.getCustomDecorationRaw(index2);
22784
22862
  }
22785
22863
  _buildHeaderFooterViewModel() {
22786
- const { headerModelMap, footerModelMap } = this._documentDataModel;
22864
+ const { headerModelMap, footerModelMap } = this._documentDataModel, viewModels = [];
22787
22865
  for (const [headerId, headerModel] of headerModelMap)
22788
- this.headerTreeMap.set(headerId, new _DocumentViewModel(headerModel));
22866
+ this.headerTreeMap.set(headerId, new _DocumentViewModel(headerModel)), viewModels.push(this.headerTreeMap.get(headerId));
22789
22867
  for (const [footerId, footerModel] of footerModelMap)
22790
- this.footerTreeMap.set(footerId, new _DocumentViewModel(footerModel));
22868
+ this.footerTreeMap.set(footerId, new _DocumentViewModel(footerModel)), viewModels.push(this.footerTreeMap.get(footerId));
22869
+ this._segmentViewModels$.next(viewModels);
22791
22870
  }
22792
22871
  _getParagraphByIndex(nodes, insertIndex) {
22793
22872
  for (const node of nodes) {
@@ -22988,10 +23067,14 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
22988
23067
  cursorList
22989
23068
  };
22990
23069
  if (!this._isValidPosition(startOrigin, endOrigin))
22991
- throw new Error("Invalid positions in NodePositionConvertToCursor, they are not in the same segment page when in header or footer.");
23070
+ throw new Error(
23071
+ `
23072
+ Invalid positions in NodePositionConvertToCursor,
23073
+ they are not in the same segment page when in header or footer.`
23074
+ );
22992
23075
  const { start, end } = compareNodePosition(startOrigin, endOrigin);
22993
23076
  return this._selectionIterator(start, end, (start_sp, end_sp, isFirst, isLast, divide, line2) => {
22994
- const { lineHeight, marginTop, asc } = line2, { glyphGroup, st } = divide;
23077
+ const { lineHeight, asc, paddingTop, marginTop, marginBottom } = line2, { glyphGroup, st } = divide;
22995
23078
  if (glyphGroup.length === 0)
22996
23079
  return;
22997
23080
  const { x: startX, y: startY } = this._liquid;
@@ -23002,12 +23085,12 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
23002
23085
  startX: startX + firstGlyphLeft + (isCurrentList ? firstGlyphWidth : 0),
23003
23086
  startY,
23004
23087
  endX: startX + lastGlyphLeft + lastGlyphWidth,
23005
- endY: startY + lineHeight
23088
+ endY: startY + lineHeight - marginTop - marginBottom
23006
23089
  }, contentBoxPosition = {
23007
23090
  startX: startX + firstGlyphLeft + (isCurrentList ? firstGlyphWidth : 0),
23008
- startY: startY + marginTop + asc - anchorGlyph.bBox.ba,
23091
+ startY: startY + paddingTop + asc - anchorGlyph.bBox.ba,
23009
23092
  endX: startX + lastGlyphLeft + lastGlyphWidth,
23010
- endY: startY + marginTop + asc + anchorGlyph.bBox.bd
23093
+ endY: startY + paddingTop + asc + anchorGlyph.bBox.bd
23011
23094
  };
23012
23095
  else {
23013
23096
  const isStartBackFin = isStartBack && !isCurrentList;
@@ -23015,12 +23098,12 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
23015
23098
  startX: startX + firstGlyphLeft + (isStartBackFin ? 0 : firstGlyphWidth),
23016
23099
  startY,
23017
23100
  endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
23018
- endY: startY + lineHeight
23101
+ endY: startY + lineHeight - marginTop - marginBottom
23019
23102
  }, contentBoxPosition = {
23020
23103
  startX: startX + firstGlyphLeft + (isStartBackFin ? 0 : firstGlyphWidth),
23021
- startY: startY + marginTop + asc - anchorGlyph.bBox.ba,
23104
+ startY: startY + paddingTop + asc - anchorGlyph.bBox.ba,
23022
23105
  endX: startX + lastGlyphLeft + (isEndBack ? 0 : lastGlyphWidth),
23023
- endY: startY + marginTop + asc + anchorGlyph.bBox.bd
23106
+ endY: startY + paddingTop + asc + anchorGlyph.bBox.bd
23024
23107
  };
23025
23108
  }
23026
23109
  borderBoxPointGroup.push(pushToPoints(borderBoxPosition)), contentBoxPointGroup.push(pushToPoints(contentBoxPosition)), cursorList.push({
@@ -23171,7 +23254,7 @@ const _NodePositionConvertToCursor = class _NodePositionConvertToCursor {
23171
23254
  divides.length - 1,
23172
23255
  l
23173
23256
  );
23174
- this._liquid.translateSave(), this._liquid.translateLine(line2);
23257
+ this._liquid.translateSave(), this._liquid.translateLine(line2, !0, !1);
23175
23258
  for (let d = start_d; d <= end_d; d++) {
23176
23259
  const divide = divides[d];
23177
23260
  this._liquid.translateSave(), this._liquid.translateDivide(divide);
@@ -23774,6 +23857,8 @@ __name(getPagePath, "getPagePath");
23774
23857
  const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
23775
23858
  constructor(_docViewModel, localeService) {
23776
23859
  super(localeService);
23860
+ __publicField(this, "_dirty$", new Subject());
23861
+ __publicField(this, "dirty$", this._dirty$.asObservable());
23777
23862
  __publicField(this, "_skeletonData");
23778
23863
  __publicField(this, "_findLiquid", new Liquid());
23779
23864
  // Use for hyphenation.
@@ -23796,7 +23881,7 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
23796
23881
  if (!this.dirty)
23797
23882
  return;
23798
23883
  const ctx = this._prepareLayoutContext();
23799
- this._skeletonData = this._createSkeleton(ctx, bounds);
23884
+ this._skeletonData = this._createSkeleton(ctx, bounds), this._dirty$.next(!0);
23800
23885
  }
23801
23886
  getSkeletonData() {
23802
23887
  return this._skeletonData;
@@ -24122,7 +24207,9 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24122
24207
  _collectNearestNode(segmentPage, pageType, page, segmentId, pi, cache, x, y, nestLevel = 0) {
24123
24208
  var _a11, _b, _c, _d, _e, _f, _g, _h, _i;
24124
24209
  const { sections, skeTables } = segmentPage;
24125
- switch (this._findLiquid.translateSave(), pageType) {
24210
+ this._findLiquid.translateSave();
24211
+ const pageLeft = this._findLiquid.x, pageRight = pageLeft + page.pageWidth, pageTop = this._findLiquid.y + (pageType === DocumentSkeletonPageType.FOOTER ? page.pageHeight - segmentPage.pageHeight : 0), pageBottom = pageTop + segmentPage.pageHeight, pointInPage = x >= pageLeft && x <= pageRight && y >= pageTop && y <= pageBottom;
24212
+ switch (pageType) {
24126
24213
  case DocumentSkeletonPageType.HEADER: {
24127
24214
  this._findLiquid.translatePagePadding({
24128
24215
  ...segmentPage,
@@ -24141,7 +24228,6 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24141
24228
  break;
24142
24229
  }
24143
24230
  }
24144
- const pointInPage = x >= this._findLiquid.x && x <= this._findLiquid.x + segmentPage.pageWidth && y >= this._findLiquid.y && y <= this._findLiquid.y + segmentPage.pageHeight;
24145
24231
  if (pointInPage)
24146
24232
  for (const section of sections) {
24147
24233
  const { columns } = section;
@@ -24717,6 +24803,10 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24717
24803
  }
24718
24804
  return Math.min(height, MAXIMUM_ROW_HEIGHT);
24719
24805
  }
24806
+ /**
24807
+ * Calculate data for row col & cell position, then update position value to this._rowHeaderWidth & this._rowHeightAccumulation & this._columnHeaderHeight & this._columnWidthAccumulation.
24808
+ * @returns this
24809
+ */
24720
24810
  _updateLayout() {
24721
24811
  if (!this.dirty)
24722
24812
  return;
@@ -25271,18 +25361,20 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25271
25361
  // return mergeRangeCache;
25272
25362
  // }
25273
25363
  _calculateStylesCache() {
25274
- const dataMergeCache = this._dataMergeCache, rowColumnSegment = this._rowColumnSegment, columnWidthAccumulation = this.columnWidthAccumulation, { startRow, endRow, startColumn, endColumn } = rowColumnSegment;
25364
+ const dataMergeCaches = this._dataMergeCache, rowColumnSegment = this._rowColumnSegment, columnWidthAccumulation = this.columnWidthAccumulation, { startRow, endRow, startColumn, endColumn } = rowColumnSegment;
25275
25365
  if (!(endColumn === -1 || endRow === -1)) {
25276
- for (const data2 of dataMergeCache)
25277
- this._setCellCache(data2.startRow, data2.startColumn, !1, data2);
25366
+ for (const mergeRange of dataMergeCaches)
25367
+ this._setCellStylesCache(mergeRange.startRow, mergeRange.startColumn, {
25368
+ mergeRange
25369
+ });
25278
25370
  for (let r = startRow; r <= endRow; r++) {
25279
25371
  for (let c = startColumn; c <= endColumn; c++)
25280
- this._setCellCache(r, c, !1);
25372
+ this._setCellStylesCache(r, c);
25281
25373
  for (let c = 0; c < startColumn; c++)
25282
- this._setCellCache(r, c, !0);
25374
+ this._setCellStylesCache(r, c, { cacheItem: { bg: !1, border: !1 } });
25283
25375
  if (endColumn !== 0)
25284
25376
  for (let c = endColumn + 1; c < columnWidthAccumulation.length; c++)
25285
- this._setCellCache(r, c, !0);
25377
+ this._setCellStylesCache(r, c, { cacheItem: { bg: !1, border: !1 } });
25286
25378
  }
25287
25379
  }
25288
25380
  }
@@ -25294,6 +25386,9 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25294
25386
  border: new ObjectMatrix()
25295
25387
  }, this._renderedCellCache = new ObjectMatrix(), this._overflowCache.reset();
25296
25388
  }
25389
+ resetCache() {
25390
+ this._resetCache();
25391
+ }
25297
25392
  _makeDocumentSkeletonDirty(r, c) {
25298
25393
  if (this._stylesCache.font == null)
25299
25394
  return;
@@ -25307,11 +25402,11 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25307
25402
  }
25308
25403
  }
25309
25404
  // eslint-disable-next-line complexity
25310
- _setCellCache(r, c, skipBackgroundAndBorder, mergeRange) {
25405
+ _setCellStylesCache(r, c, options) {
25311
25406
  var _a11;
25312
- const needsRendering = this._renderedCellCache.getValue(r, c);
25313
25407
  if (r === -1 || c === -1)
25314
25408
  return !0;
25409
+ const needsRendering = this._renderedCellCache.getValue(r, c);
25315
25410
  if (needsRendering === !1)
25316
25411
  return this._makeDocumentSkeletonDirty(r, c), !0;
25317
25412
  const cell = this.worksheet.getCell(r, c) || this.worksheet.getCellRaw(r, c);
@@ -25328,14 +25423,18 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25328
25423
  if (!isMergedMainCell)
25329
25424
  return !0;
25330
25425
  }
25331
- const cache = this._stylesCache, style = this._styles.getStyleByCell(cell);
25332
- if (!skipBackgroundAndBorder && style && style.bg && style.bg.rgb) {
25426
+ const cache = this._stylesCache, style = this._styles.getStyleByCell(cell), cacheItem = (options == null ? void 0 : options.cacheItem) || { bg: !0, border: !0 };
25427
+ if (cacheItem.bg && style && style.bg && style.bg.rgb) {
25333
25428
  const rgb = style.bg.rgb;
25334
25429
  cache.background[rgb] || (cache.background[rgb] = new ObjectMatrix()), cache.background[rgb].setValue(r, c, rgb);
25335
25430
  const cellInfo = this.getCellByIndexWithNoHeader(r, c);
25336
25431
  (_a11 = cache.backgroundPositions) == null || _a11.setValue(r, c, cellInfo);
25337
25432
  }
25338
- if (!skipBackgroundAndBorder && style && style.bd && (mergeRange ? (this._setMergeBorderProps(BORDER_TYPE.TOP, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.BOTTOM, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.LEFT, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.RIGHT, cache, mergeRange)) : this.intersectMergeRange(r, c) || (this._setBorderProps(r, c, BORDER_TYPE.TOP, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BOTTOM, style, cache), this._setBorderProps(r, c, BORDER_TYPE.LEFT, style, cache), this._setBorderProps(r, c, BORDER_TYPE.RIGHT, style, cache)), this._setBorderProps(r, c, BORDER_TYPE.TL_BR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.TL_BC, style, cache), this._setBorderProps(r, c, BORDER_TYPE.TL_MR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BL_TR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.ML_TR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BC_TR, style, cache)), needsRendering === !0)
25433
+ if (cacheItem.border && style && style.bd) {
25434
+ const mergeRange = options == null ? void 0 : options.mergeRange;
25435
+ mergeRange ? (this._setMergeBorderProps(BORDER_TYPE.TOP, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.BOTTOM, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.LEFT, cache, mergeRange), this._setMergeBorderProps(BORDER_TYPE.RIGHT, cache, mergeRange)) : this.intersectMergeRange(r, c) || (this._setBorderProps(r, c, BORDER_TYPE.TOP, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BOTTOM, style, cache), this._setBorderProps(r, c, BORDER_TYPE.LEFT, style, cache), this._setBorderProps(r, c, BORDER_TYPE.RIGHT, style, cache)), this._setBorderProps(r, c, BORDER_TYPE.TL_BR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.TL_BC, style, cache), this._setBorderProps(r, c, BORDER_TYPE.TL_MR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BL_TR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.ML_TR, style, cache), this._setBorderProps(r, c, BORDER_TYPE.BC_TR, style, cache);
25436
+ }
25437
+ if (needsRendering === !0)
25339
25438
  return this._makeDocumentSkeletonDirty(r, c), !0;
25340
25439
  if (isNullCell(cell))
25341
25440
  return;
@@ -25363,7 +25462,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25363
25462
  };
25364
25463
  fontCache2.setValue(r, c, config), this._calculateOverflowCell(r, c, config);
25365
25464
  }
25366
- skipBackgroundAndBorder ? this._renderedCellCache.setValue(r, c, !0) : this._renderedCellCache.setValue(r, c, !1);
25465
+ cacheItem.bg || cacheItem.border ? this._renderedCellCache.setValue(r, c, !1) : this._renderedCellCache.setValue(r, c, !0);
25367
25466
  }
25368
25467
  _updateConfigAndGetDocumentModel(documentData, horizontalAlign, renderConfig) {
25369
25468
  var _a11;
@@ -25577,14 +25676,13 @@ const UNIQUE_KEY$7 = "DefaultFontExtension", EXTENSION_Z_INDEX = 45, _Font = cla
25577
25676
  }
25578
25677
  draw(ctx, parentScale, spreadsheetSkeleton, diffRanges, moreBoundsInfo) {
25579
25678
  const { viewRanges = [], checkOutOfViewBound } = moreBoundsInfo, { stylesCache, dataMergeCache, overflowCache, worksheet } = spreadsheetSkeleton, { font: fontList } = stylesCache;
25580
- if (!spreadsheetSkeleton || !worksheet)
25679
+ if (!spreadsheetSkeleton || !worksheet || !fontList)
25581
25680
  return;
25582
25681
  const { rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;
25583
25682
  if (!rowHeightAccumulation || !columnWidthAccumulation || columnTotalWidth === void 0 || rowTotalHeight === void 0 || !worksheet)
25584
25683
  return;
25585
25684
  ctx.save();
25586
- const scale = this._getScale(parentScale);
25587
- fontList && Object.keys(fontList).forEach((fontFormat) => {
25685
+ const scale = this._getScale(parentScale), renderFontByCell = /* @__PURE__ */ __name((fontFormat) => {
25588
25686
  fontList[fontFormat].forValue((rowIndex, columnIndex, docsConfig) => {
25589
25687
  var _a11, _b, _c, _d, _e;
25590
25688
  if (!checkOutOfViewBound && !inViewRanges(viewRanges, rowIndex, columnIndex))
@@ -25659,7 +25757,8 @@ const UNIQUE_KEY$7 = "DefaultFontExtension", EXTENSION_Z_INDEX = 45, _Font = cla
25659
25757
  ctx.rectByPrecision(startX + 1 / scale, startY + 1 / scale, cellWidth - 2 / scale, cellHeight - 2 / scale), ctx.clip();
25660
25758
  ctx.translate(startX + FIX_ONE_PIXEL_BLUR_OFFSET, startY + FIX_ONE_PIXEL_BLUR_OFFSET), this._renderDocuments(ctx, docsConfig, startX, startY, endX, endY, rowIndex, columnIndex, overflowCache), ctx.closePath(), ctx.restore();
25661
25759
  });
25662
- }), ctx.restore();
25760
+ }, "renderFontByCell");
25761
+ Object.keys(fontList).forEach(renderFontByCell), ctx.restore();
25663
25762
  }
25664
25763
  _renderDocuments(ctx, docsConfig, startX, startY, endX, endY, row, column, overflowCache) {
25665
25764
  const documents = this.getDocuments();
@@ -27149,6 +27248,7 @@ const RICHTEXT_OBJECT_ARRAY = ["text", "richText", "fs"], _RichText = class _Ric
27149
27248
  __publicField(this, "_documentData");
27150
27249
  __publicField(this, "_documentSkeleton");
27151
27250
  __publicField(this, "_documents");
27251
+ __publicField(this, "documentModel");
27152
27252
  /**
27153
27253
  * fontFamily
27154
27254
  */
@@ -27202,7 +27302,7 @@ const RICHTEXT_OBJECT_ARRAY = ["text", "richText", "fs"], _RichText = class _Ric
27202
27302
  __publicField(this, "_cl");
27203
27303
  __publicField(this, "objectType", ObjectType.RICH_TEXT);
27204
27304
  this._localeService = _localeService, props != null && props.richText ? this._documentData = props.richText : props && (this._fs = props.fs, this._ff = props.ff, this._it = props.it, this._bl = props.bl, this._ul = props.ul, this._st = props.st, this._ol = props.ol, this._bg = props.bg, this._bd = props.bd, this._cl = props.cl, this._documentData = this._convertToDocumentData(props.text || ""));
27205
- const docModel = new DocumentDataModel(this._documentData), docViewModel = new DocumentViewModel(docModel);
27305
+ const docModel = this.documentModel = new DocumentDataModel(this._documentData), docViewModel = new DocumentViewModel(docModel);
27206
27306
  this._documentSkeleton = DocumentSkeleton.create(docViewModel, this._localeService), this._documents = new Documents(`${this.oKey}_DOCUMENTS`, this._documentSkeleton, {
27207
27307
  pageMarginLeft: 0,
27208
27308
  pageMarginTop: 0
@@ -27326,14 +27426,13 @@ const RICHTEXT_OBJECT_ARRAY = ["text", "richText", "fs"], _RichText = class _Ric
27326
27426
  }), this.setProps(props), this.makeDirty(!0);
27327
27427
  }
27328
27428
  /**
27329
- *
27330
- * it should be invoked when _documentData changed.
27331
- * _documentData changed ---> update _documentSkeleton & _documentSkeleton
27332
- *
27333
- * now it is invoked when transformByState(change editor size) & end of editing
27429
+ * After changing editor size & end of editing, update skeleton of doc.
27334
27430
  */
27431
+ // TODO: This method should be invoked when _documentData changed.
27432
+ // _documentData changed ---> update _documentSkeleton & _documentSkeleton
27433
+ // now it is invoked when transformByState(change editor size) & end of editing
27335
27434
  refreshDocumentByDocData() {
27336
- const docModel = new DocumentDataModel(this._documentData), docViewModel = new DocumentViewModel(docModel);
27435
+ const docModel = this.documentModel = new DocumentDataModel(this._documentData), docViewModel = new DocumentViewModel(docModel);
27337
27436
  this._documentSkeleton = DocumentSkeleton.create(docViewModel, this._localeService), this._documents = new Documents(`${this.oKey}_DOCUMENTS`, this._documentSkeleton, {
27338
27437
  pageMarginLeft: 0,
27339
27438
  pageMarginTop: 0
@@ -28015,7 +28114,7 @@ const _Documents = class _Documents extends DocComponent {
28015
28114
  renderConfig
28016
28115
  }, extension.draw(ctx, parentScale, line2));
28017
28116
  else {
28018
- this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0), rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i2]);
28117
+ this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0, !0), rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i2]);
28019
28118
  const divideLength = divides.length;
28020
28119
  for (let i3 = 0; i3 < divideLength; i3++) {
28021
28120
  const divide = divides[i3], { glyphGroup } = divide;
@@ -28160,7 +28259,7 @@ const _Documents = class _Documents extends DocComponent {
28160
28259
  renderConfig
28161
28260
  }, extension.draw(ctx, parentScale, line2));
28162
28261
  else {
28163
- this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0);
28262
+ this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0, !0);
28164
28263
  const divideLength = divides.length;
28165
28264
  for (let i2 = 0; i2 < divideLength; i2++) {
28166
28265
  const divide = divides[i2], { glyphGroup } = divide;
@@ -28265,7 +28364,7 @@ const _Documents = class _Documents extends DocComponent {
28265
28364
  renderConfig
28266
28365
  }, extension.draw(ctx, parentScale, line2));
28267
28366
  else {
28268
- this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0);
28367
+ this._drawLiquid.translateSave(), this._drawLiquid.translateLine(line2, !0, !0);
28269
28368
  const { y } = this._drawLiquid;
28270
28369
  if (isHeader) {
28271
28370
  if (y - originY + alignOffset.y > (parentPage.pageHeight - 100) / 2) {
@@ -28399,8 +28498,6 @@ const OBJECT_KEY = "__SHEET_EXTENSION_FONT_DOCUMENT_INSTANCE__", _Spreadsheet =
28399
28498
  }
28400
28499
  /**
28401
28500
  * draw by viewport
28402
- * cacheBound ---> viewBound
28403
- * diffCacheBounds ---> diffRange
28404
28501
  * @param ctx
28405
28502
  * @param viewportInfo
28406
28503
  */
@@ -28790,15 +28887,20 @@ const arrowPath = "M512 1024C229.248 1024 0 794.752 0 512S229.248 0 512 0s512 22
28790
28887
  constructor() {
28791
28888
  super(...arguments);
28792
28889
  __publicField(this, "slideChangePageByNavigation$", new EventSubject());
28890
+ __publicField(this, "subSceneChanged$", new EventSubject());
28793
28891
  __publicField(this, "_navigationEnabled", !1);
28794
28892
  }
28795
28893
  activeFirstPage() {
28796
28894
  const firstKey = this.getSubScenes().keys().next().value;
28797
28895
  firstKey != null && this.changePage(firstKey);
28798
28896
  }
28799
- addPage(scene) {
28800
- const key = scene.sceneKey;
28801
- this.getSubScene(key) == null && (this.addSubScene(scene), this.addNavigation());
28897
+ /**
28898
+ * add pageScene to this._subScenes
28899
+ * @param pageScene
28900
+ */
28901
+ addPageScene(pageScene) {
28902
+ const key = pageScene.sceneKey;
28903
+ this.getSubScene(key) || this.addSubScene(pageScene), this.addNavigation(), this.subSceneChanged$.emitEvent(pageScene);
28802
28904
  }
28803
28905
  changePage(id) {
28804
28906
  id !== null && (this.removeNavigation(), this.activeSubScene(id), this.addNavigation());
@@ -29067,9 +29169,17 @@ function getOverflowAncestors(node, list, traverseIframes) {
29067
29169
  var _node$ownerDocument2;
29068
29170
  list === void 0 && (list = []), traverseIframes === void 0 && (traverseIframes = !0);
29069
29171
  const scrollableAncestor = getNearestOverflowAncestor(node), isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body), win = getWindow(scrollableAncestor);
29070
- return isBody ? list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []) : list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
29172
+ if (isBody) {
29173
+ const frameElement = getFrameElement(win);
29174
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
29175
+ }
29176
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
29071
29177
  }
29072
29178
  __name(getOverflowAncestors, "getOverflowAncestors");
29179
+ function getFrameElement(win) {
29180
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
29181
+ }
29182
+ __name(getFrameElement, "getFrameElement");
29073
29183
  function observeClientRect(containerElement) {
29074
29184
  return new Observable((observer) => {
29075
29185
  const disposable = autoClientRect(containerElement, () => observer.next());
@@ -31307,8 +31417,10 @@ const _Scene = class _Scene extends ThinScene {
31307
31417
  scaleX !== void 0 && (this.scaleX = scaleX), scaleY !== void 0 && (this.scaleY = scaleY);
31308
31418
  }
31309
31419
  /**
31310
- * scale to value, absolute
31311
- * setTransform ---> viewport._updateScrollBarPosByViewportScroll ---> scrollTo
31420
+ * Set scale, and then emit event to update Viewport scroll state.
31421
+ * @param scaleX
31422
+ * @param scaleY
31423
+ * @returns Scene
31312
31424
  */
31313
31425
  scale(scaleX, scaleY) {
31314
31426
  const preScaleX = this.scaleX;
@@ -31340,9 +31452,7 @@ const _Scene = class _Scene extends ThinScene {
31340
31452
  }), this;
31341
31453
  }
31342
31454
  /**
31343
- * This sequence will initiate a series of updates:
31344
- * scene._setTransForm --> viewport@resetCanvasSizeAndUpdateScrollBar ---> scrollTo ---> limitedScroll ---> onScrollBeforeObserver ---> setScrollInfo
31345
- * scrollInfo needs accurate scene width & height, limitedScroll depends on scene & engine's width & height
31455
+ * Reset canvas size and update scroll
31346
31456
  * @param state
31347
31457
  */
31348
31458
  transformByState(state) {
@@ -31393,6 +31503,12 @@ const _Scene = class _Scene extends ThinScene {
31393
31503
  var _a11;
31394
31504
  return (_a11 = this.getLayer(zIndex)) == null || _a11.addObjects(objects), this._addObject$.next(this), this;
31395
31505
  }
31506
+ /**
31507
+ * Add object to Layer (Layer is specified by zIndex).
31508
+ * @param o
31509
+ * @param zIndex layer index
31510
+ * @returns scene
31511
+ */
31396
31512
  addObject(o, zIndex = 1) {
31397
31513
  var _a11;
31398
31514
  return (_a11 = this.getLayer(zIndex)) == null || _a11.addObject(o), this._addObject$.next(this), this;
@@ -31526,6 +31642,10 @@ const _Scene = class _Scene extends ThinScene {
31526
31642
  this.render(parentCtx), requestNewFrame(resolve);
31527
31643
  });
31528
31644
  }
31645
+ /**
31646
+ * create transformer if not exist, and then transformer attach to object that passed in by parameter.
31647
+ * @param o
31648
+ */
31529
31649
  attachTransformerTo(o) {
31530
31650
  var _a11;
31531
31651
  this._transformer || this.initTransformer(), (_a11 = this._transformer) == null || _a11.attachTo(o);
@@ -31816,11 +31936,15 @@ let RenderUnit = (_a7 = class extends Disposable {
31816
31936
  this._injector.dispose(), super.dispose();
31817
31937
  }
31818
31938
  /**
31819
- * Get render controller hold by this render unit.
31939
+ * Get a dependency from the RenderUnit's injector.
31820
31940
  */
31821
31941
  with(dependency) {
31822
31942
  return this._injector.get(dependency);
31823
31943
  }
31944
+ /**
31945
+ * Add render dependencies to the RenderUnit's injector. Note that the dependencies would be initialized immediately
31946
+ * after being added.
31947
+ */
31824
31948
  addRenderDependencies(dependencies) {
31825
31949
  this._initDependencies(dependencies);
31826
31950
  }
@@ -31829,9 +31953,13 @@ let RenderUnit = (_a7 = class extends Disposable {
31829
31953
  dependencies.forEach((dep) => {
31830
31954
  const [identifier, implOrNull] = Array.isArray(dep) ? dep : [dep, null];
31831
31955
  if (!implOrNull)
31832
- j.add([identifier, { useFactory: /* @__PURE__ */ __name(() => j.createInstance(identifier, this._renderContext), "useFactory") }]);
31956
+ j.add([identifier, {
31957
+ useFactory: /* @__PURE__ */ __name(() => j.createInstance(identifier, this._renderContext), "useFactory")
31958
+ }]);
31833
31959
  else if (isClassDependencyItem(implOrNull))
31834
- j.add([identifier, { useFactory: /* @__PURE__ */ __name(() => j.createInstance(implOrNull.useClass, this._renderContext), "useFactory") }]);
31960
+ j.add([identifier, {
31961
+ useFactory: /* @__PURE__ */ __name(() => j.createInstance(implOrNull.useClass, this._renderContext), "useFactory")
31962
+ }]);
31835
31963
  else
31836
31964
  throw new Error("[RenderUnit]: render dependency could only be an class!");
31837
31965
  }), dependencies.forEach((dep) => {
@@ -31884,21 +32012,36 @@ let RenderManagerService = (_a8 = class extends Disposable {
31884
32012
  deps.forEach((dep) => remove(dependencies, dep));
31885
32013
  });
31886
32014
  }
31887
- registerRenderModule(type, ctor) {
32015
+ /**
32016
+ * add dep to _renderDependencies(type, dep)
32017
+ * @param type
32018
+ * @param depCtor
32019
+ */
32020
+ registerRenderModule(type, depCtor) {
31888
32021
  this._renderDependencies.has(type) || this._renderDependencies.set(type, []);
31889
32022
  const dependencies = this._renderDependencies.get(type);
31890
- dependencies.push(ctor);
32023
+ dependencies.push(depCtor);
31891
32024
  for (const [_2, render] of this._renderMap)
31892
- render.type === type && this._tryAddRenderDependencies(render, [ctor]);
31893
- return toDisposable(() => remove(dependencies, ctor));
32025
+ render.type === type && this._tryAddRenderDependencies(render, [depCtor]);
32026
+ return toDisposable(() => remove(dependencies, depCtor));
31894
32027
  }
31895
- _getRenderControllersForType(type) {
32028
+ /**
32029
+ * get render dependencies from _renderDependencies
32030
+ * @param type
32031
+ * @returns Dependency[]
32032
+ */
32033
+ _getRenderDepsByType(type) {
31896
32034
  var _a11;
31897
32035
  return Array.from((_a11 = this._renderDependencies.get(type)) != null ? _a11 : []);
31898
32036
  }
31899
32037
  create(unitId) {
31900
32038
  this._createRender$.next(unitId);
31901
32039
  }
32040
+ /**
32041
+ * create renderUnit & init deps from renderDependencies
32042
+ * @param unitId
32043
+ * @returns renderUnit:IRender
32044
+ */
31902
32045
  createRender(unitId) {
31903
32046
  const renderer = this._createRender(unitId, new Engine());
31904
32047
  return this._renderCreated$.next(renderer), renderer;
@@ -31918,9 +32061,21 @@ let RenderManagerService = (_a8 = class extends Disposable {
31918
32061
  const current = this._univerInstanceService.getCurrentUnitForType(type);
31919
32062
  return current ? (_a11 = this.getRenderById(current.getUnitId())) == null ? void 0 : _a11.with(id) : null;
31920
32063
  }
32064
+ /**
32065
+ * init deps by injector.get(dep), and injector derives from renderer.
32066
+ * @param renderer
32067
+ * @param deps
32068
+ */
31921
32069
  _tryAddRenderDependencies(renderer, deps) {
31922
32070
  renderer instanceof RenderUnit && renderer.addRenderDependencies(deps);
31923
32071
  }
32072
+ /**
32073
+ * create renderUnit & init deps from renderDependencies by renderUnit's type
32074
+ * @param unitId
32075
+ * @param engine
32076
+ * @param isMainScene
32077
+ * @returns renderUnit:IRender
32078
+ */
31924
32079
  _createRender(unitId, engine, isMainScene = !0) {
31925
32080
  const existItem = this.getRenderById(unitId);
31926
32081
  let shouldDestroyEngine = !0;
@@ -31931,13 +32086,13 @@ let RenderManagerService = (_a8 = class extends Disposable {
31931
32086
  }), unit = this._univerInstanceService.getUnit(unitId);
31932
32087
  let renderUnit;
31933
32088
  if (unit) {
31934
- const type = this._univerInstanceService.getUnitType(unitId), ctors = this._getRenderControllersForType(type);
32089
+ const type = this._univerInstanceService.getUnitType(unitId), ctorOfDeps = this._getRenderDepsByType(type);
31935
32090
  renderUnit = this._injector.createInstance(RenderUnit, {
31936
32091
  unit,
31937
32092
  engine,
31938
32093
  scene,
31939
32094
  isMainScene
31940
- }), this._tryAddRenderDependencies(renderUnit, ctors);
32095
+ }), this._tryAddRenderDependencies(renderUnit, ctorOfDeps);
31941
32096
  } else
31942
32097
  renderUnit = {
31943
32098
  isThumbNail: !0,
@@ -31977,6 +32132,11 @@ let RenderManagerService = (_a8 = class extends Disposable {
31977
32132
  getFirst() {
31978
32133
  return [...this.getRenderAll().values()][0];
31979
32134
  }
32135
+ /**
32136
+ * get RenderUnit from this._renderMap
32137
+ * @param unitId
32138
+ * @returns RenderUnit, aka IRender
32139
+ */
31980
32140
  getRenderById(unitId) {
31981
32141
  return this._renderMap.get(unitId);
31982
32142
  }
@@ -32271,10 +32431,6 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32271
32431
  disable() {
32272
32432
  this._active = !1;
32273
32433
  }
32274
- /**
32275
- * invoked when canvas element size change
32276
- * engineResizeObserver --> engine.resizeBySize --> scene._setTransForm
32277
- */
32278
32434
  resetCanvasSizeAndUpdateScroll() {
32279
32435
  this._resizeCacheCanvas(), this._updateScrollByViewportScrollValue();
32280
32436
  }
@@ -32310,33 +32466,18 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32310
32466
  });
32311
32467
  }
32312
32468
  /**
32313
- * There are serval cases to call this method.
32314
- * the most common case is scrolling. Other situations include:
32315
- * 1. changing the frozen row & col settings
32316
- * 2. changing curr skeleton
32317
- * 3. changing selection which cross viewport
32318
- * 4. changing the viewport size (also include change window size)
32319
- * 5. changing the scroll bar position
32320
- *
32321
- * when scrolling by trackpad:
32322
- * scene.input-manager@_onMouseWheel --> scene@triggerMouseWheel --> sheet-render.controller@scene.onMouseWheel$.add -->
32323
- * set-scroll.command.ts --> scroll.operation.ts -->
32324
- * scrollManagerService.setScrollInfoAndEmitEvent
32325
- *
32326
- * when change skelenton:
32327
- * _currentSkeletonBefore$ ---> scroll.render-controller@_updateSceneSize --> setSearchParam --> scene@_setTransForm ---> viewport.resetCanvasSizeAndUpdateScrollBar ---> scrollToXX
32328
- * --> onScrollAfterObserver.notifyObservers --> scroll.render-controller@onScrollAfterObserver ---> setScrollInfoToCurrSheetWithoutNotify ---> sms._setScrollInfo
32329
- *
32330
- * _currentSkeleton$ ---> selection.render-controller ---> formula@_autoScroll ---> viewport.resize ---> get scrollXY by viewportScrollXY ---> scrollTo
32331
- * _currentSkeleton$ ---> selection.render-controller ---> setCurrentSelection ---> formula@_autoScroll ---> scrollTo
32332
- * _currentSkeleton$ ---> freeze.render-controller@_refreshFreeze --> viewport.resize ---> scrollTo ---> _scroll
32333
- *
32334
- * Debug
32335
- * window.scene.getViewports()[0].scrollTo({x: 14.2, y: 1.8}, true)
32336
- *
32337
- * @param pos
32338
- *
32469
+ * ScrollBar scroll to certain position.
32470
+ * @param pos position of scrollBar
32339
32471
  */
32472
+ // There are serval cases to call this method.
32473
+ // the most common case is scrolling. Other situations include:
32474
+ // 1. changing the frozen row & col settings
32475
+ // 2. changing curr skeleton
32476
+ // 3. changing selection which cross viewport
32477
+ // 4. changing the viewport size (also include change window size)
32478
+ // 5. changing the scroll bar position
32479
+ // Debug
32480
+ // window.scene.getViewports()[0].scrollTo({x: 14.2, y: 1.8}, true)
32340
32481
  scrollToBarPos(pos) {
32341
32482
  return this._scrollToBarPosCore(pos);
32342
32483
  }
@@ -32367,6 +32508,12 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32367
32508
  isTrigger
32368
32509
  });
32369
32510
  }
32511
+ /**
32512
+ * Viewport scroll to certain position.
32513
+ * @param pos
32514
+ * @param isTrigger
32515
+ * @returns IViewportScrollPosition
32516
+ */
32370
32517
  scrollToViewportPos(pos, isTrigger = !0) {
32371
32518
  if (!this._scrollBar || this.isActive === !1)
32372
32519
  return;
@@ -32428,8 +32575,11 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32428
32575
  getScrollBar() {
32429
32576
  return this._scrollBar;
32430
32577
  }
32431
- // scrollTo ---> _scroll ---> onScrollAfter$.next ---> scroll.render-controller@updateScroll
32432
- // scrollTo ---> _scroll ---> onScrollAfter$.next ---> freeze.render-controller@updateScroll
32578
+ /**
32579
+ * Just record state of scroll. This method won't scroll viewport and scrollbar.
32580
+ * @param current
32581
+ * @returns Viewport
32582
+ */
32433
32583
  updateScrollVal(current) {
32434
32584
  this._preScrollX = this.scrollX, this._preScrollY = this.scrollY;
32435
32585
  const { scrollX, scrollY, viewportScrollX, viewportScrollY } = current;
@@ -32443,8 +32593,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32443
32593
  return !(this.isActive === !1 || this.width == null || this.height == null || this.width <= 1 || this.height <= 1);
32444
32594
  }
32445
32595
  /**
32446
- * call stack: engine.renderLoop ---> scene.render ---> layer.render ---> viewport.render
32447
- * that means each layer call all viewports to render
32596
+ * Render function in each render loop.
32448
32597
  * @param parentCtx parentCtx is cacheCtx from layer when layer._allowCache is true
32449
32598
  * @param objects
32450
32599
  * @param isMaxLayer
@@ -32691,7 +32840,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32691
32840
  (_a11 = this._cacheCanvas) == null || _a11.setSize(canvasW, canvasH), this.cacheBound = this._viewBound, this.preCacheBound = null, this.markForceDirty(!0);
32692
32841
  }
32693
32842
  /**
32694
- * This method will be invoked when viewport is resizing and removing rol & col
32843
+ * Update scroll when viewport is resizing and removing rol & col
32695
32844
  */
32696
32845
  _updateScrollByViewportScrollValue() {
32697
32846
  if (!this.width || this.width < 0 || !this.height || this.height < 0) return;
@@ -33503,8 +33652,8 @@ function getRangeListFromSelection(anchorPosition, focusPosition, scene, documen
33503
33652
  else if (endOffset > tableStart && endOffset < tableEnd)
33504
33653
  tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, !0, segmentId, segmentPage), tableEndPosition = skeleton.findNodePositionByCharIndex(endRow.endIndex - 3, !0, segmentId, segmentPage), end = tableStart - 1, endInTable = !0;
33505
33654
  else if (tableStart > startOffset && tableEnd < endOffset) {
33506
- if (tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, !0, segmentId, segmentPage), tableEndPosition = skeleton.findNodePositionByCharIndex(tableEnd - 4, !0, segmentId, segmentPage), start < tableStart - 1) {
33507
- const sp = skeleton.findNodePositionByCharIndex(start, !0, segmentId, segmentPage), ep = skeleton.findNodePositionByCharIndex(tableStart - 1, !0, segmentId, segmentPage), ap = direction ? sp : ep, fp = direction ? ep : sp;
33655
+ if (tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, !0, segmentId, segmentPage), tableEndPosition = skeleton.findNodePositionByCharIndex(tableEnd - 4, !0, segmentId, segmentPage), start <= tableStart - 1) {
33656
+ const sp = skeleton.findNodePositionByCharIndex(start, !0, segmentId, segmentPage), ep = skeleton.findNodePositionByCharIndex(tableStart - 1, !1, segmentId, segmentPage), ap = direction ? sp : ep, fp = direction ? ep : sp;
33508
33657
  textRanges.push(new TextRange(scene, document2, skeleton, ap, fp, style, segmentId));
33509
33658
  }
33510
33659
  start = tableEnd + 1;
@@ -33523,8 +33672,8 @@ function getRangeListFromSelection(anchorPosition, focusPosition, scene, documen
33523
33672
  }
33524
33673
  }
33525
33674
  if (end >= startIndex && end <= endIndex || endInTable) {
33526
- const sp = skeleton.findNodePositionByCharIndex(start, !0, segmentId, segmentPage), ep = skeleton.findNodePositionByCharIndex(end, !0, segmentId, segmentPage), ap = direction ? sp : ep, fp = direction ? ep : sp;
33527
- if (rectRanges.length && start === end)
33675
+ const sp = skeleton.findNodePositionByCharIndex(start, !0, segmentId, segmentPage), ep = skeleton.findNodePositionByCharIndex(end, !endInTable, segmentId, segmentPage), ap = direction ? sp : ep, fp = direction ? ep : sp;
33676
+ if (rectRanges.length && Tools.diffValue(ap, fp))
33528
33677
  continue;
33529
33678
  textRanges.push(new TextRange(scene, document2, skeleton, ap, fp, style, segmentId));
33530
33679
  }
@@ -33732,7 +33881,7 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
33732
33881
  this._removeAllRanges();
33733
33882
  return;
33734
33883
  }
33735
- (startNode == null ? void 0 : startNode.node.streamType) === DataStreamTreeTokenType.PARAGRAPH && (position.isBack = !0), this._updateTextRangeAnchorPosition(position), this._activeSelectionRefresh(), this._textSelectionInner$.next({
33884
+ (startNode == null ? void 0 : startNode.node.streamType) === DataStreamTreeTokenType.PARAGRAPH && (position.isBack = !0), this._createTextRangeByAnchorPosition(position), this._textSelectionInner$.next({
33736
33885
  textRanges: this._getAllTextRanges(),
33737
33886
  rectRanges: this._getAllRectRanges(),
33738
33887
  segmentId: this._currentSegmentId,
@@ -34026,11 +34175,12 @@ let TextSelectionRenderManager = (_a10 = class extends RxDisposable {
34026
34175
  _addRectRanges(rectRanges) {
34027
34176
  rectRanges.length !== 0 && (this._deactivateAllRectRanges(), rectRanges[rectRanges.length - 1].activate(), this._rectRangeList.push(...rectRanges));
34028
34177
  }
34029
- _updateTextRangeAnchorPosition(position) {
34178
+ _createTextRangeByAnchorPosition(position) {
34030
34179
  if (!this._scene)
34031
34180
  return;
34032
- let lastRange = this._rangeList.pop();
34033
- lastRange || (lastRange = new TextRange(this._scene, this._document, this._docSkeleton, position, void 0, this._selectionStyle, this._currentSegmentId)), this._removeAllTextRanges(), lastRange.activate(), lastRange.anchorNodePosition = position, lastRange.focusNodePosition = null, this._rangeList = [lastRange];
34181
+ this._removeAllRanges();
34182
+ const lastRange = new TextRange(this._scene, this._document, this._docSkeleton, position, void 0, this._selectionStyle, this._currentSegmentId);
34183
+ this._addTextRange(lastRange);
34034
34184
  }
34035
34185
  _updateActiveRangePosition(position) {
34036
34186
  if (!this._scene) {