decor-6-site/assets/js/plugins/decor-blockquote.js
2026-03-24 00:46:25 +01:00

32 lines
No EOL
1.3 KiB
JavaScript

class blockquoteDecor extends Paged.Handler {
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
this.symbol = ".";
}
afterPageLayout(pageElement, page, breakToken) {
let blockquotes = pageElement.querySelectorAll("blockquote");
blockquotes.forEach((blockquote) => {
const container = document.createElement("div");
container.className = "before-blockquote_container";
const inner = document.createElement("div");
inner.className = "before-blockquote";
inner.textContent = this.symbol.repeat(300);
container.appendChild(inner);
blockquote.insertBefore(container, blockquote.firstChild);
container.style.height = `${blockquote.offsetHeight}px`;
const containerAfter = document.createElement("div");
containerAfter.className = "after-blockquote_container";
const innerAfter = document.createElement("div");
innerAfter.className = "after-blockquote";
innerAfter.textContent = this.symbol.repeat(300);
containerAfter.appendChild(innerAfter);
blockquote.insertBefore(containerAfter, container.nextSibling);
containerAfter.style.height = `${blockquote.offsetHeight}px`;
});
}
}
Paged.registerHandlers(blockquoteDecor);