@univerjs/engine-render 1.0.0-alpha.1 → 1.0.0-insiders.20260701-0ef51b0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -12707,6 +12707,34 @@ var DocumentViewModel = class DocumentViewModel {
12707
12707
  }
12708
12708
  };
12709
12709
 
12710
+ //#endregion
12711
+ //#region src/components/docs/custom-block-render-viewport.ts
12712
+ let docsCustomBlockRenderViewportProvider = null;
12713
+ const docsCustomBlockRenderViewportProviders = /* @__PURE__ */ new Set();
12714
+ function setDocsCustomBlockRenderViewportProvider(provider) {
12715
+ if (provider == null) {
12716
+ docsCustomBlockRenderViewportProvider = null;
12717
+ docsCustomBlockRenderViewportProviders.clear();
12718
+ return () => {};
12719
+ }
12720
+ docsCustomBlockRenderViewportProvider = provider;
12721
+ docsCustomBlockRenderViewportProviders.add(provider);
12722
+ return () => {
12723
+ var _providers;
12724
+ docsCustomBlockRenderViewportProviders.delete(provider);
12725
+ const providers = Array.from(docsCustomBlockRenderViewportProviders);
12726
+ docsCustomBlockRenderViewportProvider = (_providers = providers[providers.length - 1]) !== null && _providers !== void 0 ? _providers : null;
12727
+ };
12728
+ }
12729
+ function getDocsCustomBlockRenderViewport(unitId, blockId, input) {
12730
+ const providers = docsCustomBlockRenderViewportProviders.size ? Array.from(docsCustomBlockRenderViewportProviders).reverse() : docsCustomBlockRenderViewportProvider ? [docsCustomBlockRenderViewportProvider] : [];
12731
+ for (const provider of providers) {
12732
+ const viewport = provider(unitId, blockId, input);
12733
+ if (viewport != null) return viewport;
12734
+ }
12735
+ return null;
12736
+ }
12737
+
12710
12738
  //#endregion
12711
12739
  //#region src/components/docs/layout/model/glyph.ts
12712
12740
  function isSpace(char) {
@@ -13897,7 +13925,7 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
13897
13925
  if (anchorDrawings.length > 0) {
13898
13926
  var _paragraphConfig$para, _paragraphConfig$pDra;
13899
13927
  const paragraphAnchorLeft = __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, (_paragraphConfig$para = paragraphConfig.paragraphStyle) === null || _paragraphConfig$para === void 0 ? void 0 : _paragraphConfig$para.indentStart);
13900
- const drawings = __getDrawingPosition(currentLine.top, currentLine.lineHeight, currentLine.parent, true, (_paragraphConfig$pDra = paragraphConfig.pDrawingAnchor) === null || _paragraphConfig$pDra === void 0 || (_paragraphConfig$pDra = _paragraphConfig$pDra.get(paragraphConfig.paragraphIndex)) === null || _paragraphConfig$pDra === void 0 ? void 0 : _paragraphConfig$pDra.top, anchorDrawings, paragraphAnchorLeft);
13928
+ const drawings = __getDrawingPosition(ctx, currentLine.top, currentLine.lineHeight, currentLine.parent, true, (_paragraphConfig$pDra = paragraphConfig.pDrawingAnchor) === null || _paragraphConfig$pDra === void 0 || (_paragraphConfig$pDra = _paragraphConfig$pDra.get(paragraphConfig.paragraphIndex)) === null || _paragraphConfig$pDra === void 0 ? void 0 : _paragraphConfig$pDra.top, anchorDrawings, paragraphAnchorLeft, false);
13901
13929
  __updateDrawingPosition(currentLine.parent, drawings);
13902
13930
  addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
13903
13931
  updateDivideInfo(divide, { breakType: breakPointType });
@@ -13997,6 +14025,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
13997
14025
  }
13998
14026
  }
13999
14027
  let deferredInlineGroupAnchorDrawings = [];
14028
+ let deferredTopBottomAnchorDrawings = [];
14000
14029
  if (paragraphNonInlineSkeDrawings != null && paragraphNonInlineSkeDrawings.size > 0) {
14001
14030
  var _pDrawingAnchor$get;
14002
14031
  let targetDrawings = [...paragraphNonInlineSkeDrawings.values()].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom !== _univerjs_core.ObjectRelativeFromV.LINE);
@@ -14004,13 +14033,17 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
14004
14033
  deferredInlineGroupAnchorDrawings = targetDrawings.filter((drawing) => glyphGroupCustomBlockIds.has(drawing.drawingId) && drawing.drawingOrigin.docTransform.positionV.relativeFrom === _univerjs_core.ObjectRelativeFromV.LINE);
14005
14034
  targetDrawings = targetDrawings.filter((drawing) => !deferredInlineGroupAnchorDrawings.includes(drawing));
14006
14035
  }
14007
- __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get === void 0 ? void 0 : _pDrawingAnchor$get.top, paragraphAnchorLeft);
14036
+ deferredTopBottomAnchorDrawings = targetDrawings.filter((drawing) => glyphGroupCustomBlockIds.has(drawing.drawingId) && drawing.drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM);
14037
+ targetDrawings = targetDrawings.filter((drawing) => drawing.drawingOrigin.layoutType !== _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM);
14038
+ __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get === void 0 ? void 0 : _pDrawingAnchor$get.top, paragraphAnchorLeft, false, deferredTopBottomAnchorDrawings.length > 0);
14008
14039
  }
14009
14040
  if (skeTablesInParagraph != null && skeTablesInParagraph.length > 0) {
14010
14041
  var _pDrawingAnchor$get2;
14011
14042
  needOpenNewPageByTableLayout = _updateAndPositionTable(ctx, lineTop, lineHeight, lastPage, column, section, skeTablesInParagraph, paragraphConfig.paragraphIndex, sectionBreakConfig, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get2 = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get2 === void 0 ? void 0 : _pDrawingAnchor$get2.top);
14012
14043
  }
14013
- const newLineTop = positionedCustomBlockOnly ? lineTop : calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage);
14044
+ const calculatedLineTop = positionedCustomBlockOnly ? lineTop : calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage);
14045
+ const previousTopBottomCustomBlockFlowBottom = deferredTopBottomAnchorDrawings.length > 0 ? paragraphConfig.topBottomCustomBlockFlowBottom : void 0;
14046
+ const newLineTop = previousTopBottomCustomBlockFlowBottom == null ? calculatedLineTop : Math.max(calculatedLineTop, previousTopBottomCustomBlockFlowBottom);
14014
14047
  if (lineHeight + newLineTop - section.height > LINE_LAYOUT_OVERFLOW_TOLERANCE && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
14015
14048
  setColumnFullState(column, true);
14016
14049
  _columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
@@ -14044,16 +14077,21 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
14044
14077
  }, column.width, lineIndex, isParagraphFirstShapedText, paragraphConfig, lastPage, headerPage, footerPage);
14045
14078
  column.lines.push(newLine);
14046
14079
  newLine.parent = column;
14047
- createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor);
14080
+ const blockAnchorTop = deferredTopBottomAnchorDrawings.length > 0 ? newLineTop : lineTop;
14081
+ createAndUpdateBlockAnchor(paragraphIndex, newLine, blockAnchorTop, pDrawingAnchor);
14082
+ if (deferredTopBottomAnchorDrawings.length > 0) {
14083
+ __updateAndPositionDrawings(ctx, newLineTop, lineHeight, column, deferredTopBottomAnchorDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, blockAnchorTop, paragraphAnchorLeft, true, true);
14084
+ __updateTopBottomCustomBlockFlowBottom(paragraphConfig, deferredTopBottomAnchorDrawings);
14085
+ }
14048
14086
  _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
14049
14087
  if (deferredInlineGroupAnchorDrawings.length > 0) {
14050
14088
  var _pDrawingAnchor$get3;
14051
14089
  __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, deferredInlineGroupAnchorDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get3 = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get3 === void 0 ? void 0 : _pDrawingAnchor$get3.top, paragraphAnchorLeft, true);
14052
14090
  }
14053
14091
  }
14054
- function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop, drawingAnchorLeft = 0, skipRelayoutCheck = false) {
14092
+ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop, drawingAnchorLeft = 0, skipRelayoutCheck = false, overwriteTopBottomPosition = false) {
14055
14093
  if (targetDrawings.length === 0) return;
14056
- const drawings = __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
14094
+ const drawings = __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
14057
14095
  if (drawings == null || drawings.size === 0) return;
14058
14096
  const floatObjects = [...drawings.values()].filter((drawing) => {
14059
14097
  const layoutType = drawing.drawingOrigin.layoutType;
@@ -14075,7 +14113,7 @@ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDra
14075
14113
  };
14076
14114
  });
14077
14115
  if (!skipRelayoutCheck) _reLayoutCheck(ctx, floatObjects, column, paragraphIndex);
14078
- __updateDrawingPosition(column, drawings);
14116
+ __updateDrawingPosition(column, drawings, overwriteTopBottomPosition);
14079
14117
  }
14080
14118
  function __updateWrapTablePosition(ctx, table, lineTop, lineHeight, column, paragraphIndex, drawingAnchorTop) {
14081
14119
  const wrapTablePosition = __getWrapTablePosition(table, column, lineTop, lineHeight, drawingAnchorTop);
@@ -14186,6 +14224,15 @@ function _getCustomBlockIdsInLine(line) {
14186
14224
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK) customBlockIds.push(glyph.drawingId);
14187
14225
  return customBlockIds;
14188
14226
  }
14227
+ function __updateTopBottomCustomBlockFlowBottom(paragraphConfig, drawings) {
14228
+ for (const drawing of drawings) {
14229
+ var _drawingOrigin$distB, _paragraphConfig$topB;
14230
+ const { drawingOrigin } = drawing;
14231
+ if (drawingOrigin.layoutType !== _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM || drawingOrigin.behindDoc === _univerjs_core.BooleanNumber.TRUE) continue;
14232
+ const bottom = drawing.aTop + drawing.height + ((_drawingOrigin$distB = drawingOrigin.distB) !== null && _drawingOrigin$distB !== void 0 ? _drawingOrigin$distB : 0);
14233
+ paragraphConfig.topBottomCustomBlockFlowBottom = Math.max((_paragraphConfig$topB = paragraphConfig.topBottomCustomBlockFlowBottom) !== null && _paragraphConfig$topB !== void 0 ? _paragraphConfig$topB : Number.NEGATIVE_INFINITY, bottom);
14234
+ }
14235
+ }
14189
14236
  function __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings) {
14190
14237
  return __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings).length > 0;
14191
14238
  }
@@ -14417,7 +14464,7 @@ function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitc
14417
14464
  lineSpacingApply: exactLineSpacingApply
14418
14465
  };
14419
14466
  }
14420
- function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnchorTop, paragraphNonInlineSkeDrawings) {
14467
+ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId = "", blockAnchorTop, paragraphNonInlineSkeDrawings) {
14421
14468
  var _line$parent, _section$top;
14422
14469
  const column = line.parent;
14423
14470
  const section = column === null || column === void 0 ? void 0 : column.parent;
@@ -14429,6 +14476,7 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14429
14476
  const sectionTop = (_section$top = section === null || section === void 0 ? void 0 : section.top) !== null && _section$top !== void 0 ? _section$top : 0;
14430
14477
  const lineTop = sectionTop + top;
14431
14478
  for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0) {
14479
+ var _viewport$width, _viewport$height, _viewport$offsetLeft;
14432
14480
  const { drawingId } = glyph;
14433
14481
  if (drawingId == null) continue;
14434
14482
  const drawing = paragraphInlineSkeDrawings === null || paragraphInlineSkeDrawings === void 0 ? void 0 : paragraphInlineSkeDrawings.get(drawingId);
@@ -14438,7 +14486,19 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14438
14486
  const { size, angle } = docTransform;
14439
14487
  const { width = 0, height = 0 } = size;
14440
14488
  const glyphHeight = glyph.bBox.bd + glyph.bBox.ba;
14441
- drawing.aLeft = column.left + divide.left + divide.paddingLeft + glyph.left + .5 * glyph.width - .5 * width || 0;
14489
+ const glyphLeft = divide.left + divide.paddingLeft + glyph.left;
14490
+ const blockLeft = column.left + glyphLeft;
14491
+ const viewport = getDocsCustomBlockRenderViewport(unitId, drawingId, {
14492
+ blockLeft,
14493
+ fallbackHeight: height,
14494
+ fallbackWidth: width,
14495
+ pageMarginLeft: page.marginLeft,
14496
+ pageMarginRight: page.marginRight,
14497
+ pageWidth: page.pageWidth
14498
+ });
14499
+ const drawingWidth = (_viewport$width = viewport === null || viewport === void 0 ? void 0 : viewport.width) !== null && _viewport$width !== void 0 ? _viewport$width : width;
14500
+ const drawingHeight = (_viewport$height = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _viewport$height !== void 0 ? _viewport$height : height;
14501
+ drawing.aLeft = viewport ? blockLeft + ((_viewport$offsetLeft = viewport.offsetLeft) !== null && _viewport$offsetLeft !== void 0 ? _viewport$offsetLeft : 0) : blockLeft + .5 * glyph.width - .5 * drawingWidth || 0;
14442
14502
  if (glyph.width > divide.width) {
14443
14503
  var _paragraphNonInlineSk;
14444
14504
  for (const positionedDrawing of (_paragraphNonInlineSk = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.values()) !== null && _paragraphNonInlineSk !== void 0 ? _paragraphNonInlineSk : []) {
@@ -14448,17 +14508,25 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14448
14508
  const lineBottom = lineTop + lineHeight;
14449
14509
  if (positionedDrawing.aTop >= lineBottom || positionedBottom <= lineTop) continue;
14450
14510
  const positionedRight = positionedDrawing.aLeft + positionedDrawing.width;
14451
- const drawingRight = drawing.aLeft + width;
14511
+ const drawingRight = drawing.aLeft + drawingWidth;
14452
14512
  if (positionedDrawing.aLeft < drawingRight && positionedRight > drawing.aLeft) {
14453
14513
  var _positionedOrigin$dis;
14454
14514
  drawing.aLeft = Math.max(drawing.aLeft, positionedDrawing.aLeft + positionedDrawing.width + ((_positionedOrigin$dis = positionedOrigin.distR) !== null && _positionedOrigin$dis !== void 0 ? _positionedOrigin$dis : 0));
14455
14515
  }
14456
14516
  }
14457
14517
  }
14458
- drawing.aTop = lineTop + lineHeight - .5 * glyphHeight - .5 * height - marginBottom;
14459
- drawing.width = width;
14460
- drawing.height = height;
14518
+ drawing.width = drawingWidth;
14519
+ drawing.height = drawingHeight;
14520
+ drawing.aTop = lineTop + lineHeight - .5 * glyphHeight - .5 * drawingHeight - marginBottom;
14461
14521
  drawing.angle = angle;
14522
+ drawing.customBlockRenderViewport = viewport ? {
14523
+ bleedLeft: viewport.bleedLeft,
14524
+ bleedWidth: viewport.bleedWidth,
14525
+ contentHeight: viewport.contentHeight,
14526
+ contentWidth: viewport.contentWidth,
14527
+ height: viewport.height,
14528
+ viewportHeight: viewport.viewportHeight
14529
+ } : void 0;
14462
14530
  drawing.isPageBreak = isPageBreak;
14463
14531
  drawing.lineTop = lineTop;
14464
14532
  drawing.columnLeft = column.left;
@@ -14468,7 +14536,7 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
14468
14536
  }
14469
14537
  page.skeDrawings = new Map([...page.skeDrawings, ...drawings]);
14470
14538
  }
14471
- function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = [], blockAnchorLeft = 0) {
14539
+ function __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = [], blockAnchorLeft = 0, normalizeTraditionalColumnAnchor = true) {
14472
14540
  var _column$parent3;
14473
14541
  const page = (_column$parent3 = column.parent) === null || _column$parent3 === void 0 ? void 0 : _column$parent3.parent;
14474
14542
  if (page == null || needPositionDrawings.length === 0) return;
@@ -14476,22 +14544,42 @@ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShape
14476
14544
  const isPageBreak = __checkPageBreak(column);
14477
14545
  if (isPageBreak && !isParagraphFirstShapedText) return;
14478
14546
  for (const drawing of needPositionDrawings) {
14479
- var _getPositionHorizon2, _getPositionVertical2;
14547
+ var _ctx$dataModel$getUni, _ctx$dataModel$getUni2, _ctx$dataModel, _viewport$width2, _viewport$height2, _getPositionHorizon2, _getPositionVertical2;
14480
14548
  const { drawingOrigin } = drawing;
14481
14549
  if (!drawingOrigin) continue;
14482
14550
  const { docTransform } = drawingOrigin;
14483
14551
  const { positionH, positionV, size, angle } = docTransform;
14484
- const { width = 0, height = 0 } = size;
14485
- let aLeft = (_getPositionHorizon2 = getPositionHorizon(positionH, column, page, width, isPageBreak)) !== null && _getPositionHorizon2 !== void 0 ? _getPositionHorizon2 : 0;
14552
+ const { width, height } = size;
14553
+ const fallbackWidth = width !== null && width !== void 0 ? width : 0;
14554
+ const fallbackHeight = height !== null && height !== void 0 ? height : 0;
14555
+ const viewport = drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM ? getDocsCustomBlockRenderViewport((_ctx$dataModel$getUni = (_ctx$dataModel$getUni2 = (_ctx$dataModel = ctx.dataModel).getUnitId) === null || _ctx$dataModel$getUni2 === void 0 ? void 0 : _ctx$dataModel$getUni2.call(_ctx$dataModel)) !== null && _ctx$dataModel$getUni !== void 0 ? _ctx$dataModel$getUni : "", drawing.drawingId, {
14556
+ fallbackHeight,
14557
+ fallbackWidth,
14558
+ pageMarginLeft: page.marginLeft,
14559
+ pageMarginRight: page.marginRight,
14560
+ pageWidth: page.pageWidth
14561
+ }) : null;
14562
+ const drawingWidth = (_viewport$width2 = viewport === null || viewport === void 0 ? void 0 : viewport.width) !== null && _viewport$width2 !== void 0 ? _viewport$width2 : fallbackWidth;
14563
+ const drawingHeight = (_viewport$height2 = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _viewport$height2 !== void 0 ? _viewport$height2 : fallbackHeight;
14564
+ let aLeft = (_getPositionHorizon2 = getPositionHorizon(positionH, column, page, drawingWidth, isPageBreak)) !== null && _getPositionHorizon2 !== void 0 ? _getPositionHorizon2 : 0;
14486
14565
  if (positionH.relativeFrom === _univerjs_core.ObjectRelativeFromH.COLUMN && blockAnchorLeft > 0) {
14487
14566
  const renderedColumnOrigin = isPageBreak ? 0 : column.left || page.marginLeft;
14488
14567
  aLeft += blockAnchorLeft - renderedColumnOrigin;
14568
+ if (normalizeTraditionalColumnAnchor && ctx.dataModel.documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL && positionV.relativeFrom === _univerjs_core.ObjectRelativeFromV.PARAGRAPH) aLeft -= page.marginLeft;
14489
14569
  }
14490
14570
  drawing.aLeft = aLeft;
14491
- drawing.aTop = (_getPositionVertical2 = getPositionVertical(positionV, page, lineTop, lineHeight, height, blockAnchorTop, isPageBreak)) !== null && _getPositionVertical2 !== void 0 ? _getPositionVertical2 : 0;
14492
- drawing.width = width;
14493
- drawing.height = height;
14571
+ drawing.aTop = (_getPositionVertical2 = getPositionVertical(positionV, page, lineTop, lineHeight, drawingHeight, blockAnchorTop, isPageBreak)) !== null && _getPositionVertical2 !== void 0 ? _getPositionVertical2 : 0;
14572
+ drawing.width = drawingWidth;
14573
+ drawing.height = drawingHeight;
14494
14574
  drawing.angle = angle;
14575
+ drawing.customBlockRenderViewport = viewport ? {
14576
+ bleedLeft: viewport.bleedLeft,
14577
+ bleedWidth: viewport.bleedWidth,
14578
+ contentHeight: viewport.contentHeight,
14579
+ contentWidth: viewport.contentWidth,
14580
+ height: viewport.height,
14581
+ viewportHeight: viewport.viewportHeight
14582
+ } : void 0;
14495
14583
  drawing.initialState = true;
14496
14584
  drawing.columnLeft = column.left;
14497
14585
  drawing.lineTop = lineTop;
@@ -14502,16 +14590,18 @@ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShape
14502
14590
  }
14503
14591
  return drawings;
14504
14592
  }
14505
- function __updateDrawingPosition(column, drawings) {
14593
+ function __updateDrawingPosition(column, drawings, overwriteTopBottomPosition = false) {
14506
14594
  var _column$parent4;
14507
14595
  const page = (_column$parent4 = column.parent) === null || _column$parent4 === void 0 ? void 0 : _column$parent4.parent;
14508
14596
  if (drawings == null || drawings.size === 0 || page == null) return;
14509
14597
  for (const drawing of drawings.values()) {
14510
14598
  const originDrawing = page.skeDrawings.get(drawing.drawingId);
14511
- if (originDrawing) if (originDrawing.drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) {
14599
+ if (originDrawing) if (originDrawing.drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) if (overwriteTopBottomPosition) page.skeDrawings.set(drawing.drawingId, drawing);
14600
+ else {
14512
14601
  const lowerDrawing = originDrawing.aTop > drawing.aTop ? originDrawing : drawing;
14513
14602
  page.skeDrawings.set(drawing.drawingId, lowerDrawing);
14514
- } else page.skeDrawings.set(drawing.drawingId, drawing);
14603
+ }
14604
+ else page.skeDrawings.set(drawing.drawingId, drawing);
14515
14605
  else page.skeDrawings.set(drawing.drawingId, drawing);
14516
14606
  }
14517
14607
  }
@@ -14840,7 +14930,10 @@ function updateInlineDrawingCoordsAndBorder(ctx, pages) {
14840
14930
  const affectInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphInlineSkeDrawings;
14841
14931
  const affectNonInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphNonInlineSkeDrawings;
14842
14932
  const drawingAnchor = (_ctx$skeletonResource = ctx.skeletonResourceReference) === null || _ctx$skeletonResource === void 0 || (_ctx$skeletonResource = _ctx$skeletonResource.drawingAnchor) === null || _ctx$skeletonResource === void 0 || (_ctx$skeletonResource = _ctx$skeletonResource.get(segmentId)) === null || _ctx$skeletonResource === void 0 ? void 0 : _ctx$skeletonResource.get(line.paragraphIndex);
14843
- if (affectInlineDrawings && affectInlineDrawings.size > 0) updateInlineDrawingPosition(line, affectInlineDrawings, drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top, affectNonInlineDrawings);
14933
+ if (affectInlineDrawings && affectInlineDrawings.size > 0) {
14934
+ var _ctx$dataModel$getUni, _ctx$dataModel$getUni2, _ctx$dataModel;
14935
+ updateInlineDrawingPosition(line, affectInlineDrawings, (_ctx$dataModel$getUni = (_ctx$dataModel$getUni2 = (_ctx$dataModel = ctx.dataModel).getUnitId) === null || _ctx$dataModel$getUni2 === void 0 ? void 0 : _ctx$dataModel$getUni2.call(_ctx$dataModel)) !== null && _ctx$dataModel$getUni !== void 0 ? _ctx$dataModel$getUni : "", drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top, affectNonInlineDrawings);
14936
+ }
14844
14937
  const paragraphStyle = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphStyle;
14845
14938
  const paragraphBackgroundColor = paragraphStyle === null || paragraphStyle === void 0 || (_paragraphStyle$shadi = paragraphStyle.shading) === null || _paragraphStyle$shadi === void 0 ? void 0 : _paragraphStyle$shadi.backgroundColor;
14846
14939
  if (paragraphBackgroundColor) line.backgroundColor = paragraphBackgroundColor;
@@ -16169,22 +16262,66 @@ function _isDocxColumnBreakVisuallyBlankColumn(column) {
16169
16262
  function _hasOnlyCustomBlockGlyphs(glyphs) {
16170
16263
  return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK);
16171
16264
  }
16172
- function _mergeAdjacentCustomBlockShapedTexts(shapedTextList) {
16265
+ function _mergeAdjacentCustomBlockShapedTexts(shapedTextList, customBlockDrawings) {
16173
16266
  const mergedShapedTextList = [];
16174
- for (const shapedText of shapedTextList) {
16175
- const lastShapedText = mergedShapedTextList[mergedShapedTextList.length - 1];
16176
- if (lastShapedText && _hasOnlyCustomBlockGlyphs(lastShapedText.glyphs) && _hasOnlyCustomBlockGlyphs(shapedText.glyphs)) {
16177
- lastShapedText.text += shapedText.text;
16178
- lastShapedText.glyphs.push(...shapedText.glyphs);
16179
- lastShapedText.breakPointType = shapedText.breakPointType;
16180
- continue;
16267
+ for (const originShapedText of shapedTextList) {
16268
+ const splitShapedTexts = _splitTopBottomCustomBlockShapedText(originShapedText, customBlockDrawings);
16269
+ for (const shapedText of splitShapedTexts) {
16270
+ const lastShapedText = mergedShapedTextList[mergedShapedTextList.length - 1];
16271
+ if (lastShapedText && _hasOnlyCustomBlockGlyphs(lastShapedText.glyphs) && _hasOnlyCustomBlockGlyphs(shapedText.glyphs) && !_hasTopBottomCustomBlockGlyph(lastShapedText.glyphs, customBlockDrawings) && !_hasTopBottomCustomBlockGlyph(shapedText.glyphs, customBlockDrawings)) {
16272
+ lastShapedText.text += shapedText.text;
16273
+ lastShapedText.glyphs.push(...shapedText.glyphs);
16274
+ lastShapedText.breakPointType = shapedText.breakPointType;
16275
+ continue;
16276
+ }
16277
+ mergedShapedTextList.push({
16278
+ ...shapedText,
16279
+ glyphs: [...shapedText.glyphs]
16280
+ });
16181
16281
  }
16182
- mergedShapedTextList.push({
16282
+ }
16283
+ return mergedShapedTextList;
16284
+ }
16285
+ function _splitTopBottomCustomBlockShapedText(shapedText, customBlockDrawings) {
16286
+ const splitShapedTexts = [];
16287
+ let pendingGlyphs = [];
16288
+ let pendingText = "";
16289
+ let textOffset = 0;
16290
+ const flushPending = () => {
16291
+ if (pendingGlyphs.length === 0) return;
16292
+ splitShapedTexts.push({
16183
16293
  ...shapedText,
16184
- glyphs: [...shapedText.glyphs]
16294
+ text: pendingText,
16295
+ glyphs: pendingGlyphs
16185
16296
  });
16297
+ pendingGlyphs = [];
16298
+ pendingText = "";
16299
+ };
16300
+ for (const glyph of shapedText.glyphs) {
16301
+ const glyphText = shapedText.text.slice(textOffset, textOffset + glyph.count);
16302
+ textOffset += glyph.count;
16303
+ if (_isTopBottomCustomBlockGlyph(glyph, customBlockDrawings)) {
16304
+ flushPending();
16305
+ splitShapedTexts.push({
16306
+ ...shapedText,
16307
+ text: glyphText,
16308
+ glyphs: [glyph]
16309
+ });
16310
+ continue;
16311
+ }
16312
+ pendingGlyphs.push(glyph);
16313
+ pendingText += glyphText;
16186
16314
  }
16187
- return mergedShapedTextList;
16315
+ flushPending();
16316
+ return splitShapedTexts.length > 0 ? splitShapedTexts : [shapedText];
16317
+ }
16318
+ function _hasTopBottomCustomBlockGlyph(glyphs, customBlockDrawings) {
16319
+ return glyphs.some((glyph) => _isTopBottomCustomBlockGlyph(glyph, customBlockDrawings));
16320
+ }
16321
+ function _isTopBottomCustomBlockGlyph(glyph, customBlockDrawings) {
16322
+ var _customBlockDrawings$;
16323
+ if (glyph.streamType !== _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK || glyph.drawingId == null) return false;
16324
+ return ((_customBlockDrawings$ = customBlockDrawings.get(glyph.drawingId)) === null || _customBlockDrawings$ === void 0 ? void 0 : _customBlockDrawings$.drawingOrigin.layoutType) === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM;
16188
16325
  }
16189
16326
  function _getListLevelAncestors(bullet, listLevel) {
16190
16327
  if (!bullet || !listLevel) return;
@@ -16367,7 +16504,7 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
16367
16504
  let allPages = [curPage];
16368
16505
  let isParagraphFirstShapedText = true;
16369
16506
  let shapedTextOffset = 0;
16370
- for (const [_index, { text, glyphs, breakPointType }] of _mergeAdjacentCustomBlockShapedTexts(shapedTextList).entries()) {
16507
+ for (const [_index, { text, glyphs, breakPointType }] of _mergeAdjacentCustomBlockShapedTexts(shapedTextList, paragraphNonInlineSkeDrawingsByBlockId).entries()) {
16371
16508
  const textStartIndex = paragraphNode.startIndex + shapedTextOffset;
16372
16509
  const textGlyphCount = _glyphCount(glyphs);
16373
16510
  const textEndIndex = textStartIndex + textGlyphCount;
@@ -17061,10 +17198,15 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
17061
17198
  const { blockId } = customBlock;
17062
17199
  const drawingOrigin = drawings[blockId];
17063
17200
  if ((drawingOrigin === null || drawingOrigin === void 0 ? void 0 : drawingOrigin.layoutType) === _univerjs_core.PositionedObjectLayoutType.INLINE) {
17201
+ var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3, _boundingBox$height, _boundingBox$width, _ref, _viewport$layoutWidth, _viewport$height;
17064
17202
  const { angle } = drawingOrigin.docTransform;
17065
17203
  const { width = 0, height = 0 } = drawingOrigin.docTransform.size;
17066
17204
  const boundingBox = getBoundingBox(angle, 0, width, 0, height);
17067
- newGlyph = createSkeletonCustomBlockGlyph(config, boundingBox.width, boundingBox.height, drawingOrigin.drawingId);
17205
+ const viewport = getDocsCustomBlockRenderViewport((_viewModel$getDataMod = (_viewModel$getDataMod2 = (_viewModel$getDataMod3 = viewModel.getDataModel()).getUnitId) === null || _viewModel$getDataMod2 === void 0 ? void 0 : _viewModel$getDataMod2.call(_viewModel$getDataMod3)) !== null && _viewModel$getDataMod !== void 0 ? _viewModel$getDataMod : "", drawingOrigin.drawingId, {
17206
+ fallbackHeight: (_boundingBox$height = boundingBox.height) !== null && _boundingBox$height !== void 0 ? _boundingBox$height : 0,
17207
+ fallbackWidth: (_boundingBox$width = boundingBox.width) !== null && _boundingBox$width !== void 0 ? _boundingBox$width : 0
17208
+ });
17209
+ newGlyph = createSkeletonCustomBlockGlyph(config, (_ref = (_viewport$layoutWidth = viewport === null || viewport === void 0 ? void 0 : viewport.layoutWidth) !== null && _viewport$layoutWidth !== void 0 ? _viewport$layoutWidth : viewport === null || viewport === void 0 ? void 0 : viewport.width) !== null && _ref !== void 0 ? _ref : boundingBox.width, (_viewport$height = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _viewport$height !== void 0 ? _viewport$height : boundingBox.height, drawingOrigin.drawingId);
17068
17210
  } else if (drawingOrigin != null) newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
17069
17211
  }
17070
17212
  if (newGlyph == null) newGlyph = createSkeletonLetterGlyph(char, config);
@@ -26555,7 +26697,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
26555
26697
  //#endregion
26556
26698
  //#region package.json
26557
26699
  var name = "@univerjs/engine-render";
26558
- var version = "1.0.0-alpha.1";
26700
+ var version = "1.0.0-insiders.20260701-0ef51b0";
26559
26701
 
26560
26702
  //#endregion
26561
26703
  //#region src/config/config.ts
@@ -27909,8 +28051,8 @@ var Transformer = class extends _univerjs_core.Disposable {
27909
28051
  }
27910
28052
  _getOutlinePosition(width, height, borderSpacing, borderStrokeWidth) {
27911
28053
  return {
27912
- left: borderSpacing - borderStrokeWidth,
27913
- top: -borderSpacing - this.borderStrokeWidth,
28054
+ left: -borderSpacing - borderStrokeWidth,
28055
+ top: -borderSpacing - borderStrokeWidth,
27914
28056
  width: width + borderSpacing * 2,
27915
28057
  height: height + borderSpacing * 2
27916
28058
  };
@@ -27986,7 +28128,7 @@ var Transformer = class extends _univerjs_core.Disposable {
27986
28128
  top += -borderSpacing - borderStrokeWidth;
27987
28129
  break;
27988
28130
  case "__SpreadsheetTransformerResizeLM__":
27989
- left += borderSpacing - borderStrokeWidth;
28131
+ left += -borderSpacing - borderStrokeWidth;
27990
28132
  top += height / 2 - longEdge / 2;
27991
28133
  break;
27992
28134
  case "__SpreadsheetTransformerResizeRM__":
@@ -27994,7 +28136,7 @@ var Transformer = class extends _univerjs_core.Disposable {
27994
28136
  top += height / 2 - longEdge / 2;
27995
28137
  break;
27996
28138
  case "__SpreadsheetTransformerResizeLB__":
27997
- left += -this.borderSpacing - borderStrokeWidth;
28139
+ left += -borderSpacing - borderStrokeWidth;
27998
28140
  top += height + borderSpacing - borderStrokeWidth - longEdge;
27999
28141
  break;
28000
28142
  case "__SpreadsheetTransformerResizeCB__":
@@ -28038,7 +28180,7 @@ var Transformer = class extends _univerjs_core.Disposable {
28038
28180
  top += -borderSpacing - borderStrokeWidth;
28039
28181
  break;
28040
28182
  case "__SpreadsheetTransformerResizeLM__":
28041
- left += borderSpacing - borderStrokeWidth;
28183
+ left += -borderSpacing - borderStrokeWidth;
28042
28184
  top += height / 2;
28043
28185
  break;
28044
28186
  case "__SpreadsheetTransformerResizeRM__":
@@ -28046,7 +28188,7 @@ var Transformer = class extends _univerjs_core.Disposable {
28046
28188
  top += height / 2;
28047
28189
  break;
28048
28190
  case "__SpreadsheetTransformerResizeLB__":
28049
- left += -this.borderSpacing - borderStrokeWidth;
28191
+ left += -borderSpacing - borderStrokeWidth;
28050
28192
  top += height + borderSpacing - borderStrokeWidth;
28051
28193
  break;
28052
28194
  case "__SpreadsheetTransformerResizeCB__":
@@ -29433,10 +29575,11 @@ let RenderUnit = class RenderUnit extends _univerjs_core.Disposable {
29433
29575
  if (((_init$createUnitOptio = init.createUnitOptions) === null || _init$createUnitOptio === void 0 ? void 0 : _init$createUnitOptio.makeCurrent) === false) this.deactivate();
29434
29576
  }
29435
29577
  dispose() {
29436
- this._injector.dispose();
29437
- super.dispose();
29578
+ if (this._disposed) return;
29438
29579
  this._activated$.next(false);
29439
29580
  this._activated$.complete();
29581
+ super.dispose();
29582
+ this._injector.dispose();
29440
29583
  this._renderContext.unit = null;
29441
29584
  this._renderContext.components.clear();
29442
29585
  }
@@ -29447,7 +29590,10 @@ let RenderUnit = class RenderUnit extends _univerjs_core.Disposable {
29447
29590
  * Get a dependency from the RenderUnit's injector.
29448
29591
  */
29449
29592
  with(dependency) {
29450
- return this._injector.get(dependency);
29593
+ return this._injector.get(dependency, _univerjs_core.LookUp.SELF);
29594
+ }
29595
+ getInjector() {
29596
+ return this._injector;
29451
29597
  }
29452
29598
  /**
29453
29599
  * Add render dependencies to the RenderUnit's injector. Note that the dependencies would be initialized immediately
@@ -29458,15 +29604,16 @@ let RenderUnit = class RenderUnit extends _univerjs_core.Disposable {
29458
29604
  }
29459
29605
  _initDependencies(dependencies) {
29460
29606
  const j = this._injector;
29461
- dependencies.forEach((dep) => {
29607
+ const uniqueDependencies = dedupeRenderDependencies(dependencies);
29608
+ uniqueDependencies.forEach((dep) => {
29462
29609
  const [identifier, implOrNull] = Array.isArray(dep) ? dep : [dep, null];
29463
29610
  if (!implOrNull) j.add([identifier, { useFactory: () => j.createInstance(identifier, this._renderContext) }]);
29464
29611
  else if ((0, _univerjs_core.isClassDependencyItem)(implOrNull)) j.add([identifier, { useFactory: () => j.createInstance(implOrNull.useClass, this._renderContext) }]);
29465
29612
  else throw new Error("[RenderUnit]: render dependency could only be an class!");
29466
29613
  });
29467
- dependencies.forEach((dep) => {
29614
+ uniqueDependencies.forEach((dep) => {
29468
29615
  const [identifier] = Array.isArray(dep) ? dep : [dep, null];
29469
- j.get(identifier);
29616
+ j.get(identifier, _univerjs_core.LookUp.SELF);
29470
29617
  });
29471
29618
  }
29472
29619
  getRenderContext() {
@@ -29480,6 +29627,20 @@ let RenderUnit = class RenderUnit extends _univerjs_core.Disposable {
29480
29627
  }
29481
29628
  };
29482
29629
  RenderUnit = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector))], RenderUnit);
29630
+ function dedupeRenderDependencies(dependencies) {
29631
+ const seen = /* @__PURE__ */ new Set();
29632
+ return dependencies.filter((dependency) => {
29633
+ const key = getRenderDependencyIdentifierKey$1(Array.isArray(dependency) ? dependency[0] : dependency);
29634
+ if (seen.has(key)) return false;
29635
+ seen.add(key);
29636
+ return true;
29637
+ });
29638
+ }
29639
+ function getRenderDependencyIdentifierKey$1(identifier) {
29640
+ const decoratorName = identifier === null || identifier === void 0 ? void 0 : identifier.decoratorName;
29641
+ if (typeof decoratorName === "string" && decoratorName) return `identifier:${decoratorName}`;
29642
+ return identifier;
29643
+ }
29483
29644
 
29484
29645
  //#endregion
29485
29646
  //#region src/render-manager/render-manager.service.ts
@@ -29520,10 +29681,11 @@ let RenderManagerService = class RenderManagerService extends _univerjs_core.Dis
29520
29681
  registerRenderModules(type, deps) {
29521
29682
  if (!this._renderDependencies.has(type)) this._renderDependencies.set(type, []);
29522
29683
  const dependencies = this._renderDependencies.get(type);
29523
- dependencies.push(...deps);
29524
- for (const [_, render] of this._renderMap) if (render.type === type) this._tryAddRenderDependencies(render, deps);
29684
+ const registeredDeps = deps.filter((dep) => !hasRenderDependency(dependencies, dep));
29685
+ dependencies.push(...registeredDeps);
29686
+ for (const [_, render] of this._renderMap) if (render.type === type) this._tryAddRenderDependencies(render, registeredDeps);
29525
29687
  return (0, _univerjs_core.toDisposable)(() => {
29526
- deps.forEach((dep) => (0, _univerjs_core.remove)(dependencies, dep));
29688
+ registeredDeps.forEach((dep) => (0, _univerjs_core.remove)(dependencies, dep));
29527
29689
  });
29528
29690
  }
29529
29691
  /**
@@ -29534,6 +29696,7 @@ let RenderManagerService = class RenderManagerService extends _univerjs_core.Dis
29534
29696
  registerRenderModule(type, depCtor) {
29535
29697
  if (!this._renderDependencies.has(type)) this._renderDependencies.set(type, []);
29536
29698
  const dependencies = this._renderDependencies.get(type);
29699
+ if (hasRenderDependency(dependencies, depCtor)) return (0, _univerjs_core.toDisposable)(() => {});
29537
29700
  dependencies.push(depCtor);
29538
29701
  for (const [_, render] of this._renderMap) if (render.type === type) this._tryAddRenderDependencies(render, [depCtor]);
29539
29702
  return (0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(dependencies, depCtor));
@@ -29566,7 +29729,9 @@ let RenderManagerService = class RenderManagerService extends _univerjs_core.Dis
29566
29729
  * @returns renderUnit:IRender
29567
29730
  */
29568
29731
  createRender(unitId, createUnitOptions) {
29569
- const renderer = this._createRender(unitId, this._injector.createInstance(Engine, unitId, void 0), true, createUnitOptions);
29732
+ var _createUnitOptions$re;
29733
+ const parentInjector = (_createUnitOptions$re = createUnitOptions === null || createUnitOptions === void 0 ? void 0 : createUnitOptions.renderParentInjector) !== null && _createUnitOptions$re !== void 0 ? _createUnitOptions$re : this._injector;
29734
+ const renderer = this._createRender(unitId, parentInjector.createInstance(Engine, unitId, void 0), (createUnitOptions === null || createUnitOptions === void 0 ? void 0 : createUnitOptions.embeddedRender) !== true, createUnitOptions, parentInjector);
29570
29735
  this._renderCreated$.next(renderer);
29571
29736
  return renderer;
29572
29737
  }
@@ -29590,7 +29755,7 @@ let RenderManagerService = class RenderManagerService extends _univerjs_core.Dis
29590
29755
  * @param isMainScene
29591
29756
  * @returns renderUnit:IRender
29592
29757
  */
29593
- _createRender(unitId, engine, isMainScene = true, createUnitOptions) {
29758
+ _createRender(unitId, engine, isMainScene = true, createUnitOptions, parentInjector = this._injector) {
29594
29759
  const existItem = this.getRenderById(unitId);
29595
29760
  let shouldDestroyEngine = true;
29596
29761
  if (existItem != null) {
@@ -29607,7 +29772,7 @@ let RenderManagerService = class RenderManagerService extends _univerjs_core.Dis
29607
29772
  if (unit) {
29608
29773
  const type = this._univerInstanceService.getUnitType(unitId);
29609
29774
  const ctorOfDeps = this._getRenderDepsByType(type);
29610
- renderUnit = this._injector.createInstance(RenderUnit, {
29775
+ renderUnit = parentInjector.createInstance(RenderUnit, {
29611
29776
  unit,
29612
29777
  engine,
29613
29778
  scene,
@@ -29615,7 +29780,16 @@ let RenderManagerService = class RenderManagerService extends _univerjs_core.Dis
29615
29780
  createUnitOptions
29616
29781
  });
29617
29782
  this._addRenderUnit(unitId, renderUnit);
29618
- this._tryAddRenderDependencies(renderUnit, ctorOfDeps);
29783
+ try {
29784
+ this._tryAddRenderDependencies(renderUnit, ctorOfDeps);
29785
+ } catch (error) {
29786
+ try {
29787
+ this._disposeItem(renderUnit);
29788
+ } finally {
29789
+ this._renderMap.delete(unitId);
29790
+ }
29791
+ throw error;
29792
+ }
29619
29793
  } else {
29620
29794
  renderUnit = {
29621
29795
  isThumbNail: true,
@@ -29678,6 +29852,18 @@ RenderManagerService = __decorate([
29678
29852
  __decorateParam(1, _univerjs_core.IUniverInstanceService),
29679
29853
  __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))
29680
29854
  ], RenderManagerService);
29855
+ function hasRenderDependency(dependencies, dep) {
29856
+ const key = getRenderDependencyIdentifierKey(getRenderDependencyIdentifier(dep));
29857
+ return dependencies.some((registered) => getRenderDependencyIdentifierKey(getRenderDependencyIdentifier(registered)) === key);
29858
+ }
29859
+ function getRenderDependencyIdentifier(dep) {
29860
+ return Array.isArray(dep) ? dep[0] : dep;
29861
+ }
29862
+ function getRenderDependencyIdentifierKey(identifier) {
29863
+ const decoratorName = identifier.decoratorName;
29864
+ if (typeof decoratorName === "string" && decoratorName) return `identifier:${decoratorName}`;
29865
+ return identifier;
29866
+ }
29681
29867
  const IRenderManagerService = (0, _univerjs_core.createIdentifier)("engine-render.render-manager.service");
29682
29868
  function isDisposable(thing) {
29683
29869
  return !!thing && typeof thing.dispose === "function";
@@ -31033,6 +31219,7 @@ exports.getCurrentScrollXY = getCurrentScrollXY;
31033
31219
  exports.getCurrentTypeOfRenderer = getCurrentTypeOfRenderer;
31034
31220
  exports.getDPI = getDPI;
31035
31221
  exports.getDevicePixelRatio = getDevicePixelRatio;
31222
+ exports.getDocsCustomBlockRenderViewport = getDocsCustomBlockRenderViewport;
31036
31223
  exports.getDocsSkeletonPageSize = getDocsSkeletonPageSize;
31037
31224
  exports.getDocsTableRenderViewport = getDocsTableRenderViewport;
31038
31225
  exports.getDocumentSkeletonColumnPagePathInfo = getDocumentSkeletonColumnPagePathInfo;
@@ -31113,6 +31300,7 @@ exports.renderTextWatermark = renderTextWatermark;
31113
31300
  exports.renderUserInfoWatermark = renderUserInfoWatermark;
31114
31301
  exports.renderWatermark = renderWatermark;
31115
31302
  exports.requestNewFrame = requestNewFrame;
31303
+ exports.setDocsCustomBlockRenderViewportProvider = setDocsCustomBlockRenderViewportProvider;
31116
31304
  exports.setDocsTableRenderViewportProvider = setDocsTableRenderViewportProvider;
31117
31305
  exports.setLineType = setLineType;
31118
31306
  exports.sheetContentViewportKeys = sheetContentViewportKeys;