Commit 8f747e9f authored by julien's avatar julien

turn styles into class fot the text-align-last

parent 63686db9
import Handler from "../handler";
class Splits extends Handler {
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
}
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;
}
this.handleAlignment(from);
}
});
}
handleAlignment(node) {
let styles = window.getComputedStyle(node);
let align = styles["text-align"];
let alignLast = styles["text-align-last"];
if (align === "justify" && alignLast === "auto") {
node.style["text-align-last"] = "justify";
}
}
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
}
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;
}
this.handleAlignment(from);
}
});
}
handleAlignment(node) {
let styles = window.getComputedStyle(node);
let align = styles["text-align"];
let alignLast = styles["text-align-last"];
if (align === "justify" && alignLast === "auto") {
node.classList.add("node-align-last");
}
}
}
export default Splits;
......@@ -488,4 +488,8 @@ img {
height: 100% !important;
}
}
.node-align-last [data-split-original="true"] {
text-align-last: justify;
}
`;
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