Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issues #1959 and #2625 #2775

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DocumentContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class DocumentContext extends EventEmitter {
}
}

markEnding(endingCell) {
markEnding(endingCell, originalXOffset) {
this.page = endingCell._columnEndingContext.page;
this.x = endingCell._columnEndingContext.x;
this.x = endingCell._columnEndingContext.x + originalXOffset;
this.y = endingCell._columnEndingContext.y;
this.availableWidth = endingCell._columnEndingContext.availableWidth;
this.availableHeight = endingCell._columnEndingContext.availableHeight;
Expand Down
18 changes: 17 additions & 1 deletion src/LayoutBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ class LayoutBuilder {
if (startingSpanCell && startingSpanCell._endingCell) {
// Reference to the last cell of the rowspan
endingSpanCell = startingSpanCell._endingCell;
// Store if we are in an unbreakable block when we save the context and the originalX
if (this.writer.transactionLevel > 0) {
endingSpanCell._isUnbreakableContext = true;
endingSpanCell._originalXOffset = this.writer.originalX;
}
}

// We pass the endingSpanCell reference to store the context just after processing rowspan cell
Expand All @@ -587,9 +592,15 @@ class LayoutBuilder {
this.processNode(column);
addAll(positions, column.positions);
} else if (column._columnEndingContext) {
let originalXOffset = 0;
// If context was saved from an unbreakable block and we are not in an unbreakable block anymore
// We have to sum the originalX (X before starting unbreakable block) to X
if (column._isUnbreakableContext && !this.writer.transactionLevel) {
originalXOffset = column._originalXOffset;
}
// row-span ending
// Recover the context after processing the rowspanned cell
this.writer.context().markEnding(column);
this.writer.context().markEnding(column, originalXOffset);
}
}

Expand All @@ -607,6 +618,11 @@ class LayoutBuilder {
if (startingSpanCell) {
// Context will be stored here (ending cell)
endingSpanCell = startingSpanCell._endingCell;
// Store if we are in an unbreakable block when we save the context and the originalX
if (this.writer.transactionLevel > 0) {
endingSpanCell._isUnbreakableContext = true;
endingSpanCell._originalXOffset = this.writer.originalX;
}
}
}
}
Expand Down
Loading