@univerjs/engine-render 0.4.0-alpha.2 → 0.4.0-experimental.20241017-da434a2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -7255,6 +7255,7 @@ function getBulletParagraphTextStyle(bullet, viewModel) {
7255
7255
  return (_a10 = viewModel.getDataModel().getBulletPresetList()[listType].nestingLevel[0].paragraphProperties) == null ? void 0 : _a10.textStyle;
7256
7256
  }
7257
7257
  __name(getBulletParagraphTextStyle, "getBulletParagraphTextStyle");
7258
+ const DEFAULT_TEXT_RUN = { ts: {}, st: 0, ed: 0 };
7258
7259
  function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
7259
7260
  const {
7260
7261
  gridType = GridType.LINES,
@@ -7268,10 +7269,10 @@ function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfi
7268
7269
  marginLeft = 0,
7269
7270
  localeService,
7270
7271
  renderConfig = {}
7271
- } = 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;
7272
+ } = sectionBreakConfig, { paragraphStyle = {}, bullet } = paragraph, { isRenderStyle } = renderConfig, { startIndex } = paragraphNode, originTextRun = viewModel.getTextRun(index2 + startIndex), textRun = isRenderStyle === BooleanNumber.FALSE ? DEFAULT_TEXT_RUN : originTextRun != null ? originTextRun : DEFAULT_TEXT_RUN, 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 || !!bullet, { st, ed } = textRun;
7272
7273
  let { ts: textStyle = {} } = textRun;
7273
7274
  const cache = fontCreateConfigCache.getValue(st, ed);
7274
- if (cache && !hasAddonStyle)
7275
+ if (cache && !hasAddonStyle && originTextRun)
7275
7276
  return cache;
7276
7277
  const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle, bulletTextStyle = bullet ? getBulletParagraphTextStyle(bullet, viewModel) : null;
7277
7278
  textStyle = {
@@ -7292,7 +7293,7 @@ function getFontCreateConfig(index2, viewModel, paragraphNode, sectionBreakConfi
7292
7293
  snapToGrid,
7293
7294
  pageWidth
7294
7295
  };
7295
- return hasAddonStyle || fontCreateConfigCache.setValue(st, ed, result), result;
7296
+ return !hasAddonStyle && originTextRun && fontCreateConfigCache.setValue(st, ed, result), result;
7296
7297
  }
7297
7298
  __name(getFontCreateConfig, "getFontCreateConfig");
7298
7299
  function getNullSkeleton() {
@@ -25811,9 +25812,9 @@ const UNIQUE_KEY$6 = "DefaultFontExtension", _Font = class _Font extends SheetEx
25811
25812
  renderFontContext.cellInfo = cellInfo, this.renderFontEachCell(renderFontContext, range.startRow, range.startColumn, fontMatrix);
25812
25813
  }), ctx.restore();
25813
25814
  }
25814
- renderFontEachCell(renderFontContext, row, col, fontMatrix) {
25815
+ renderFontEachCell(renderFontCtx, row, col, fontMatrix) {
25815
25816
  var _a10;
25816
- const { ctx, viewRanges, diffRanges, spreadsheetSkeleton, cellInfo } = renderFontContext;
25817
+ const { ctx, viewRanges, diffRanges, spreadsheetSkeleton, cellInfo } = renderFontCtx;
25817
25818
  let { startY, endY, startX, endX } = cellInfo;
25818
25819
  const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
25819
25820
  if (isMerged && !isMergedMainCell)
@@ -25829,9 +25830,16 @@ const UNIQUE_KEY$6 = "DefaultFontExtension", _Font = class _Font extends SheetEx
25829
25830
  const cellData = spreadsheetSkeleton.worksheet.getCell(row, col) || {};
25830
25831
  if ((_a10 = cellData.fontRenderExtension) != null && _a10.isSkip)
25831
25832
  return !0;
25832
- ctx.save(), ctx.beginPath(), renderFontContext.overflowRectangle = overflowRange, renderFontContext.cellData = cellData, renderFontContext.startX = startX, renderFontContext.startY = startY, renderFontContext.endX = endX, renderFontContext.endY = endY, this._clipTextOverflow(renderFontContext, row, col, fontMatrix), ctx.translate(startX + FIX_ONE_PIXEL_BLUR_OFFSET, startY + FIX_ONE_PIXEL_BLUR_OFFSET), this._renderDocuments(ctx, fontsConfig, startX, startY, endX, endY, row, col, spreadsheetSkeleton.overflowCache), ctx.closePath(), ctx.restore();
25833
+ ctx.save(), ctx.beginPath(), renderFontCtx.overflowRectangle = overflowRange, renderFontCtx.cellData = cellData, renderFontCtx.startX = startX, renderFontCtx.startY = startY, renderFontCtx.endX = endX, renderFontCtx.endY = endY, this._setFontRenderBounds(renderFontCtx, row, col, fontMatrix), ctx.translate(startX + FIX_ONE_PIXEL_BLUR_OFFSET, startY + FIX_ONE_PIXEL_BLUR_OFFSET), this._renderDocuments(ctx, fontsConfig, renderFontCtx.startX, renderFontCtx.startY, renderFontCtx.endX, renderFontCtx.endY, row, col, spreadsheetSkeleton.overflowCache), ctx.closePath(), ctx.restore();
25833
25834
  }
25834
- _clipTextOverflow(renderFontContext, row, col, fontMatrix) {
25835
+ /**
25836
+ * Change font render bounds, for overflow and filter icon & custom render.
25837
+ * @param renderFontContext
25838
+ * @param row
25839
+ * @param col
25840
+ * @param fontMatrix
25841
+ */
25842
+ _setFontRenderBounds(renderFontContext, row, col, fontMatrix) {
25835
25843
  var _a10, _b, _c, _d;
25836
25844
  const { ctx, scale, overflowRectangle, rowHeightAccumulation, columnWidthAccumulation, cellData } = renderFontContext;
25837
25845
  let { startX, endX, startY, endY } = renderFontContext;
@@ -25879,14 +25887,15 @@ const UNIQUE_KEY$6 = "DefaultFontExtension", _Font = class _Font extends SheetEx
25879
25887
  );
25880
25888
  } else
25881
25889
  ctx.rectByPrecision(startX + 1 / scale, startY + 1 / scale, cellWidth - 2 / scale, cellHeight - 2 / scale), ctx.clip();
25890
+ renderFontContext.startX = startX, renderFontContext.startY = startY, renderFontContext.endX = endX, renderFontContext.endY = endY;
25882
25891
  }
25883
- _renderDocuments(ctx, docsConfig, startX, startY, endX, endY, row, column, overflowCache) {
25892
+ _renderDocuments(ctx, docsConfig, startX, startY, endX, endY, row, col, overflowCache) {
25884
25893
  const documents = this.getDocuments();
25885
25894
  if (documents == null)
25886
25895
  throw new Error("documents is null");
25887
25896
  const { documentSkeleton, vertexAngle = 0, wrapStrategy } = docsConfig, cellHeight = endY - startY, cellWidth = endX - startX;
25888
25897
  wrapStrategy === WrapStrategy.WRAP && vertexAngle === 0 ? (documentSkeleton.getViewModel().getDataModel().updateDocumentDataPageSize(cellWidth), documentSkeleton.calculate()) : documentSkeleton.getViewModel().getDataModel().updateDocumentDataPageSize(Number.POSITIVE_INFINITY);
25889
- const overflowRectangle = overflowCache.getValue(row, column);
25898
+ const overflowRectangle = overflowCache.getValue(row, col);
25890
25899
  if (!(wrapStrategy === WrapStrategy.WRAP && !overflowRectangle && vertexAngle === 0)) {
25891
25900
  const contentSize = getDocsSkeletonPageSize(documentSkeleton), documentStyle = documentSkeleton.getViewModel().getDataModel().getSnapshot().documentStyle;
25892
25901
  if (contentSize && documentStyle) {
@@ -27917,7 +27926,7 @@ const UNIQUE_KEY$1 = "DefaultDocsFontAndBaseLineExtension", DOC_EXTENSION_Z_INDE
27917
27926
  if ((content === "☐" || content === CHECKED_GLYPH) && glyph.glyphType === GlyphType.LIST) {
27918
27927
  const size = Math.ceil(((_b = (_a10 = glyph.ts) == null ? void 0 : _a10.fs) != null ? _b : 12) * 1.2);
27919
27928
  ctx.save();
27920
- const fontWidth = glyph.bBox.width, fontHeight = glyph.bBox.aba - glyph.bBox.abd, bottom = spanPointWithFont.y, top = bottom - fontHeight, left = spanPointWithFont.x, right = left + fontWidth, topOffset = top + (bottom - top - size) / 2, leftOffset = left + (right - left - size) / 2, BORDER_WIDTH = 1;
27929
+ const fontHeight = glyph.bBox.aba - glyph.bBox.abd, bottom = spanPointWithFont.y, top = bottom - fontHeight, left = spanPointWithFont.x, topOffset = top + (bottom - top - size) / 2, leftOffset = left, BORDER_WIDTH = 1;
27921
27930
  ctx.translate(leftOffset - BORDER_WIDTH / 2, topOffset - BORDER_WIDTH / 2), Checkbox.drawWith(ctx, {
27922
27931
  width: size,
27923
27932
  height: size,
@@ -27943,11 +27952,11 @@ const UNIQUE_KEY = "DefaultDocsLineExtension", DOC_EXTENSION_Z_INDEX = 40, _Line
27943
27952
  }
27944
27953
  draw(ctx, parentScale, glyph) {
27945
27954
  var _a10;
27946
- const line2 = (_a10 = glyph.parent) == null ? void 0 : _a10.parent, { ts: textStyle, bBox, content } = glyph;
27955
+ const line2 = (_a10 = glyph.parent) == null ? void 0 : _a10.parent, { renderConfig } = this.extensionOffset, vertexAngle = (renderConfig == null ? void 0 : renderConfig.vertexAngle) || 0, drawStrikeAndUnderline = !(((renderConfig == null ? void 0 : renderConfig.centerAngle) || 0) === 0 && vertexAngle !== 0 && vertexAngle % 90 === 0), { ts: textStyle, bBox, content } = glyph;
27947
27956
  if (line2 == null || textStyle == null || content === "\r")
27948
27957
  return;
27949
27958
  const { asc, dsc } = line2, { sp: strikeoutPosition, spo, sbo, bd } = bBox, scale = getScale(parentScale), DELTA = 0.5, { ul: underline, st: strikethrough, ol: overline, va: baselineOffset, bbl: bottomBorderLine } = textStyle;
27950
- if (underline) {
27959
+ if (drawStrikeAndUnderline && underline) {
27951
27960
  const startY = asc + dsc;
27952
27961
  this._drawLine(ctx, glyph, underline, startY, scale);
27953
27962
  }
@@ -27955,7 +27964,7 @@ const UNIQUE_KEY = "DefaultDocsLineExtension", DOC_EXTENSION_Z_INDEX = 40, _Line
27955
27964
  const startY = asc + dsc + 3;
27956
27965
  this._drawLine(ctx, glyph, bottomBorderLine, startY, scale, 2);
27957
27966
  }
27958
- if (strikethrough) {
27967
+ if (drawStrikeAndUnderline && strikethrough) {
27959
27968
  let startY = asc + bd - strikeoutPosition - DELTA;
27960
27969
  baselineOffset === BaselineOffset.SUPERSCRIPT ? startY -= spo : baselineOffset === BaselineOffset.SUBSCRIPT && (startY += sbo), this._drawLine(ctx, glyph, strikethrough, startY, scale);
27961
27970
  }
@@ -28,8 +28,15 @@ export declare class Font extends SheetExtension {
28
28
  Z_INDEX: number;
29
29
  getDocuments(): any;
30
30
  draw(ctx: UniverRenderingContext, parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges: IRange[], moreBoundsInfo: IDrawInfo): void;
31
- renderFontEachCell(renderFontContext: IRenderFontContext, row: number, col: number, fontMatrix: ObjectMatrix<IFontCacheItem>): true | undefined;
32
- private _clipTextOverflow;
31
+ renderFontEachCell(renderFontCtx: IRenderFontContext, row: number, col: number, fontMatrix: ObjectMatrix<IFontCacheItem>): true | undefined;
32
+ /**
33
+ * Change font render bounds, for overflow and filter icon & custom render.
34
+ * @param renderFontContext
35
+ * @param row
36
+ * @param col
37
+ * @param fontMatrix
38
+ */
39
+ private _setFontRenderBounds;
33
40
  private _renderDocuments;
34
41
  private _clipRectangleForOverflow;
35
42
  }