Comparing version 0.4.0-beta.2 to 0.4.0-beta.3
{ | ||
"name": "pagedjs", | ||
"version": "0.4.0-beta.2", | ||
"version": "0.4.0-beta.3", | ||
"description": "Chunks up a document into paged media flows and applies print styles", | ||
@@ -5,0 +5,0 @@ "author": "Fred Chasen", |
@@ -124,2 +124,3 @@ <img style="display: block; margin: 5em 0 auto;" src="https://www.pagedmedia.org/wp-content/uploads/2018/11/pagedjs.png" alt="Paged.js logo - pagination in the browser"/> | ||
afterPageLayout(pageElement, page, breakToken) | ||
finalizePage(pageElement, page, breakToken) | ||
afterRendered(pages) | ||
@@ -126,0 +127,0 @@ |
@@ -109,2 +109,3 @@ import Page from "./page.js"; | ||
this.hooks.afterPageLayout = new Hook(this); | ||
this.hooks.finalizePage = new Hook(this); | ||
this.hooks.afterRendered = new Hook(this); | ||
@@ -325,2 +326,3 @@ | ||
await this.hooks.afterPageLayout.trigger(page.element, page, undefined, this); | ||
await this.hooks.finalizePage.trigger(page.element, page, undefined, this); | ||
this.emit("renderedPage", page); | ||
@@ -350,2 +352,3 @@ } | ||
await this.hooks.afterPageLayout.trigger(page.element, page, breakToken, this); | ||
await this.hooks.finalizePage.trigger(page.element, page, undefined, this); | ||
this.emit("renderedPage", page); | ||
@@ -521,2 +524,3 @@ | ||
await this.hooks.afterPageLayout.trigger(page.element, page, undefined, this); | ||
await this.hooks.finalizePage.trigger(page.element, page, undefined, this); | ||
this.emit("renderedPage", page); | ||
@@ -523,0 +527,0 @@ } |
@@ -11,3 +11,3 @@ import Handler from "../handler.js"; | ||
this.type; | ||
// pageLastString = last string variable defined on the page | ||
// pageLastString = last string variable defined on the page | ||
this.pageLastString; | ||
@@ -21,17 +21,31 @@ | ||
let identifier = declaration.value.children.first().name; | ||
let identifiers = []; | ||
let functions = []; | ||
let values = []; | ||
let value; | ||
csstree.walk(declaration, { | ||
visit: "Function", | ||
enter: (node, item, list) => { | ||
value = csstree.generate(node); | ||
declaration.value.children.forEach((child) => { | ||
if (child.type === "Identifier") { | ||
identifiers.push(child.name); | ||
} | ||
if (child.type === "Function") { | ||
functions.push(child.name); | ||
child.children.forEach((subchild) => { | ||
if (subchild.type === "Identifier") { | ||
values.push(subchild.name); | ||
} | ||
}); | ||
} | ||
}); | ||
this.stringSetSelectors[identifier] = { | ||
identifier, | ||
value, | ||
selector | ||
}; | ||
identifiers.forEach((identifier, index) => { | ||
let func = functions[index]; | ||
let value = values[index]; | ||
this.stringSetSelectors[identifier] = { | ||
identifier, | ||
func, | ||
value, | ||
selector | ||
}; | ||
}); | ||
} | ||
@@ -76,3 +90,3 @@ } | ||
} | ||
@@ -82,2 +96,4 @@ for (let name of Object.keys(this.stringSetSelectors)) { | ||
let set = this.stringSetSelectors[name]; | ||
let value = set.value; | ||
let func = set.func; | ||
let selected = fragment.querySelectorAll(set.selector); | ||
@@ -100,4 +116,10 @@ | ||
// push each content into the array to define in the variable the first and the last element of the page. | ||
this.pageLastString[name] = selected[selected.length - 1].textContent; | ||
if (func === "content") { | ||
this.pageLastString[name] = selected[selected.length - 1].textContent; | ||
} | ||
if (func === "attr") { | ||
this.pageLastString[name] = selected[selected.length - 1].getAttribute(value) || ""; | ||
} | ||
}); | ||
@@ -107,10 +129,22 @@ | ||
varFirst = selected[0].textContent; | ||
if (func === "content") { | ||
varFirst = selected[0].textContent; | ||
} | ||
if (func === "attr") { | ||
varFirst = selected[0].getAttribute(value) || ""; | ||
} | ||
/* LAST */ | ||
varLast = selected[selected.length - 1].textContent; | ||
if (func === "content") { | ||
varLast = selected[selected.length - 1].textContent; | ||
} | ||
if (func === "attr") { | ||
varLast = selected[selected.length - 1].getAttribute(value) || ""; | ||
} | ||
/* START */ | ||
@@ -117,0 +151,0 @@ |
@@ -1737,3 +1737,3 @@ import Handler from "../handler.js"; | ||
afterPageLayout(fragment, page, breakToken, chunker) { | ||
finalizePage(fragment, page, breakToken, chunker) { | ||
for (let m in this.marginalia) { | ||
@@ -1740,0 +1740,0 @@ let margin = this.marginalia[m]; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4934064
115728
274