feat(viewer): Add pagination metadata and thumbnail offset rendering for viewer thumbnails
This commit is contained in:
@@ -11,8 +11,9 @@ import {
|
||||
type TemplateResult,
|
||||
} from "@design.estate/dees-element";
|
||||
import { demoFunc } from "./viewer.demo.js";
|
||||
import { DeDocument } from "./document.js";
|
||||
import { DeDocument, type IPagePaginationInfo } from "./document.js";
|
||||
import "./page.js"; // Import DePage for thumbnail rendering
|
||||
import "./contentinvoice.js"; // Import DeContentInvoice for thumbnail content
|
||||
|
||||
import "@design.estate/dees-catalog";
|
||||
|
||||
@@ -105,6 +106,9 @@ export class DeDocumentViewer extends DeesElement {
|
||||
@state()
|
||||
accessor thumbnailPages: number[] = [];
|
||||
|
||||
@state()
|
||||
accessor paginationInfo: IPagePaginationInfo[] = [];
|
||||
|
||||
// Zoom animation
|
||||
private zoomAnimationId: number | null = null;
|
||||
|
||||
@@ -667,8 +671,10 @@ export class DeDocumentViewer extends DeesElement {
|
||||
<div class="${sidebarClasses}" style="width: ${this.sidebarWidth}px;">
|
||||
<div class="sidebar__header">Pages</div>
|
||||
<div class="sidebar__thumbnails">
|
||||
${this.thumbnailPages.map(
|
||||
(_, i) => html`
|
||||
${this.thumbnailPages.map((_, i) => {
|
||||
const pageInfo = this.paginationInfo[i];
|
||||
|
||||
return html`
|
||||
<div
|
||||
class="thumbnail ${currentPage === i + 1 ? "thumbnail--active" : ""}"
|
||||
@click=${() => this.scrollToPage(i + 1)}
|
||||
@@ -689,13 +695,20 @@ export class DeDocumentViewer extends DeesElement {
|
||||
.documentSettings=${this.documentSettings}
|
||||
.pageNumber=${i + 1}
|
||||
.pageTotalNumber=${this.thumbnailPages.length}
|
||||
></dedocument-page>
|
||||
>${pageInfo ? html`
|
||||
<dedocument-contentinvoice
|
||||
.letterData=${this.letterData as unknown as plugins.tsclass.finance.TInvoice}
|
||||
.documentSettings=${this.documentSettings}
|
||||
.renderStartOffset=${pageInfo.startOffset}
|
||||
.renderContentLength=${pageInfo.contentLength}
|
||||
></dedocument-contentinvoice>
|
||||
` : null}</dedocument-page>
|
||||
</div>
|
||||
</div>
|
||||
<span class="thumbnail__label">${i + 1}</span>
|
||||
</div>
|
||||
`
|
||||
)}
|
||||
`;
|
||||
})}
|
||||
</div>
|
||||
<div
|
||||
class="sidebar__resize-handle"
|
||||
@@ -1216,6 +1229,15 @@ export class DeDocumentViewer extends DeesElement {
|
||||
setTimeout(() => this.updateDisplayZoom(), 200);
|
||||
}
|
||||
|
||||
// Listen for pagination-complete event from DeDocument
|
||||
this.addEventListener('pagination-complete', (e: CustomEvent) => {
|
||||
this.paginationInfo = e.detail.paginationInfo;
|
||||
const pageCount = e.detail.pageCount;
|
||||
if (pageCount !== this.thumbnailPages.length) {
|
||||
this.thumbnailPages = Array.from({ length: pageCount }, (_, i) => i);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle viewport resize and scroll
|
||||
const viewport = this.shadowRoot?.querySelector(".viewport");
|
||||
if (viewport) {
|
||||
|
||||
Reference in New Issue
Block a user