Commit 2248a183 authored by julientaq's avatar julientaq

update paged.js and add smallCaps to running header

parent 816abce1
......@@ -11,9 +11,9 @@
@page :right {
@top-right {
content: string(chapterTitleRun, first) " " counter(page);
content: string(chapterTitleRun, first) "\00A0\00A0\00A0\00A0\00A0" counter(page);
padding-top: 2.6em;
font-variant: oldstyle-nums;
font-variant: oldstyle-nums all-small-caps;
text-align: right;
}
/* @top-center {
......@@ -26,11 +26,11 @@
@page :left {
@top-left {
content: counter(page) " " string(chapterTitleRun, first);
content: counter(page) "\00A0\00A0\00A0\00A0\00A0" string(chapterTitleRun, first);
padding-top: 2.6em;
font-size: 9pt;
line-height: 17px;
font-variant: oldstyle-nums;
font-variant: oldstyle-nums all-small-caps;
}
/* @top-center {
margin-top: 1.15em;
......
......@@ -23014,6 +23014,11 @@
display: block;
}
.pagedjs_pages > .pagedjs_page > .pagedjs_area > div [data-split-to] {
margin-bottom: unset;
padding-bottom: unset;
}
.pagedjs_pages > .pagedjs_page > .pagedjs_area > div [data-split-from] {
text-indent: unset;
margin-top: unset;
......@@ -23482,9 +23487,11 @@
let declarations = this.replaceDeclartations(node);
if (declarations.size) {
page.size = declarations.size;
page.width = declarations.size.width;
page.height = declarations.size.height;
page.orientation = declarations.size.orientation;
page.format = declarations.size.format;
}
if (declarations.margin) {
......@@ -23525,18 +23532,20 @@
if ("*" in this.pages) {
let width = this.pages["*"].width;
let height = this.pages["*"].height;
let format = this.pages["*"].format;
let orientation = this.pages["*"].orientation;
if ((width && height) &&
(this.width !== width || this.height !== height)) {
this.width = width;
this.height = height;
this.format = format;
this.orientation = orientation;
this.addRootVars(ast, width, height);
this.addRootPage(ast, width, height);
this.addRootVars(ast, width, height, orientation);
this.addRootPage(ast, this.pages["*"].size);
this.emit("size", { width, height, orientation });
this.emit("size", { width, height, orientation, format });
}
}
......@@ -23652,7 +23661,7 @@
}
getSize(declaration) {
let width, height, orientation;
let width, height, orientation, format;
// Get size: Xmm Ymm
lib.walk(declaration, {
......@@ -23693,6 +23702,7 @@
width = s.width;
height = s.height;
}
format = name;
}
}
});
......@@ -23700,7 +23710,8 @@
return {
width,
height,
orientation
orientation,
format
}
}
......@@ -23807,7 +23818,7 @@
this.addMarginVars(page.margin, children, children.first());
if (page.width) {
this.addDimensions(page.width, page.height, children, children.first());
this.addDimensions(page.width, page.height, page.orientation, children, children.first());
}
if (page.marginalia) {
......@@ -23836,22 +23847,33 @@
}
}
addDimensions(width, height, list, item) {
addDimensions(width, height, orientation, list, item) {
let outputWidth, outputHeight;
if (!orientation || orientation === "portrait") {
outputWidth = width;
outputHeight = height;
} else {
outputWidth = height;
outputHeight = width;
}
// width variable
let wVar = this.createVariable("--width", width.value + (width.unit || ''));
let wVar = this.createVariable("--width", outputWidth.value + (outputWidth.unit || ''));
list.appendData(wVar);
// height variable
let hVar = this.createVariable("--height", height.value + (height.unit || ''));
let hVar = this.createVariable("--height", outputHeight.value + (outputHeight.unit || ''));
list.appendData(hVar);
// width dimension
let w = this.createDimension("width", width.value, width.unit);
let w = this.createDimension("width", outputWidth.value, outputWidth.unit);
list.appendData(w);
// height dimension
let h = this.createDimension("height", height.value, height.unit);
let h = this.createDimension("height", outputHeight.value, outputHeight.unit);
list.appendData(h);
}
addMarginaliaStyles(page, list, item, sheet) {
......@@ -24015,7 +24037,7 @@
}
}
addRootVars(ast, width, height) {
addRootVars(ast, width, height, orientation) {
let selectors = new lib.List();
selectors.insertData({
type: "PseudoClassSelector",
......@@ -24023,44 +24045,72 @@
children: null
});
// width variable
let wVar = this.createVariable("--width", width.value + (width.unit || ''));
// orientation variable
let oVar = this.createVariable("--orientation", orientation || "");
// height variable
let hVar = this.createVariable("--height", height.value + (height.unit || ''));
let widthString, heightString;
if (!orientation || orientation === "portrait") {
widthString = width.value + (width.unit || '');
heightString = height.value + (height.unit || '');
} else {
widthString = height.value + (height.unit || '');
heightString = width.value + (width.unit || '');
}
let rule = this.createRule(selectors, [wVar, hVar]);
let wVar = this.createVariable("--width", widthString);
let hVar = this.createVariable("--height", heightString);
let rule = this.createRule(selectors, [wVar, hVar, oVar]);
ast.children.appendData(rule);
}
addRootPage(ast, width, height) {
/*
@page {
size: var(--width) var(--height);
margin: 0;
padding: 0;
}
*/
/*
@page {
size: var(--width) var(--height);
margin: 0;
padding: 0;
}
*/
addRootPage(ast, size) {
let { width, height, orientation, format } = size;
let children = new lib.List();
let dimensions = new lib.List();
dimensions.appendData({
type: 'Dimension',
unit: width.unit,
value: width.value
});
if (format) {
dimensions.appendData({
type: 'Identifier',
name: format
});
dimensions.appendData({
type: 'WhiteSpace',
value: " "
});
if (orientation) {
dimensions.appendData({
type: 'WhiteSpace',
value: " "
});
dimensions.appendData({
type: 'Dimension',
unit: height.unit,
value: height.value
});
dimensions.appendData({
type: 'Identifier',
name: orientation
});
}
} else {
dimensions.appendData({
type: 'Dimension',
unit: width.unit,
value: width.value
});
dimensions.appendData({
type: 'WhiteSpace',
value: " "
});
dimensions.appendData({
type: 'Dimension',
unit: height.unit,
value: height.value
});
}
children.appendData({
type: 'Declaration',
......@@ -24706,10 +24756,47 @@
}
class Splits extends Handler {
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
}
// layout(pageElement, page) {
//
// }
afterPageLayout(pageElement, page, breakToken, chunker) {
let splits = Array.from(pageElement.querySelectorAll("[data-split-from]"));
let pages = pageElement.parentNode;
let index = Array.prototype.indexOf.call(pages.children, pageElement);
let prevPage;
if (index === 0) {
return;
}
prevPage = pages.children[index - 1];
splits.forEach((split) => {
let ref = split.dataset.ref;
let from = prevPage.querySelector("[data-ref='"+ ref +"']:not([data-split-to])");
if (from) {
from.dataset.splitTo = ref;
if (!from.dataset.splitFrom) {
from.dataset.splitOriginal = true;
}
}
});
}
}
var pagedMediaHandlers = [
AtPage,
Breaks,
PrintMedia
PrintMedia,
Splits
];
class RunningHeaders extends Handler {
......@@ -25514,7 +25601,7 @@
return arr;
};
var from = isImplemented$3()
var from_1 = isImplemented$3()
? Array.from
: shim$4;
......@@ -25612,7 +25699,7 @@
delete desc.set;
}
desc.value = function () {
var i, emitter, data = from(pipes);
var i, emitter, data = from_1(pipes);
emit.apply(this, arguments);
for (i = 0; (emitter = data[i]); ++i) emit.apply(emitter, arguments);
};
......@@ -25664,7 +25751,9 @@
height: {
value: 11,
unit: "in"
}
},
format: undefined,
orientation: undefined
};
let counter = 0;
......@@ -25766,9 +25855,9 @@
let endTime = performance.now();
let msg = "Rendering " + flow.total + " pages took " + (endTime - startTime) + " milliseconds.";
this.emit("rendered", msg, this.size.width && this.size.width.value + this.size.width.unit, this.size.height && this.size.height.value + this.size.height.unit, this.size.orientation);
this.emit("rendered", msg, this.size.width && this.size.width.value + this.size.width.unit, this.size.height && this.size.height.value + this.size.height.unit, this.size.orientation, this.size.format);
if (typeof window.onPagesRendered !== "undefined") {
window.onPagesRendered(msg, this.size.width && this.size.width.value + this.size.width.unit, this.size.height && this.size.height.value + this.size.height.unit, this.size.orientation);
window.onPagesRendered(msg, this.size.width && this.size.width.value + this.size.width.unit, this.size.height && this.size.height.value + this.size.height.unit, this.size.orientation, this.size.format);
}
return flow;
......
......@@ -23014,6 +23014,11 @@
display: block;
}
.pagedjs_pages > .pagedjs_page > .pagedjs_area > div [data-split-to] {
margin-bottom: unset;
padding-bottom: unset;
}
.pagedjs_pages > .pagedjs_page > .pagedjs_area > div [data-split-from] {
text-indent: unset;
margin-top: unset;
......@@ -23482,9 +23487,11 @@
let declarations = this.replaceDeclartations(node);
if (declarations.size) {
page.size = declarations.size;
page.width = declarations.size.width;
page.height = declarations.size.height;
page.orientation = declarations.size.orientation;
page.format = declarations.size.format;
}
if (declarations.margin) {
......@@ -23525,18 +23532,20 @@
if ("*" in this.pages) {
let width = this.pages["*"].width;
let height = this.pages["*"].height;
let format = this.pages["*"].format;
let orientation = this.pages["*"].orientation;
if ((width && height) &&
(this.width !== width || this.height !== height)) {
this.width = width;
this.height = height;
this.format = format;
this.orientation = orientation;
this.addRootVars(ast, width, height);
this.addRootPage(ast, width, height);
this.addRootVars(ast, width, height, orientation);
this.addRootPage(ast, this.pages["*"].size);
this.emit("size", { width, height, orientation });
this.emit("size", { width, height, orientation, format });
}
}
......@@ -23652,7 +23661,7 @@
}
getSize(declaration) {
let width, height, orientation;
let width, height, orientation, format;
// Get size: Xmm Ymm
lib.walk(declaration, {
......@@ -23693,6 +23702,7 @@
width = s.width;
height = s.height;
}
format = name;
}
}
});
......@@ -23700,7 +23710,8 @@
return {
width,
height,
orientation
orientation,
format
}
}
......@@ -23807,7 +23818,7 @@
this.addMarginVars(page.margin, children, children.first());
if (page.width) {
this.addDimensions(page.width, page.height, children, children.first());
this.addDimensions(page.width, page.height, page.orientation, children, children.first());
}
if (page.marginalia) {
......@@ -23836,22 +23847,33 @@
}
}
addDimensions(width, height, list, item) {
addDimensions(width, height, orientation, list, item) {
let outputWidth, outputHeight;
if (!orientation || orientation === "portrait") {
outputWidth = width;
outputHeight = height;
} else {
outputWidth = height;
outputHeight = width;
}
// width variable
let wVar = this.createVariable("--width", width.value + (width.unit || ''));
let wVar = this.createVariable("--width", outputWidth.value + (outputWidth.unit || ''));
list.appendData(wVar);
// height variable
let hVar = this.createVariable("--height", height.value + (height.unit || ''));
let hVar = this.createVariable("--height", outputHeight.value + (outputHeight.unit || ''));
list.appendData(hVar);
// width dimension
let w = this.createDimension("width", width.value, width.unit);
let w = this.createDimension("width", outputWidth.value, outputWidth.unit);
list.appendData(w);
// height dimension
let h = this.createDimension("height", height.value, height.unit);
let h = this.createDimension("height", outputHeight.value, outputHeight.unit);
list.appendData(h);
}
addMarginaliaStyles(page, list, item, sheet) {
......@@ -24015,7 +24037,7 @@
}
}
addRootVars(ast, width, height) {
addRootVars(ast, width, height, orientation) {
let selectors = new lib.List();
selectors.insertData({
type: "PseudoClassSelector",
......@@ -24023,44 +24045,72 @@
children: null
});
// width variable
let wVar = this.createVariable("--width", width.value + (width.unit || ''));
// orientation variable
let oVar = this.createVariable("--orientation", orientation || "");
// height variable
let hVar = this.createVariable("--height", height.value + (height.unit || ''));
let widthString, heightString;
if (!orientation || orientation === "portrait") {
widthString = width.value + (width.unit || '');
heightString = height.value + (height.unit || '');
} else {
widthString = height.value + (height.unit || '');
heightString = width.value + (width.unit || '');
}
let rule = this.createRule(selectors, [wVar, hVar]);
let wVar = this.createVariable("--width", widthString);
let hVar = this.createVariable("--height", heightString);
let rule = this.createRule(selectors, [wVar, hVar, oVar]);
ast.children.appendData(rule);
}
addRootPage(ast, width, height) {
/*
@page {
size: var(--width) var(--height);
margin: 0;
padding: 0;
}
*/
/*
@page {
size: var(--width) var(--height);
margin: 0;
padding: 0;
}
*/
addRootPage(ast, size) {
let { width, height, orientation, format } = size;
let children = new lib.List();
let dimensions = new lib.List();
dimensions.appendData({
type: 'Dimension',
unit: width.unit,
value: width.value
});
if (format) {
dimensions.appendData({
type: 'Identifier',
name: format
});
dimensions.appendData({
type: 'WhiteSpace',
value: " "
});
if (orientation) {
dimensions.appendData({
type: 'WhiteSpace',
value: " "
});
dimensions.appendData({
type: 'Dimension',
unit: height.unit,
value: height.value
});
dimensions.appendData({
type: 'Identifier',
name: orientation
});
}
} else {
dimensions.appendData({
type: 'Dimension',
unit: width.unit,
value: width.value
});
dimensions.appendData({
type: 'WhiteSpace',
value: " "
});
dimensions.appendData({
type: 'Dimension',
unit: height.unit,
value: height.value
});
}
children.appendData({
type: 'Declaration',
......@@ -24706,10 +24756,47 @@
}
class Splits extends Handler {
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
}
// layout(pageElement, page) {
//
// }
afterPageLayout(pageElement, page, breakToken, chunker) {
let splits = Array.from(pageElement.querySelectorAll("[data-split-from]"));
let pages = pageElement.parentNode;
let index = Array.prototype.indexOf.call(pages.children, pageElement);
let prevPage;
if (index === 0) {
return;
}
prevPage = pages.children[index - 1];
splits.forEach((split) => {
let ref = split.dataset.ref;
let from = prevPage.querySelector("[data-ref='"+ ref +"']:not([data-split-to])");
if (from) {
from.dataset.splitTo = ref;
if (!from.dataset.splitFrom) {
from.dataset.splitOriginal = true;
}
}
});
}
}
var pagedMediaHandlers = [
AtPage,
Breaks,
PrintMedia
PrintMedia,
Splits
];
class RunningHeaders extends Handler {
......@@ -25514,7 +25601,7 @@
return arr;
};
var from = isImplemented$3()
var from_1 = isImplemented$3()
? Array.from
: shim$4;
......@@ -25612,7 +25699,7 @@
delete desc.set;
}
desc.value = function () {
var i, emitter, data = from(pipes);
var i, emitter, data = from_1(pipes);
emit.apply(this, arguments);
for (i = 0; (emitter = data[i]); ++i) emit.apply(emitter, arguments);
};
......@@ -25658,7 +25745,9 @@
height: {
value: 11,
unit: "in"
}
},
format: undefined,
orientation: undefined
};
let counter = 0;
......@@ -25760,9 +25849,9 @@
let endTime = performance.now();
let msg = "Rendering " + flow.total + " pages took " + (endTime - startTime) + " milliseconds.";
this.emit("rendered", msg, this.size.width && this.size.width.value + this.size.width.unit, this.size.height && this.size.height.value + this.size.height.unit, this.size.orientation);
this.emit("rendered", msg, this.size.width && this.size.width.value + this.size.width.unit, this.size.height && this.size.height.value + this.size.height.unit, this.size.orientation, this.size.format);
if (typeof window.onPagesRendered !== "undefined") {
window.onPagesRendered(msg, this.size.width && this.size.width.value + this.size.width.unit, this.size.height && this.size.height.value + this.size.height.unit, this.size.orientation);
window.onPagesRendered(msg, this.size.width && this.size.width.value + this.size.width.unit, this.size.height && this.size.height.value + this.size.height.unit, this.size.orientation, this.size.format);
}
return flow;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment