@univerjs/engine-render 0.4.0-alpha.2 → 0.4.0-experimental.d7288c0-20241017
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 +1 -1
- package/lib/es/index.js +18 -10
- package/lib/types/components/sheets/extensions/font.d.ts +9 -2
- package/lib/umd/index.js +1 -1
- package/package.json +2 -2
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -25811,9 +25811,9 @@ const UNIQUE_KEY$6 = "DefaultFontExtension", _Font = class _Font extends SheetEx
|
|
|
25811
25811
|
renderFontContext.cellInfo = cellInfo, this.renderFontEachCell(renderFontContext, range.startRow, range.startColumn, fontMatrix);
|
|
25812
25812
|
}), ctx.restore();
|
|
25813
25813
|
}
|
|
25814
|
-
renderFontEachCell(
|
|
25814
|
+
renderFontEachCell(renderFontCtx, row, col, fontMatrix) {
|
|
25815
25815
|
var _a10;
|
|
25816
|
-
const { ctx, viewRanges, diffRanges, spreadsheetSkeleton, cellInfo } =
|
|
25816
|
+
const { ctx, viewRanges, diffRanges, spreadsheetSkeleton, cellInfo } = renderFontCtx;
|
|
25817
25817
|
let { startY, endY, startX, endX } = cellInfo;
|
|
25818
25818
|
const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
|
|
25819
25819
|
if (isMerged && !isMergedMainCell)
|
|
@@ -25829,9 +25829,16 @@ const UNIQUE_KEY$6 = "DefaultFontExtension", _Font = class _Font extends SheetEx
|
|
|
25829
25829
|
const cellData = spreadsheetSkeleton.worksheet.getCell(row, col) || {};
|
|
25830
25830
|
if ((_a10 = cellData.fontRenderExtension) != null && _a10.isSkip)
|
|
25831
25831
|
return !0;
|
|
25832
|
-
ctx.save(), ctx.beginPath(),
|
|
25832
|
+
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
25833
|
}
|
|
25834
|
-
|
|
25834
|
+
/**
|
|
25835
|
+
* Change font render bounds, for overflow and filter icon & custom render.
|
|
25836
|
+
* @param renderFontContext
|
|
25837
|
+
* @param row
|
|
25838
|
+
* @param col
|
|
25839
|
+
* @param fontMatrix
|
|
25840
|
+
*/
|
|
25841
|
+
_setFontRenderBounds(renderFontContext, row, col, fontMatrix) {
|
|
25835
25842
|
var _a10, _b, _c, _d;
|
|
25836
25843
|
const { ctx, scale, overflowRectangle, rowHeightAccumulation, columnWidthAccumulation, cellData } = renderFontContext;
|
|
25837
25844
|
let { startX, endX, startY, endY } = renderFontContext;
|
|
@@ -25879,14 +25886,15 @@ const UNIQUE_KEY$6 = "DefaultFontExtension", _Font = class _Font extends SheetEx
|
|
|
25879
25886
|
);
|
|
25880
25887
|
} else
|
|
25881
25888
|
ctx.rectByPrecision(startX + 1 / scale, startY + 1 / scale, cellWidth - 2 / scale, cellHeight - 2 / scale), ctx.clip();
|
|
25889
|
+
renderFontContext.startX = startX, renderFontContext.startY = startY, renderFontContext.endX = endX, renderFontContext.endY = endY;
|
|
25882
25890
|
}
|
|
25883
|
-
_renderDocuments(ctx, docsConfig, startX, startY, endX, endY, row,
|
|
25891
|
+
_renderDocuments(ctx, docsConfig, startX, startY, endX, endY, row, col, overflowCache) {
|
|
25884
25892
|
const documents = this.getDocuments();
|
|
25885
25893
|
if (documents == null)
|
|
25886
25894
|
throw new Error("documents is null");
|
|
25887
25895
|
const { documentSkeleton, vertexAngle = 0, wrapStrategy } = docsConfig, cellHeight = endY - startY, cellWidth = endX - startX;
|
|
25888
25896
|
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,
|
|
25897
|
+
const overflowRectangle = overflowCache.getValue(row, col);
|
|
25890
25898
|
if (!(wrapStrategy === WrapStrategy.WRAP && !overflowRectangle && vertexAngle === 0)) {
|
|
25891
25899
|
const contentSize = getDocsSkeletonPageSize(documentSkeleton), documentStyle = documentSkeleton.getViewModel().getDataModel().getSnapshot().documentStyle;
|
|
25892
25900
|
if (contentSize && documentStyle) {
|
|
@@ -27917,7 +27925,7 @@ const UNIQUE_KEY$1 = "DefaultDocsFontAndBaseLineExtension", DOC_EXTENSION_Z_INDE
|
|
|
27917
27925
|
if ((content === "☐" || content === CHECKED_GLYPH) && glyph.glyphType === GlyphType.LIST) {
|
|
27918
27926
|
const size = Math.ceil(((_b = (_a10 = glyph.ts) == null ? void 0 : _a10.fs) != null ? _b : 12) * 1.2);
|
|
27919
27927
|
ctx.save();
|
|
27920
|
-
const
|
|
27928
|
+
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
27929
|
ctx.translate(leftOffset - BORDER_WIDTH / 2, topOffset - BORDER_WIDTH / 2), Checkbox.drawWith(ctx, {
|
|
27922
27930
|
width: size,
|
|
27923
27931
|
height: size,
|
|
@@ -27943,11 +27951,11 @@ const UNIQUE_KEY = "DefaultDocsLineExtension", DOC_EXTENSION_Z_INDEX = 40, _Line
|
|
|
27943
27951
|
}
|
|
27944
27952
|
draw(ctx, parentScale, glyph) {
|
|
27945
27953
|
var _a10;
|
|
27946
|
-
const line2 = (_a10 = glyph.parent) == null ? void 0 : _a10.parent, { ts: textStyle, bBox, content } = glyph;
|
|
27954
|
+
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
27955
|
if (line2 == null || textStyle == null || content === "\r")
|
|
27948
27956
|
return;
|
|
27949
27957
|
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) {
|
|
27958
|
+
if (drawStrikeAndUnderline && underline) {
|
|
27951
27959
|
const startY = asc + dsc;
|
|
27952
27960
|
this._drawLine(ctx, glyph, underline, startY, scale);
|
|
27953
27961
|
}
|
|
@@ -27955,7 +27963,7 @@ const UNIQUE_KEY = "DefaultDocsLineExtension", DOC_EXTENSION_Z_INDEX = 40, _Line
|
|
|
27955
27963
|
const startY = asc + dsc + 3;
|
|
27956
27964
|
this._drawLine(ctx, glyph, bottomBorderLine, startY, scale, 2);
|
|
27957
27965
|
}
|
|
27958
|
-
if (strikethrough) {
|
|
27966
|
+
if (drawStrikeAndUnderline && strikethrough) {
|
|
27959
27967
|
let startY = asc + bd - strikeoutPosition - DELTA;
|
|
27960
27968
|
baselineOffset === BaselineOffset.SUPERSCRIPT ? startY -= spo : baselineOffset === BaselineOffset.SUBSCRIPT && (startY += sbo), this._drawLine(ctx, glyph, strikethrough, startY, scale);
|
|
27961
27969
|
}
|
|
@@ -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(
|
|
32
|
-
|
|
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
|
}
|