@8btc/office-assistant-mcp 0.0.6 → 0.0.8
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 +28 -18
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -75977,7 +75977,6 @@ const style = `/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com *
|
|
|
75977
75977
|
.markdown-body ul, .markdown-body ol {
|
|
75978
75978
|
margin-top: 0;
|
|
75979
75979
|
margin-bottom: 0;
|
|
75980
|
-
padding-left: 2em;
|
|
75981
75980
|
}
|
|
75982
75981
|
.markdown-body ol ol, .markdown-body ul ol {
|
|
75983
75982
|
list-style-type: lower-roman;
|
|
@@ -76999,6 +76998,18 @@ const localImageToBase64 = async (imagePath) => {
|
|
|
76999
76998
|
}
|
|
77000
76999
|
return null;
|
|
77001
77000
|
};
|
|
77001
|
+
const extractAllImageSrc = (html2) => {
|
|
77002
|
+
const regex = /<img[^>]*?src=["']([^"']+)["'][^>]*>/gi;
|
|
77003
|
+
const srcs = [];
|
|
77004
|
+
let match;
|
|
77005
|
+
while ((match = regex.exec(html2)) !== null) {
|
|
77006
|
+
if (isLocalPath(match[1])) {
|
|
77007
|
+
srcs.push(match[1]);
|
|
77008
|
+
}
|
|
77009
|
+
}
|
|
77010
|
+
return srcs;
|
|
77011
|
+
};
|
|
77012
|
+
const reg = /<img[^>]+>/gi;
|
|
77002
77013
|
const createPage = async (page, item) => {
|
|
77003
77014
|
const {
|
|
77004
77015
|
tempFileName,
|
|
@@ -77015,12 +77026,10 @@ const createPage = async (page, item) => {
|
|
|
77015
77026
|
</div>
|
|
77016
77027
|
</header>
|
|
77017
77028
|
`;
|
|
77018
|
-
|
|
77019
|
-
|
|
77020
|
-
|
|
77021
|
-
|
|
77022
|
-
const fileInfoArray = await Promise.all(
|
|
77023
|
-
imgElements.filter((src) => isLocalPath(src)).map(
|
|
77029
|
+
const localSrcs = extractAllImageSrc(html2);
|
|
77030
|
+
logger.info("localSrcs:::" + localSrcs.join(","));
|
|
77031
|
+
const localFileInfoList = await Promise.all(
|
|
77032
|
+
localSrcs.map(
|
|
77024
77033
|
(src) => new Promise((resolve) => {
|
|
77025
77034
|
localImageToBase64(src).then((fileInfo) => {
|
|
77026
77035
|
resolve(fileInfo);
|
|
@@ -77030,18 +77039,19 @@ const createPage = async (page, item) => {
|
|
|
77030
77039
|
})
|
|
77031
77040
|
)
|
|
77032
77041
|
);
|
|
77033
|
-
|
|
77034
|
-
|
|
77035
|
-
|
|
77036
|
-
|
|
77042
|
+
const _html = html2.replaceAll(reg, (m) => {
|
|
77043
|
+
const item2 = localFileInfoList.find(
|
|
77044
|
+
(info) => m.indexOf(info.src) !== -1
|
|
77045
|
+
);
|
|
77046
|
+
if (item2) {
|
|
77047
|
+
return m.replace(
|
|
77048
|
+
/(<img[^>]*?)src=["'][^"']*["']([^>]*>)/gi,
|
|
77049
|
+
`$1src="${item2.base64}"$2`
|
|
77037
77050
|
);
|
|
77038
|
-
|
|
77039
|
-
|
|
77040
|
-
|
|
77041
|
-
|
|
77042
|
-
}),
|
|
77043
|
-
fileInfoArray
|
|
77044
|
-
);
|
|
77051
|
+
}
|
|
77052
|
+
return m;
|
|
77053
|
+
});
|
|
77054
|
+
await page.setContent(_html, { waitUntil: "networkidle" });
|
|
77045
77055
|
const pageRes = await page.pdf({
|
|
77046
77056
|
path: tempFileName,
|
|
77047
77057
|
format: "A4",
|