Skip to content

Commit

Permalink
fix: dup list glyph type name
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Nov 29, 2024
1 parent ed57454 commit df4dc9a
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions packages/engine-render/src/components/docs/layout/block/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,21 @@ function updateTableSkeletonsPosition(
}
}

function getCurTableSkeleton(skeTables: IDocumentSkeletonTable[]): IDocumentSkeletonTable {
return skeTables[skeTables.length - 1];
}

function getAvailableHeight(curPage: IDocumentSkeletonPage, cache: ICreateTableCache, hasRepeatHeader: boolean) {
const { marginTop, marginBottom, pageHeight } = curPage;
let pageContentHeight = pageHeight - marginTop - marginBottom;

if (hasRepeatHeader) {
pageContentHeight -= cache.repeatRowHeight;
}

return pageContentHeight;
}

function dealWithTableRow(
ctx: ILayoutContext,
curPage: IDocumentSkeletonPage,
Expand All @@ -255,8 +270,7 @@ function dealWithTableRow(
cache: ICreateTableCache,
isRepeatRow = false
) {
const { marginTop, marginBottom, pageHeight } = curPage;
const pageContentHeight = pageHeight - marginTop - marginBottom - cache.repeatRowHeight;
const pageContentHeight = getAvailableHeight(curPage, cache, false);
const { children: cellNodes, startIndex, endIndex } = rowNode;
const rowSource = table.tableRows[row];
const { trHeight, cantSplit } = rowSource;
Expand All @@ -266,7 +280,7 @@ function dealWithTableRow(
// If the remain height is less than 50 pixels, you can't fit the next line, so you can start typography directly from the second page.
const MAX_FONT_SIZE = 72;
const needOpenNewTable = cache.remainHeight <= MAX_FONT_SIZE;
let curTableSkeleton = skeTables[skeTables.length - 1];
let curTableSkeleton = getCurTableSkeleton(skeTables);

const rowHeights = [0];

Expand Down Expand Up @@ -360,18 +374,21 @@ function dealWithTableRow(

while (rowSkeletons.length > 0) {
const rowSkeleton = rowSkeletons.shift()!;
const lastRow = curTableSkeleton.rows[curTableSkeleton.rows.length - 1];

if (cache.remainHeight < MAX_FONT_SIZE || cache.remainHeight < rowSkeleton.height) {
cache.remainHeight = pageContentHeight;
cache.remainHeight = getAvailableHeight(curPage, cache, row !== 0 && rowSkeleton.index !== lastRow.index);
cache.rowTop = 0;

if (curTableSkeleton.rows.length > 0) {
curTableSkeleton = getNullTableSkeleton(startIndex, endIndex, table);
skeTables.push(curTableSkeleton);

// Handle repeat first row.
if (cache.repeatRow && isRepeatRow === false && rowSkeleton.index !== 0) {
// 如果当前行跨页,那么不用再第二页上面重复标题行了。
if (cache.repeatRow && isRepeatRow === false && row !== 0 && rowSkeleton.index !== lastRow.index) {
const FIRST_ROW_INDEX = 0;
cache.remainHeight = getAvailableHeight(curPage, cache, false);
dealWithTableRow(
ctx,
curPage,
Expand All @@ -388,7 +405,7 @@ function dealWithTableRow(
}
}

curTableSkeleton = skeTables[skeTables.length - 1];
curTableSkeleton = getCurTableSkeleton(skeTables);

rowSkeleton.top = cache.rowTop;
curTableSkeleton.height += rowSkeleton.height;
Expand Down

0 comments on commit df4dc9a

Please sign in to comment.