调整了目录结构
This commit is contained in:
1 parent
f1ba28550a
commit
6ec5e1404f
17 files changed
+60
-46
No files matched your search
@@ -17,6 +17,7 @@ type IndexItemLayout = {
|
||||
top: number;
|
||||
width: number;
|
||||
height: number;
|
||||
fontSize: number;
|
||||
};
|
||||
|
||||
const PDF_PAGE_HEIGHT_PT = 842;
|
||||
@@ -255,6 +256,12 @@ export class IndexBuilder {
|
||||
const titleEl = item.querySelector("page_title") as any;
|
||||
const itemRect = item.getBoundingClientRect();
|
||||
const titleRect = titleEl?.getBoundingClientRect() ?? itemRect;
|
||||
const computedStyle = titleEl
|
||||
? globalThis.getComputedStyle(titleEl)
|
||||
: null;
|
||||
const fontSizePx = computedStyle
|
||||
? Number.parseFloat(computedStyle.fontSize || "0")
|
||||
: 0;
|
||||
const pageIndex = Math.floor(
|
||||
(itemRect.bottom - 1) / printableHeightPx,
|
||||
);
|
||||
@@ -263,8 +270,9 @@ export class IndexBuilder {
|
||||
pageIndex,
|
||||
left: titleRect.left,
|
||||
width: titleRect.width,
|
||||
top: itemRect.top - pageTopPx,
|
||||
height: itemRect.height,
|
||||
top: titleRect.top - pageTopPx,
|
||||
height: titleRect.height,
|
||||
fontSize: fontSizePx,
|
||||
};
|
||||
});
|
||||
},
|
||||
@@ -391,6 +399,7 @@ export class IndexBuilder {
|
||||
left: number;
|
||||
width: number;
|
||||
height: number;
|
||||
fontSize: number;
|
||||
}>,
|
||||
inserted_index_pages: number,
|
||||
insert_index_after_page: number,
|
||||
@@ -425,6 +434,7 @@ export class IndexBuilder {
|
||||
const layoutLeftPt = layout.left * CSS_PX_TO_PT;
|
||||
const layoutWidthPt = layout.width * CSS_PX_TO_PT;
|
||||
const layoutHeightPt = layout.height * CSS_PX_TO_PT;
|
||||
const fontSizePt = layout.fontSize * CSS_PX_TO_PT;
|
||||
const xLeft = Math.max(layoutLeftPt, 0);
|
||||
const xRight = Math.min(layoutLeftPt + layoutWidthPt, pageWidth);
|
||||
const mappedPage = this.remap_page_after_index_insert(
|
||||
@@ -448,7 +458,8 @@ export class IndexBuilder {
|
||||
return;
|
||||
}
|
||||
const localTopPt = layout.top * CSS_PX_TO_PT;
|
||||
const yTop = pageHeight - marginTop - localTopPt;
|
||||
const topOffsetPt = layout.pageIndex > 0 ? fontSizePt * 0.5 : 0;
|
||||
const yTop = pageHeight - marginTop - localTopPt - topOffsetPt;
|
||||
const yBottom = yTop - totalHeight;
|
||||
this.add_link_annotation(
|
||||
targetPage as any,
|
||||
|
||||
Reference in new issue
Block a user