Commit 489ce7b7 authored by Fred Chasen's avatar Fred Chasen

Fix alignment for last split element

parent d0bbb3e6
......@@ -21,7 +21,7 @@
box-shadow: 0 0 0 1px rgba(0, 0,0,0.2);
}
.pagedjs_page {
.pagedjs_pagebox {
box-shadow: 0 0 0 1px rgba(200, 0,0,0.2);
}
}
......
......@@ -17,9 +17,10 @@ class Splits extends Handler {
prevPage = pages.children[index - 1];
let from; // Capture the last from element
splits.forEach((split) => {
let ref = split.dataset.ref;
let from = prevPage.querySelector("[data-ref='"+ ref +"']:not([data-split-to])");
from = prevPage.querySelector("[data-ref='"+ ref +"']:not([data-split-to])");
if (from) {
from.dataset.splitTo = ref;
......@@ -27,18 +28,24 @@ class Splits extends Handler {
if (!from.dataset.splitFrom) {
from.dataset.splitOriginal = true;
}
this.handleAlignment(from);
}
});
// Fix alignment on the deepest split element
if (from) {
this.handleAlignment(from);
}
}
handleAlignment(node) {
let styles = window.getComputedStyle(node);
let align = styles["text-align"];
let alignLast = styles["text-align-last"];
node.dataset.lastSplitElement = "true";
if (align === "justify" && alignLast === "auto") {
node.classList.add("last-item-justify");
node.dataset.alignLastSplitElement = "justify";
} else {
node.dataset.alignLastSplitElement = alignLast;
}
}
......
......@@ -557,10 +557,11 @@ img {
height: auto;
}
.last-item-justify {
p[data-align-last-split-element='justify'] {
text-align-last: justify;
}
@media print {
html {
width: 100%;
......
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