增加pdf中划句或段ai伴读功能
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user