@8btc/office-assistant-mcp 0.0.10 → 0.0.12
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.cjs +29 -28
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -74950,16 +74950,16 @@ const CodeBlock = ({ inline, className, children, ...props }) => {
|
|
|
74950
74950
|
}
|
|
74951
74951
|
) }) : /* @__PURE__ */ jsxRuntime.jsx("code", { ...props, className, children });
|
|
74952
74952
|
};
|
|
74953
|
-
const imgRegex = /!\[(.*?)\]\((.*?)\)/g;
|
|
74954
|
-
const windowsPattern = /[a-zA-Z]:(?:\\|\/)[^\s"'`<>|?*]*(?:[\\/][^\s"'`<>|?*]*)*/g;
|
|
74955
74953
|
const replaceMarkdown = (mdContent) => {
|
|
74956
|
-
|
|
74954
|
+
const imgRegex = /!\[(.*?)\]\((.*?)\)/g;
|
|
74955
|
+
const windowsPattern = /[a-zA-Z]:(?:\\|\/)[^\s"'`<>|?*]*(?:[\\/][^\s"'`<>|?*]*)*/g;
|
|
74956
|
+
return mdContent.replace(imgRegex, (m) => {
|
|
74957
74957
|
let match;
|
|
74958
74958
|
let result = "";
|
|
74959
74959
|
while ((match = imgRegex.exec(m)) !== null) {
|
|
74960
74960
|
const [, alt, src] = match;
|
|
74961
74961
|
if (windowsPattern.test(src)) {
|
|
74962
|
-
result = `})`;
|
|
74962
|
+
result = `}")`;
|
|
74963
74963
|
}
|
|
74964
74964
|
}
|
|
74965
74965
|
return result || m;
|
|
@@ -74979,7 +74979,9 @@ const MarkdownRenderer = (props) => {
|
|
|
74979
74979
|
}
|
|
74980
74980
|
]
|
|
74981
74981
|
],
|
|
74982
|
-
components: {
|
|
74982
|
+
components: {
|
|
74983
|
+
code: CodeBlock
|
|
74984
|
+
},
|
|
74983
74985
|
children: replaceMarkdown(markDownContent || "")
|
|
74984
74986
|
}
|
|
74985
74987
|
);
|
|
@@ -74992,7 +74994,7 @@ const Segment = ({ data }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className
|
|
|
74992
74994
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pdf-columns-2 markdown-body", children: [
|
|
74993
74995
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "lv1Title", children: data.title }),
|
|
74994
74996
|
!!data.content && /* @__PURE__ */ jsxRuntime.jsx(MarkdownRenderer, { markDownContent: data.content }),
|
|
74995
|
-
data.
|
|
74997
|
+
data.childrens?.map((it, idx) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
74996
74998
|
!!it.title && /* @__PURE__ */ jsxRuntime.jsx(Lv2Title, { children: it.title }),
|
|
74997
74999
|
!!it.content && /* @__PURE__ */ jsxRuntime.jsx(MarkdownRenderer, { markDownContent: it.content })
|
|
74998
75000
|
] }, idx))
|
|
@@ -76907,7 +76909,7 @@ const renderEnd = (data) => {
|
|
|
76907
76909
|
const paragraph = zod.z.object({
|
|
76908
76910
|
title: zod.z.string().optional().describe("一级标题"),
|
|
76909
76911
|
content: zod.z.string().optional().describe("内容"),
|
|
76910
|
-
|
|
76912
|
+
childrens: zod.z.array(
|
|
76911
76913
|
zod.z.object({
|
|
76912
76914
|
title: zod.z.string().optional().describe("二级标题"),
|
|
76913
76915
|
content: zod.z.string().optional().describe("内容")
|
|
@@ -76923,9 +76925,7 @@ const basePdfSchema = {
|
|
|
76923
76925
|
footer: zod.z.string().describe("报告页脚内容"),
|
|
76924
76926
|
reference: zod.z.string().describe("报告引用"),
|
|
76925
76927
|
paragraph: zod.z.array(paragraph).describe("报告内容"),
|
|
76926
|
-
disclaimer: zod.z.string().optional().describe("ai生成声明")
|
|
76927
|
-
// todo: delete
|
|
76928
|
-
markdown: zod.z.string().optional().describe("markdown")
|
|
76928
|
+
disclaimer: zod.z.string().optional().describe("ai生成声明")
|
|
76929
76929
|
};
|
|
76930
76930
|
zod.z.object({
|
|
76931
76931
|
...basePdfSchema
|
|
@@ -77023,13 +77023,16 @@ const extractAllImageSrc = (html2) => {
|
|
|
77023
77023
|
logger.info("extractAllImageSrc match[0]:" + match[0], match[1]);
|
|
77024
77024
|
logger.info("extractAllImageSrc match[1]:" + match[1]);
|
|
77025
77025
|
}
|
|
77026
|
-
|
|
77027
|
-
|
|
77026
|
+
const decodedSrc = decodeURIComponent(match[1]);
|
|
77027
|
+
if (isLocalPath(decodedSrc)) {
|
|
77028
|
+
srcs.push({
|
|
77029
|
+
src: decodedSrc,
|
|
77030
|
+
originSrc: match[1]
|
|
77031
|
+
});
|
|
77028
77032
|
}
|
|
77029
77033
|
}
|
|
77030
77034
|
return srcs;
|
|
77031
77035
|
};
|
|
77032
|
-
const reg = /<img[^>]+>/gi;
|
|
77033
77036
|
const createPage = async (page, item) => {
|
|
77034
77037
|
const {
|
|
77035
77038
|
tempFileName,
|
|
@@ -77047,27 +77050,29 @@ const createPage = async (page, item) => {
|
|
|
77047
77050
|
</header>
|
|
77048
77051
|
`;
|
|
77049
77052
|
const localSrcs = extractAllImageSrc(html2);
|
|
77050
|
-
logger.info("localSrcs:::" + localSrcs.join(","));
|
|
77051
77053
|
const localFileInfoList = await Promise.all(
|
|
77052
77054
|
localSrcs.map(
|
|
77053
|
-
(
|
|
77054
|
-
localImageToBase64(src).then((fileInfo) => {
|
|
77055
|
-
resolve(
|
|
77055
|
+
(srcInfo) => new Promise((resolve) => {
|
|
77056
|
+
localImageToBase64(srcInfo.src).then((fileInfo) => {
|
|
77057
|
+
resolve({
|
|
77058
|
+
...fileInfo,
|
|
77059
|
+
// 原本没转换的地址
|
|
77060
|
+
originSrc: srcInfo.originSrc
|
|
77061
|
+
});
|
|
77056
77062
|
}).catch(() => {
|
|
77057
77063
|
resolve("");
|
|
77058
77064
|
});
|
|
77059
77065
|
})
|
|
77060
77066
|
)
|
|
77061
77067
|
);
|
|
77068
|
+
const reg = /<img[^>]+>/gi;
|
|
77062
77069
|
const _html = html2.replaceAll(reg, (m) => {
|
|
77063
|
-
const item2 = localFileInfoList.find(
|
|
77064
|
-
|
|
77065
|
-
);
|
|
77070
|
+
const item2 = localFileInfoList.find((info) => {
|
|
77071
|
+
return m.indexOf(info?.originSrc || "") !== -1;
|
|
77072
|
+
});
|
|
77066
77073
|
if (item2) {
|
|
77067
|
-
|
|
77068
|
-
|
|
77069
|
-
`$1src="${item2.base64}"$2`
|
|
77070
|
-
);
|
|
77074
|
+
const regByGroup = /(<img[^>]*?)src=["'][^"']*["']([^>]*>)/gi;
|
|
77075
|
+
return m.replace(regByGroup, `$1src="${item2.base64}"$2`);
|
|
77071
77076
|
}
|
|
77072
77077
|
return m;
|
|
77073
77078
|
});
|
|
@@ -77252,10 +77257,6 @@ const tool = {
|
|
|
77252
77257
|
const toolHandler = async (args) => {
|
|
77253
77258
|
try {
|
|
77254
77259
|
logger.info(`start: ${(/* @__PURE__ */ new Date()).getTime()}`);
|
|
77255
|
-
try {
|
|
77256
|
-
logger.info(JSON.stringify(args));
|
|
77257
|
-
} catch (e) {
|
|
77258
|
-
}
|
|
77259
77260
|
const generatedTemplates = await generateBasePdf(args);
|
|
77260
77261
|
const pdfUrl = await generatePDF({
|
|
77261
77262
|
list: generatedTemplates,
|