@docyrus/ui-pro-ai-assistant 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -12946,17 +12946,27 @@ var DiscussionKit = [discussionPlugin];
|
|
|
12946
12946
|
var useChat = () => {
|
|
12947
12947
|
const editor = useEditorRef();
|
|
12948
12948
|
const { getAccessToken } = useAuthContext();
|
|
12949
|
+
const options3 = usePluginOption(aiChatPlugin, "chatOptions");
|
|
12949
12950
|
const baseChat = useChat$1({
|
|
12950
12951
|
id: "editor",
|
|
12951
12952
|
transport: new DefaultChatTransport({
|
|
12952
|
-
api: "/api/ai/command",
|
|
12953
|
-
|
|
12953
|
+
api: options3?.api || "/api/ai/command",
|
|
12954
|
+
fetch: (async (input, init) => {
|
|
12955
|
+
const bodyOptions = options3?.body;
|
|
12956
|
+
const initBody = init?.body ? JSON.parse(init.body) : {};
|
|
12957
|
+
const body = { ...initBody, ...bodyOptions };
|
|
12954
12958
|
const token = getAccessToken ? await getAccessToken() : null;
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12959
|
+
const res = await fetch(input, {
|
|
12960
|
+
...init,
|
|
12961
|
+
body: JSON.stringify(body),
|
|
12962
|
+
headers: {
|
|
12963
|
+
"Content-Type": "application/json",
|
|
12964
|
+
...token && { Authorization: `Bearer ${token}` },
|
|
12965
|
+
...init?.headers
|
|
12966
|
+
}
|
|
12967
|
+
});
|
|
12968
|
+
return res;
|
|
12969
|
+
})
|
|
12960
12970
|
}),
|
|
12961
12971
|
onData(data) {
|
|
12962
12972
|
if (data.type === "data-toolName") {
|
|
@@ -13022,6 +13032,10 @@ var useChat = () => {
|
|
|
13022
13032
|
// src/internal/plate-editor/editor/plugins/ai-kit.tsx
|
|
13023
13033
|
var aiChatPlugin = AIChatPlugin.extend({
|
|
13024
13034
|
options: {
|
|
13035
|
+
chatOptions: {
|
|
13036
|
+
api: "/api/ai/command",
|
|
13037
|
+
body: {}
|
|
13038
|
+
},
|
|
13025
13039
|
contentRef: null,
|
|
13026
13040
|
scrollRef: null
|
|
13027
13041
|
}
|
|
@@ -22677,7 +22691,7 @@ var AssistantView = ({ ref, ...props }) => {
|
|
|
22677
22691
|
}
|
|
22678
22692
|
)
|
|
22679
22693
|
] }),
|
|
22680
|
-
/* @__PURE__ */ jsx("div", { className: "flex-1 p-4 flex flex-col min-h-0 overflow-hidden", children: renderSidebar() })
|
|
22694
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 p-4 flex flex-col min-h-0 overflow-hidden", children: renderSidebar(true) })
|
|
22681
22695
|
] }) })
|
|
22682
22696
|
] }),
|
|
22683
22697
|
enableSidebar && renderSidebar && /* @__PURE__ */ jsx(
|
|
@@ -22714,7 +22728,7 @@ var AssistantView = ({ ref, ...props }) => {
|
|
|
22714
22728
|
}
|
|
22715
22729
|
)
|
|
22716
22730
|
] }),
|
|
22717
|
-
/* @__PURE__ */ jsx("div", { className: "flex-1 p-4 flex flex-col min-h-0 overflow-hidden", children: renderSidebar() })
|
|
22731
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 p-4 flex flex-col min-h-0 overflow-hidden", children: renderSidebar(false) })
|
|
22718
22732
|
] })
|
|
22719
22733
|
}
|
|
22720
22734
|
),
|
|
@@ -24915,7 +24929,7 @@ var DocyAssistant = ({
|
|
|
24915
24929
|
const query = sessionState.searchQuery.toLowerCase();
|
|
24916
24930
|
return session.title.toLowerCase().includes(query);
|
|
24917
24931
|
});
|
|
24918
|
-
const renderSidebarContent = () => /* @__PURE__ */ jsx(
|
|
24932
|
+
const renderSidebarContent = (isFloating) => /* @__PURE__ */ jsx(
|
|
24919
24933
|
SidebarContent,
|
|
24920
24934
|
{
|
|
24921
24935
|
sessions: sessionState.sessions,
|
|
@@ -24954,7 +24968,7 @@ var DocyAssistant = ({
|
|
|
24954
24968
|
uiActions.setActiveTab(2);
|
|
24955
24969
|
projectActions.setView("create");
|
|
24956
24970
|
},
|
|
24957
|
-
onToggleSidebar: uiState.isExpanded ?
|
|
24971
|
+
onToggleSidebar: isFloating && !uiState.isExpanded ? () => uiActions.setSidebarOpen(false) : void 0,
|
|
24958
24972
|
t
|
|
24959
24973
|
}
|
|
24960
24974
|
);
|