* Technocrat Pagination fixes Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * [TE/pagination] Add fixes from rebase to 0.4.3 previously uncommitted. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Add code to handle what appears to be a bug in Chromium. Content that's starting to overflow gets offset to the right of the existing content, for some strange reason. Recognise that as overflow too. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Correct a typo. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Add comparison of ranges in checking overflow equality. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Remove layout repeat check - shouldn't be needed and assumes node always set. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * If we're removing all the content from a row, remove the whole row. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Ignore colgroup tags in finding overflow. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Treat break-inside:avoid-column like avoid. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Remove old comment about not setting column widths. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Set the width from width attrib first if available. Better than getBoundingClientRect result in some cases. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Clone colgroup attrib if it exists when rebuilding tree. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Remember the start of the remainder separately to 'node'. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Handle siblingRangeStart also being the end of the doc. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Revert "Treat break-inside:avoid-column like avoid." This reverts commit 045655f09852c6a88bf7af652dbc72592b0c45c7. The commit breaks relaxtorium's sample and doesn't seem to fix anything else anymore. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Improve logic for deciding whether an entire row is being removed. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Setting columnWidth causes text to be cut off / no bottom border sometimes Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Improve readability, correct ignoreSides logic, default false. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Disable window.scrollTo if not debugging. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Work on getting docker tests running. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Named pages re-add. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * startIsNode correction. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Handle contents that can't be paginated. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Disable setting data-split-from to make tests pass for now. (Comment added in PR). Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Rebuild table rows taking account of row spans, initial cut. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Correct comment. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Get detected overflow's non overflowing text on original page. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Correct error in rowspan code. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Mathjax test needs to check math elements, not parents. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * needsBreak check adjustments. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * mustSplit DOES need to look at height, not bottom. (This is the does-it-fit-in-a-page check). Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Reenable data-split-from - gets justification right. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Further clarification on comments. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Look for overflow from the top of the render tree. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Re-add afterOverflowRemoved event trigger. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Silence npm run test complaints. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Work so far on getting footnotes interacting with new overflow code. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * More work on footnotes. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * More footnotes work. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Looking like working apart from adding footnote overflow to last page? Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Fix handling of deferred notes. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Fix relative paths to polyfill in specs Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Work on forced breaks. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * 38 pages. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Spec polyfill path correction. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * More footnote changes. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Getting 3rd footnote on footnote-policy.html Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Go back to modified main footnote.js. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Adjust footnote code for new breakToken structure. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Add afterOverflowAdded hook and use to re-add overflowed footnotes. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Ensure we always add a last page if there's overflow & recalc bounds. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Only make page add condition, not sure about breakToken.overflow.length check Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Trying to get footnotes.html working. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Treat overflow as one if force parent height. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Don't use notePolicyDelta if < 0 Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Ensure entire footnote is taken as overflow if textOffset is 0. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Prevent getStart looping when we're just rendering overflow at the end. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Fix infinite loop, but correctly? Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Remove (I think wrongly) unsetting margin/padding top on split content. (To make tests pass). Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Work on page number recto/verso odd/even correction. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Correct English. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * More footnote overflow work. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Page attribute copying fix. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Re-add margin-top and padding-top to data-split-from for test passing. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Test fix Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Restore setting columnWidth (this broken TE contracts?) Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Partial fix for footnotes.html - getting underflow now. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Set max pages for now. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Get start should use breakToken.node It's the next node to be processed. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Check loops should stop at rendered. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Use this.avoidBreakInside. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Ensure break happens for colspan with break-inside avoid. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Make avoidBreakInside look at first node too. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Don't remove rowspan attrib at the moment. Needed for current use case but still need to check others. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * avoid-break-rowspan almost rendering right with our without break avoid. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Remove a dangling TR with no content. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Add math tag to dangling child pruning. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Correct textBreak. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Get rowspans working right when mixed with normal rows. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * I think the possible Chromium bug got resolved with footnotes changes. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * In getStartElement, use node that will be added next. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Don't add end overflow page if previous page empty. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Allow for hooks generating more overflow. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Get afterOverflowAdded adding footnotes correctly. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Continue named class on a footnotes only overflow page. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Break after recto testing polyfill path. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Clear MAX_PAGES and correct add page mistake. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Don't add named page classes on the basis of a node that will be in overflow. I think we should actually look for nodes in the page with the page attrib after overflow is removed, but let's revisit this later. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * No max pages. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Back to possible Chromium bug - footnotes.html text overflow missing o/wise. On footnotes.html, the "existence of similar letters" overflow on p5 isn't detected unless we look at the right bounds. Must be a better way but I don't know what it is yet. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Prevent split-from being set for content moved entirely to the next page. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Add overflow footnotes back. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Fix split-from being incorrectly set sometimes. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Don't start by assuming we need to go back to previous row. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Modify extracting footnote overflow for footnotes-counter-reset-page. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Update image snapshots for avoid-break-rowspan. Getting width consistent across the break now. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Update exceeding-rowspan-table image snapshots. Not obeying break-inside:avoid for tr in main. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * splits-tables-rowspan: Main doesn't obey rowspan correctly. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * generate-content/content-none. Images looks same but spec says different. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Fix typo. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Remove ignoreSides logic - no Chromium bug. It's display grid on the page. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Correct typo in footnotes range set. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Improve dangling, unsplit rendered child removal. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Invoke afterOverflowRemoved after all overflow is removed. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Make indexOfTextNode handle hyphenated text. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Take account of margins in textBreak for non-block parents. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Ensure split-to gets set when it should. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Don't clear the data-split-to in textBreak, so we don't confuse ourselves. If it is cleared and there is margin modified by the attribute, we might think there's overflow again. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Get setting the split-to and split-from attributes right. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Use overflow_after rather than split-to as the critieria for justifying? Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Fix typo in class name addition. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * In splits, just look for the data-ref. If text is broken, overflow-after will be on a parent but not the lowest text node (can't be). Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Update the rebuild-table-rows test - 3 pages now. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Correction to removing an entire footnote. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * named page spec image snapshot update. Can't see a difference but the code can. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Make isEntireNote handle startContainer is the footnote. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Another named page snapshot needs updating. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Update footnotes lastpage snapshot. Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> * Remove getOverflow hook - ended up being an unneeded addition. Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au> * Remove window.scrollTo debugging code. Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au> * Remove debugging commented out console log. Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au> * Remove console.log. Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au> * Remove unneeded comment / addition, update tests. Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au> * Add comment explaining the removal of parent containers. Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au> * One let ChildBounds to rule them all. Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au> * Use hyphen settings in indexOfTextNode. Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au> * Add test for copying column widths across a split (failing). Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au> * Make column-width test pass. Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au> --------- Signed-off-by: Nigel Cunningham <nigel@technocrat.com.au> Signed-off-by: Nigel Cunningham <nigel@nigelcunningham.com.au>main
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 104 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 58 KiB |
@ -0,0 +1,203 @@
|
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta charset="utf-8" /> |
||||
<script src="../../../dist/paged.polyfill.js"></script> |
||||
<style> |
||||
table { border-collapse: collapse; width: 100%; } |
||||
td, th { border: 1px solid gray; } |
||||
th { background: gray; } |
||||
</style> |
||||
</head> |
||||
|
||||
<body> |
||||
<table> |
||||
<thead> |
||||
<th>A</th> |
||||
<th>B</th> |
||||
</thead> |
||||
|
||||
<tbody> |
||||
<script> |
||||
// Make a table big enough so that the THEAD of the next table |
||||
// should be split. |
||||
for (var i = 1; i <= 38; i++) { |
||||
document.write(`<tr><td>test ${i}</td><td>m2</td></tr>`); |
||||
} |
||||
</script> |
||||
</tbody> |
||||
</table> |
||||
|
||||
<table> |
||||
<thead> |
||||
<th>This table heading should be sit at the bottom of the page and want to be split. It should get moved onto the next page and repeated for the additional pages.</th> |
||||
<th>B</th> |
||||
</thead> |
||||
|
||||
<tbody> |
||||
<script> |
||||
// Make a table big enough so that the THEAD of the next table |
||||
// should be split. |
||||
for (var i = 1; i <= 100; i++) { |
||||
document.write(`<tr><td>test ${i}</td><td>m2</td></tr>`); |
||||
} |
||||
</script> |
||||
</tbody> |
||||
</table> |
||||
|
||||
<script> |
||||
// Repeat thead on each page (PagedJS cut tables in pieces, one for each page) |
||||
// https://gitlab.pagedmedia.org/tools/pagedjs/issues/84#note_2322 |
||||
class RepeatingTableHeadersHandler extends Paged.Handler { |
||||
|
||||
constructor(chunker, polisher, caller) { |
||||
super(chunker, polisher, caller); |
||||
this.splitTablesRefs = []; |
||||
} |
||||
|
||||
afterPageLayout(pageElement, page, breakToken, chunker) { |
||||
this.chunker = chunker; |
||||
this.splitTablesRefs = []; |
||||
|
||||
if (breakToken) { |
||||
const node = breakToken.overflow[0].node; |
||||
const tables = this.findAllAncestors(node, "table"); |
||||
if (node.tagName === "TABLE") { |
||||
tables.push(node); |
||||
} |
||||
|
||||
if (tables.length > 0) { |
||||
this.splitTablesRefs = tables.map(t => t.dataset.ref); |
||||
|
||||
//checks if split inside thead and if so, set breakToken to next sibling element |
||||
let thead = node.tagName === "THEAD" ? node : this.findFirstAncestor(node, "thead"); |
||||
if (thead) { |
||||
let lastTheadNode = thead.hasChildNodes() ? thead.lastChild : thead; |
||||
breakToken.node = this.nodeAfter(lastTheadNode, chunker.source); |
||||
} |
||||
|
||||
this.hideEmptyTables(pageElement, node); |
||||
} |
||||
} |
||||
} |
||||
|
||||
hideEmptyTables(pageElement, breakTokenNode) { |
||||
this.splitTablesRefs.forEach(ref => { |
||||
let table = pageElement.querySelector("[data-ref='" + ref + "']"); |
||||
if (table) { |
||||
let sourceBody = table.querySelector("tbody > tr"); |
||||
if (!sourceBody || this.refEquals(sourceBody.firstElementChild, breakTokenNode)) { |
||||
table.style.visibility = "hidden"; |
||||
table.style.position = "absolute"; |
||||
let lineSpacer = table.nextSibling; |
||||
if (lineSpacer) { |
||||
lineSpacer.style.visibility = "hidden"; |
||||
lineSpacer.style.position = "absolute"; |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
refEquals(a, b) { |
||||
return a && a.dataset && b && b.dataset && a.dataset.ref === b.dataset.ref; |
||||
} |
||||
|
||||
findFirstAncestor(element, selector) { |
||||
while (element.parentNode && element.parentNode.nodeType === 1) { |
||||
if (element.parentNode.matches(selector)) { |
||||
return element.parentNode; |
||||
} |
||||
element = element.parentNode; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
findAllAncestors(element, selector) { |
||||
const ancestors = []; |
||||
while (element.parentNode && element.parentNode.nodeType === 1) { |
||||
if (element.parentNode.matches(selector)) { |
||||
ancestors.unshift(element.parentNode); |
||||
} |
||||
element = element.parentNode; |
||||
} |
||||
return ancestors; |
||||
} |
||||
|
||||
// The addition of repeating Table Headers is done here because this hook is triggered before overflow handling |
||||
layout(rendered, layout) { |
||||
this.splitTablesRefs.forEach(ref => { |
||||
const renderedTable = rendered.querySelector("[data-ref='" + ref + "']"); |
||||
if (renderedTable) { |
||||
// this event can be triggered multiple times |
||||
// added a flag repeated-headers to control when table headers already repeated in current page. |
||||
if (!renderedTable.getAttribute("repeated-headers")) { |
||||
const sourceTable = this.chunker.source.querySelector("[data-ref='" + ref + "']"); |
||||
this.repeatColgroup(sourceTable, renderedTable); |
||||
this.repeatTHead(sourceTable, renderedTable); |
||||
renderedTable.setAttribute("repeated-headers", true); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
repeatColgroup(sourceTable, renderedTable) { |
||||
let colgroup = sourceTable.querySelectorAll("colgroup"); |
||||
let firstChild = renderedTable.firstChild; |
||||
colgroup.forEach((colgroup) => { |
||||
let clonedColgroup = colgroup.cloneNode(true); |
||||
renderedTable.insertBefore(clonedColgroup, firstChild); |
||||
}); |
||||
} |
||||
|
||||
repeatTHead(sourceTable, renderedTable) { |
||||
let thead = sourceTable.querySelector("thead"); |
||||
if (thead) { |
||||
let clonedThead = thead.cloneNode(true); |
||||
renderedTable.insertBefore(clonedThead, renderedTable.firstChild); |
||||
} |
||||
} |
||||
|
||||
// the functions below are from pagedjs utils/dom.js |
||||
nodeAfter(node, limiter) { |
||||
if (limiter && node === limiter) { |
||||
return; |
||||
} |
||||
let significantNode = this.nextSignificantNode(node); |
||||
if (significantNode) { |
||||
return significantNode; |
||||
} |
||||
if (node.parentNode) { |
||||
while ((node = node.parentNode)) { |
||||
if (limiter && node === limiter) { |
||||
return; |
||||
} |
||||
significantNode = this.nextSignificantNode(node); |
||||
if (significantNode) { |
||||
return significantNode; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
nextSignificantNode(sib) { |
||||
while ((sib = sib.nextSibling)) { |
||||
if (!this.isIgnorable(sib)) return sib; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
isIgnorable(node) { |
||||
return (node.nodeType === 8) || // A comment node |
||||
((node.nodeType === 3) && this.isAllWhitespace(node)); // a text node, all whitespace |
||||
} |
||||
|
||||
isAllWhitespace(node) { |
||||
return !(/[^\t\n\r ]/.test(node.textContent)); |
||||
} |
||||
|
||||
} |
||||
|
||||
Paged.registerHandlers(RepeatingTableHeadersHandler); |
||||
</script> |
||||
</html> |
@ -0,0 +1,35 @@
|
||||
const TIMEOUT = 10000; |
||||
|
||||
describe("copy-column-widths", () => { |
||||
let page; |
||||
beforeAll(async () => { |
||||
page = await loadPage("tables/copy-column-widths/copy-column-widths.html"); |
||||
return page.rendered; |
||||
}, TIMEOUT); |
||||
|
||||
afterAll(async () => { |
||||
if (!DEBUG) { |
||||
await page.close(); |
||||
} |
||||
}); |
||||
|
||||
xit("should render 3 pages", async () => { |
||||
let pages = await page.$$eval(".pagedjs_page", (r) => { |
||||
return r.length; |
||||
}); |
||||
|
||||
expect(pages).toEqual(3); |
||||
}); |
||||
|
||||
|
||||
if (!DEBUG) { |
||||
it("should create a pdf", async () => { |
||||
let pdf = await page.pdf(PDF_SETTINGS); |
||||
|
||||
expect(pdf).toMatchPDFSnapshot(1); |
||||
expect(pdf).toMatchPDFSnapshot(2); |
||||
expect(pdf).toMatchPDFSnapshot(3); |
||||
}); |
||||
} |
||||
} |
||||
); |
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 116 KiB |
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 20 KiB |
@ -1,57 +1,64 @@
|
||||
import { |
||||
isElement |
||||
} from "../utils/dom.js"; |
||||
|
||||
/** |
||||
* BreakToken |
||||
* @class |
||||
*/ |
||||
class BreakToken { |
||||
|
||||
constructor(node, offset) { |
||||
constructor(node, overflowArray) { |
||||
this.node = node; |
||||
this.offset = offset; |
||||
this.overflow = overflowArray || []; |
||||
this.finished = false; |
||||
this.breakNeededAt = []; |
||||
} |
||||
|
||||
equals(otherBreakToken) { |
||||
if (!otherBreakToken) { |
||||
if (this.node !== otherBreakToken.node) { |
||||
return false; |
||||
} |
||||
if (this["node"] && otherBreakToken["node"] && |
||||
this["node"] !== otherBreakToken["node"]) { |
||||
|
||||
if (otherBreakToken.overflow.length !== this.overflow.length) { |
||||
return false; |
||||
} |
||||
if (this["offset"] && otherBreakToken["offset"] && |
||||
this["offset"] !== otherBreakToken["offset"]) { |
||||
return false; |
||||
|
||||
for (const index in this.overflow) { |
||||
if (!this.overflow[index].equals(otherBreakToken.overflow[index])) { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
let otherQueue = otherBreakToken.getForcedBreakQueue(); |
||||
for (const index in this.breakNeededAt) { |
||||
if (!this.breakNeededAt[index].isEqualNode(otherQueue[index])) { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
toJSON(hash) { |
||||
let node; |
||||
let index = 0; |
||||
if (!this.node) { |
||||
return {}; |
||||
} |
||||
if (isElement(this.node) && this.node.dataset.ref) { |
||||
node = this.node.dataset.ref; |
||||
} else if (hash) { |
||||
node = this.node.parentElement.dataset.ref; |
||||
} |
||||
setFinished() { |
||||
this.finished = true; |
||||
} |
||||
|
||||
if (this.node.parentElement) { |
||||
const children = Array.from(this.node.parentElement.childNodes); |
||||
index = children.indexOf(this.node); |
||||
} |
||||
isFinished() { |
||||
return this.finished; |
||||
} |
||||
|
||||
addNeedsBreak(needsBreak) { |
||||
this.breakNeededAt.push(needsBreak); |
||||
} |
||||
|
||||
getNextNeedsBreak() { |
||||
return this.breakNeededAt.shift(); |
||||
} |
||||
|
||||
return JSON.stringify({ |
||||
"node": node, |
||||
"index" : index, |
||||
"offset": this.offset |
||||
}); |
||||
getForcedBreakQueue() { |
||||
return this.breakNeededAt; |
||||
} |
||||
|
||||
setForcedBreakQueue(queue) { |
||||
return this.breakNeededAt = queue; |
||||
} |
||||
} |
||||
|
||||
export default BreakToken; |
||||
export default BreakToken; |
||||
|
@ -0,0 +1,31 @@
|
||||
/** |
||||
* Overflow |
||||
* @class |
||||
*/ |
||||
class Overflow { |
||||
|
||||
constructor(node, offset, overflowHeight, range) { |
||||
this.node = node; |
||||
this.offset = offset; |
||||
this.overflowHeight = overflowHeight; |
||||
this.range = range; |
||||
} |
||||
|
||||
equals(otherOffset) { |
||||
if (!otherOffset) { |
||||
return false; |
||||
} |
||||
if (this["node"] && otherOffset["node"] && |
||||
this["node"] !== otherOffset["node"]) { |
||||
return false; |
||||
} |
||||
if (this["offset"] && otherOffset["offset"] && |
||||
this["offset"] !== otherOffset["offset"]) { |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
} |
||||
|
||||
export default Overflow; |