增加阅读是pdf中高亮显示

This commit is contained in:
yhy
2026-08-29 22:46:28 +08:00
parent 3a2438f566
commit 1475f8b3c5
17 changed files with 2125 additions and 95 deletions
+49
View File
@@ -0,0 +1,49 @@
/** Helpers for Zotero ItemPane collapsible sections. */
export function prepareItemPaneBody(body: HTMLElement): void {
body.classList.add("chatpapers-pane-body");
body.style.minHeight = "0";
}
export function onItemPaneSectionToggle(options: {
body: HTMLElement;
event?: Event;
}): void {
const section = resolveCollapsibleSection(options.body, options.event);
if (!section) return;
const open = section.hasAttribute("open");
if (open) {
options.body.style.removeProperty("height");
options.body.style.removeProperty("overflow");
options.body.style.minHeight = "0";
const raf = options.body.ownerDocument?.defaultView?.requestAnimationFrame;
const updateHeight = () => {
const h = options.body.scrollHeight;
if (h > 0) {
section.style.setProperty("--open-height", `${h}px`);
}
};
if (raf) raf(updateHeight);
else updateHeight();
return;
}
options.body.style.minHeight = "0";
options.body.style.height = "0";
options.body.style.overflow = "hidden";
section.style.setProperty("--open-height", "0px");
}
function resolveCollapsibleSection(
body: HTMLElement,
event?: Event,
): HTMLElement | null {
const fromEvent = (event?.currentTarget ?? event?.target) as
| HTMLElement
| undefined;
return (
(fromEvent?.closest?.("collapsible-section") as HTMLElement | null) ??
(body.closest("collapsible-section") as HTMLElement | null)
);
}