Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix: while rendering cell content, sometimes the text is truncated (#1075)

Ran Luo648ac2c53399
diff --git a/packages/engine-render/src/components/sheets/sheet-skeleton.ts b/packages/engine-render/src/components/sheets/sheet-skeleton.ts
index 52977bf981..6124832e34 100644
--- a/packages/engine-render/src/components/sheets/sheet-skeleton.ts
+++ b/packages/engine-render/src/components/sheets/sheet-skeleton.ts
@@ -87,13 +87,16 @@ export function getDocsSkeletonPageSize(documentSkeleton: DocumentSkeleton, angl
}
const { pages } = skeletonData;
const lastPage = pages[pages.length - 1];
+ const { width, height } = lastPage;
if (angle === 0) {
- const { width, height } = lastPage;
-
return { width, height };
}
+ if (Math.abs(angle) === Math.PI / 2) {
+ return { width: height, height: width };
+ }
+
let allRotatedWidth = 0;
let allRotatedHeight = 0;
@@ -477,7 +480,27 @@ export class SpreadsheetSkeleton extends Skeleton {
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localService);
documentSkeleton.calculate();
- const { height: h = 0 } = getDocsSkeletonPageSize(documentSkeleton, angle) ?? {};
+ let { height: h = 0 } = getDocsSkeletonPageSize(documentSkeleton, angle) ?? {};
+
+ // When calculating the auto Height, need take the margin information into account,
+ // because there is margin information when rendering
+ if (documentSkeleton) {
+ const skeletonData = documentSkeleton.getSkeletonData()!;
+ const {
+ marginTop: t,
+ marginBottom: b,
+ marginLeft: l,
+ marginRight: r,
+ } = skeletonData.pages[skeletonData.pages.length - 1];
+
+ const absAngleInRad = Math.abs(degToRad(angle));
+
+ h +=
+ t * Math.cos(absAngleInRad) +
+ r * Math.sin(absAngleInRad) +
+ b * Math.cos(absAngleInRad) +
+ l * Math.sin(absAngleInRad);
+ }
height = Math.max(height, h);
}