Commit 1cd1b7d6 authored by AGLANPC\aglan's avatar AGLANPC\aglan

dfhgkfghkhtdg

parent 13e4cefa
{
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"lucide-react": "^0.469.0",
"react": "^18.3.1",
......
......@@ -170,3 +170,61 @@ export const listRepoBranches = (token, repoId) =>
export const createKBFromRepo = (token, repoId, data) =>
request("POST", `/gitlab/user/repos/${repoId}/create-kb`, token, data);
// ═══════════════════════════════════════════════════
// Utilities & New Exports
// ═══════════════════════════════════════════════════
export function extractCodeBlocks(text) {
if (!text) return [];
const blocks = [];
const regex = /```([\w:.-]+)?\n([\s\S]*?)```/g;
let match;
while ((match = regex.exec(text)) !== null) {
const rawLang = match[1] || "";
let language = rawLang;
let filename = null;
if (rawLang.includes(":")) {
const parts = rawLang.split(":");
language = parts[0];
filename = parts.slice(1).join(":");
}
blocks.push({ language, filename, code: match[2].trim() });
}
return blocks;
}
export const commitFromChat = (token, chatId, data) =>
request("POST", `/chats/${chatId}/commit`, token, data);
export const exportPptx = async (token, markdown, title) => {
const res = await fetch(`${BASE}/export/pptx`, {
method: "POST",
headers: headers(token),
body: JSON.stringify({ markdown, title })
});
if (!res.ok) throw new Error("PPTX export failed");
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `${title || "Presentation"}.pptx`;
a.click();
URL.revokeObjectURL(url);
};
export const exportDocx = async (token, markdown, title) => {
const res = await fetch(`${BASE}/export/docx`, {
method: "POST",
headers: headers(token),
body: JSON.stringify({ markdown, title })
});
if (!res.ok) throw new Error("DOCX export failed");
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `${title || "Document"}.docx`;
a.click();
URL.revokeObjectURL(url);
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment