增加pdf中划句或段ai伴读功能

This commit is contained in:
yhy
2026-08-29 23:07:19 +08:00
parent 1475f8b3c5
commit 0ed8f42029
22 changed files with 2045 additions and 15 deletions
+13 -2
View File
@@ -1,7 +1,13 @@
import { config } from "../../../package.json";
import { getLocaleID, getString } from "../../utils/locale";
import { ChatView } from "./chatView";
import { onItemPaneSectionToggle, prepareItemPaneBody } from "./itemPaneSection";
import {
applyAdaptiveHeight,
buildItemPaneSectionButtons,
onItemPaneSectionToggle,
prepareItemPaneBody,
refreshSectionOpenHeight,
} from "./itemPaneSection";
const views = new WeakMap<HTMLElement, ChatView>();
@@ -21,10 +27,12 @@ export function registerChatPane() {
l10nID: getLocaleID("item-section-chat-sidenav"),
icon: iconURL("chat.svg"),
},
sectionButtons: buildItemPaneSectionButtons("chat"),
onInit: ({ body }) => {
const doc = body.ownerDocument;
if (doc) ensureStyles(doc);
prepareItemPaneBody(body);
applyAdaptiveHeight(body, "chat");
},
onDestroy: ({ body }) => {
views.get(body)?.destroy();
@@ -53,8 +61,11 @@ export function registerChatPane() {
const view = new ChatView(doc, body, item);
views.set(body, view);
await view.mount();
applyAdaptiveHeight(body, "chat");
const section = body.closest("collapsible-section");
if (section && !section.hasAttribute("open")) {
if (section?.hasAttribute("open")) {
refreshSectionOpenHeight(body);
} else if (section) {
onItemPaneSectionToggle({ body });
}
},