增加阅读是pdf中高亮显示
This commit is contained in:
@@ -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)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user