feat(viewer): Add pagination metadata and thumbnail offset rendering for viewer thumbnails
This commit is contained in:
@@ -26,6 +26,12 @@ import { DeContentInvoice } from "./contentinvoice.js";
|
||||
|
||||
import { demoFunc } from "./document.demo.js";
|
||||
|
||||
export interface IPagePaginationInfo {
|
||||
pageNumber: number;
|
||||
startOffset: number;
|
||||
contentLength: number;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"dedocument-dedocument": DeDocument;
|
||||
@@ -142,10 +148,12 @@ export class DeDocument extends DeesElement {
|
||||
null;
|
||||
public latestRenderedLetterData: plugins.tsclass.business.TLetter = null;
|
||||
public cleanupStore: any[] = [];
|
||||
public paginationInfo: IPagePaginationInfo[] = [];
|
||||
|
||||
public async renderDocument() {
|
||||
this.latestDocumentSettings = this.documentSettings;
|
||||
this.latestRenderedLetterData = this.letterData;
|
||||
this.paginationInfo = [];
|
||||
|
||||
const cleanUpStoreCurrentRender = [];
|
||||
const cleanUpStoreNextRender = [];
|
||||
@@ -198,7 +206,16 @@ export class DeDocument extends DeesElement {
|
||||
newPageOverflows = await newPage.checkOverflow();
|
||||
}
|
||||
currentContentOffset = await currentContent.getContentLength();
|
||||
const pageStartOffset = overallContentOffset;
|
||||
overallContentOffset = overallContentOffset + currentContentOffset;
|
||||
|
||||
// Track pagination info for this page
|
||||
this.paginationInfo.push({
|
||||
pageNumber: pageCounter,
|
||||
startOffset: pageStartOffset,
|
||||
contentLength: currentContentOffset,
|
||||
});
|
||||
|
||||
if (trimmed === 0) {
|
||||
complete = true;
|
||||
}
|
||||
@@ -234,6 +251,16 @@ export class DeDocument extends DeesElement {
|
||||
}
|
||||
}
|
||||
this.adjustDePageScaling();
|
||||
|
||||
// Emit event with pagination info for thumbnails
|
||||
this.dispatchEvent(new CustomEvent('pagination-complete', {
|
||||
detail: {
|
||||
pageCount: pageCounter,
|
||||
paginationInfo: this.paginationInfo,
|
||||
},
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
}));
|
||||
}
|
||||
|
||||
async updated(
|
||||
|
||||
Reference in New Issue
Block a user