snap to baseline for columns
This commit is contained in:
parent
a51a86aa6f
commit
030e27bfac
1 changed files with 4 additions and 10 deletions
|
|
@ -12,7 +12,7 @@ export default class snapToBaseline extends Handler {
|
|||
content.querySelectorAll('blockquote').forEach((bq) => {
|
||||
const prev = bq.previousElementSibling;
|
||||
if (!prev || prev.nodeName !== 'P') {
|
||||
bq.style.color = 'red';
|
||||
// bq.style.color = 'red';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -23,10 +23,7 @@ export default class snapToBaseline extends Handler {
|
|||
if (!shouldSnap(node)) return node;
|
||||
const area = node.closest('.pagedjs_area');
|
||||
if (area) {
|
||||
const areaRect = area.getBoundingClientRect();
|
||||
// getClientRects()[0] = premier fragment (colonne 1 si le paragraphe
|
||||
// s'étend sur 2 colonnes). getBoundingClientRect().top retournerait
|
||||
// le minimum des deux tops, soit le haut de la colonne 2 — incorrect.
|
||||
const areaRect = area.getBoundingClientRect(); // cible les paragraphes sur 2 colonnes
|
||||
const firstRect = node.getClientRects()[0];
|
||||
if (!firstRect) return node;
|
||||
const relativeTop = firstRect.top - areaRect.top;
|
||||
|
|
@ -34,7 +31,6 @@ export default class snapToBaseline extends Handler {
|
|||
|
||||
if (modulo !== 0) {
|
||||
node.style.paddingTop = (this.baseline - modulo) + 'px';
|
||||
node.style.color = "green";
|
||||
}
|
||||
}
|
||||
return node;
|
||||
|
|
@ -54,10 +50,8 @@ export default class snapToBaseline extends Handler {
|
|||
const firstRect = node.getClientRects()[0];
|
||||
if (!firstRect) return;
|
||||
|
||||
// firstRect.bottom = bas du premier fragment (colonne 1 pour un paragraphe
|
||||
// qui s'étend sur 2 colonnes). Cela permet de cibler correctement les
|
||||
// paragraphes dont la première partie touche le bas de la colonne.
|
||||
if (firstRect.bottom < areaRect.bottom - this.baseline) return;
|
||||
|
||||
if (firstRect.bottom < areaRect.bottom - this.baseline) return; // cible les paragraphes qui sont sur 2 colonnes
|
||||
|
||||
const relativeTop = firstRect.top - areaRect.top;
|
||||
const modulo = relativeTop % this.baseline;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue