@rspress-theme-anatole/theme-default 0.5.9 → 0.6.1-alpha
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/bundle.js +99 -2
- package/package.json +5 -4
package/dist/bundle.js
CHANGED
|
@@ -41,6 +41,7 @@ import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_jump_20d3ca88__ from "@theme
|
|
|
41
41
|
import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_title_56a7311e__ from "@theme-assets/title";
|
|
42
42
|
import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_github_cac38251__ from "@theme-assets/github";
|
|
43
43
|
import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_gitlab_a0e4f082__ from "@theme-assets/gitlab";
|
|
44
|
+
import * as __WEBPACK_EXTERNAL_MODULE_html2pdf_js_65368f2c__ from "html2pdf.js";
|
|
44
45
|
|
|
45
46
|
function isMobileDevice() {
|
|
46
47
|
return window.innerWidth < 1280;
|
|
@@ -390,7 +391,7 @@ function DocFooter() {
|
|
|
390
391
|
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
391
392
|
className: "flex flex-col",
|
|
392
393
|
children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.EditLink, {})
|
|
393
|
-
|
|
394
|
+
}),
|
|
394
395
|
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
|
|
395
396
|
className: "flex flex-col sm:flex-row sm:justify-around gap-4 pt-6",
|
|
396
397
|
children: [
|
|
@@ -1225,7 +1226,10 @@ function DocLayout(props) {
|
|
|
1225
1226
|
children: [
|
|
1226
1227
|
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
|
|
1227
1228
|
style: {
|
|
1228
|
-
padding: '0
|
|
1229
|
+
padding: '0 64px 28px 64px',
|
|
1230
|
+
display: 'flex',
|
|
1231
|
+
justifyContent: 'space-between',
|
|
1232
|
+
alignItems: 'center',
|
|
1229
1233
|
},
|
|
1230
1234
|
children: [
|
|
1231
1235
|
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("p", {
|
|
@@ -1251,6 +1255,23 @@ function DocLayout(props) {
|
|
|
1251
1255
|
...breadcrumbNav
|
|
1252
1256
|
]
|
|
1253
1257
|
}),
|
|
1258
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("a", {
|
|
1259
|
+
onClick: exportContentToPDF,
|
|
1260
|
+
children: [
|
|
1261
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("i", {
|
|
1262
|
+
className: "fa-regular fa-file-pdf",
|
|
1263
|
+
}),
|
|
1264
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
1265
|
+
className: "ml-2",
|
|
1266
|
+
children: "Export to PDF"
|
|
1267
|
+
})
|
|
1268
|
+
],
|
|
1269
|
+
style: {
|
|
1270
|
+
fontSize: '15px',
|
|
1271
|
+
fontWeight: '500',
|
|
1272
|
+
cursor: 'pointer',
|
|
1273
|
+
}
|
|
1274
|
+
}),
|
|
1254
1275
|
]
|
|
1255
1276
|
}),
|
|
1256
1277
|
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
|
|
@@ -5454,4 +5475,80 @@ function loadGiscus() {
|
|
|
5454
5475
|
}
|
|
5455
5476
|
}
|
|
5456
5477
|
|
|
5478
|
+
function loadScript(src) {
|
|
5479
|
+
return new Promise((resolve, reject) => {
|
|
5480
|
+
if (document.querySelector(`script[src="${src}"]`)) return resolve();
|
|
5481
|
+
const script = document.createElement('script');
|
|
5482
|
+
script.src = src;
|
|
5483
|
+
script.onload = resolve;
|
|
5484
|
+
script.onerror = reject;
|
|
5485
|
+
document.body.appendChild(script);
|
|
5486
|
+
});
|
|
5487
|
+
}
|
|
5488
|
+
|
|
5489
|
+
function fixMermaidSVGs() {
|
|
5490
|
+
// 选取所有doc中的SVG
|
|
5491
|
+
document.querySelectorAll('.rspress-doc svg').forEach(svg => {
|
|
5492
|
+
// 自动根据内容调整宽高
|
|
5493
|
+
const bbox = svg.getBBox();
|
|
5494
|
+
svg.setAttribute('width', bbox.width + bbox.x);
|
|
5495
|
+
svg.setAttribute('height', bbox.height + bbox.y);
|
|
5496
|
+
svg.setAttribute('viewBox', `${bbox.x} ${bbox.y} ${bbox.width} ${bbox.height}`);
|
|
5497
|
+
svg.style.width = '100%';
|
|
5498
|
+
svg.style.height = 'auto';
|
|
5499
|
+
});
|
|
5500
|
+
}
|
|
5501
|
+
|
|
5502
|
+
async function exportContentToPDF() {
|
|
5503
|
+
// 显示生成中提示
|
|
5504
|
+
let tip = document.createElement('div');
|
|
5505
|
+
tip.id = 'pdf-generating-tip';
|
|
5506
|
+
tip.innerText = 'Generating PDF...';
|
|
5507
|
+
Object.assign(tip.style, {
|
|
5508
|
+
position: 'fixed',
|
|
5509
|
+
top: '50%',
|
|
5510
|
+
left: '50%',
|
|
5511
|
+
transform: 'translate(-50%, -50%)',
|
|
5512
|
+
background: 'rgba(0,0,0,0.8)',
|
|
5513
|
+
color: '#fff',
|
|
5514
|
+
padding: '20px 40px',
|
|
5515
|
+
borderRadius: '8px',
|
|
5516
|
+
zIndex: 9999,
|
|
5517
|
+
fontSize: '18px'
|
|
5518
|
+
});
|
|
5519
|
+
document.body.appendChild(tip);
|
|
5520
|
+
|
|
5521
|
+
fixMermaidSVGs();
|
|
5522
|
+
|
|
5523
|
+
// if (!window.html2pdf) {
|
|
5524
|
+
// await loadScript('https://cdn.jsdelivr.net/npm/html2pdf.js@0.10.1/dist/html2pdf.bundle.min.js');
|
|
5525
|
+
// }
|
|
5526
|
+
const element = document.querySelector('.rspress-doc');
|
|
5527
|
+
if (!element) {
|
|
5528
|
+
alert('No content to export.');
|
|
5529
|
+
return;
|
|
5530
|
+
}
|
|
5531
|
+
|
|
5532
|
+
const opt = {
|
|
5533
|
+
margin: 0.5,
|
|
5534
|
+
filename: document.title.replace(/\s+/g, '_') + '.pdf',
|
|
5535
|
+
image: { type: 'jpeg', quality: 0.98 },
|
|
5536
|
+
html2canvas: { scale: 2, useCORS: true },
|
|
5537
|
+
jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' },
|
|
5538
|
+
pagebreak: {
|
|
5539
|
+
mode: ['avoid-all', 'css', 'legacy'],
|
|
5540
|
+
before: '.page-break-before', // 在这些选择器前强制分页
|
|
5541
|
+
after: '.page-break-after', // 在这些选择器后强制分页
|
|
5542
|
+
avoid: '.no-page-break' // 避免这些选择器分页
|
|
5543
|
+
}
|
|
5544
|
+
};
|
|
5545
|
+
|
|
5546
|
+
// 生成 PDF 并在完成后移除提示
|
|
5547
|
+
__WEBPACK_EXTERNAL_MODULE_html2pdf_js_65368f2c__.html2pdf().set(opt).from(element).save().then(() => {
|
|
5548
|
+
document.body.removeChild(tip);
|
|
5549
|
+
}).catch(() => {
|
|
5550
|
+
document.body.removeChild(tip);
|
|
5551
|
+
});
|
|
5552
|
+
}
|
|
5553
|
+
|
|
5457
5554
|
export { Aside, Badge, Button, Card, DocFooter, DocLayout, EditLink, HomeFeature, HomeFooter, HomeLayout, HomepageLayout, HomepageTopSearch, HomepageTopics, HomepageFeatures, HomepageFaqs, LastUpdated, Layout, Link, LinkCard, Nav, NotFoundLayout, Overview, PackageManagerTabs, PrevNextPage, types_RenderType as RenderType, ScrollToTop, Search, SearchPanel, Sidebar, SidebarList, SocialLinks, SourceCode, Steps, SwitchAppearance, Tab, Tabs, Tag, Toc, bindingAsideScroll, src_rslib_entry_ as default, getCustomMDXComponent, isMobileDevice, parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown, scrollToTarget, setup, useEditLink, useEnableNav, useFullTextSearch, useHiddenNav, useLocaleSiteData, usePathUtils, usePrevNextPage, useRedirect4FirstVisit, useSidebarData, useThemeState };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress-theme-anatole/theme-default",
|
|
3
3
|
"author": "Anatole Tong",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1-alpha",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"*.css",
|
|
@@ -21,12 +21,14 @@
|
|
|
21
21
|
"types": "./dist/bundle.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@mdx-js/react": "2.3.0",
|
|
24
|
-
"@rspress-theme-anatole/
|
|
24
|
+
"@rspress-theme-anatole/rspress-plugin-mermaid": "0.6.1-alpha",
|
|
25
|
+
"@rspress-theme-anatole/shared": "0.6.1-alpha",
|
|
25
26
|
"@rspress/runtime": "1.43.8",
|
|
26
27
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
27
28
|
"copy-to-clipboard": "^3.3.3",
|
|
28
29
|
"flexsearch": "0.7.43",
|
|
29
30
|
"github-slugger": "^2.0.0",
|
|
31
|
+
"html2pdf.js": "^0.10.3",
|
|
30
32
|
"htmr": "^1.0.2",
|
|
31
33
|
"lodash-es": "^4.17.21",
|
|
32
34
|
"nprogress": "^0.2.0",
|
|
@@ -34,8 +36,7 @@
|
|
|
34
36
|
"react-dom": "^18.3.1",
|
|
35
37
|
"react-helmet-async": "^1.3.0",
|
|
36
38
|
"react-router-dom": "6.29.0",
|
|
37
|
-
"react-syntax-highlighter": "^15.6.1"
|
|
38
|
-
"@rspress-theme-anatole/rspress-plugin-mermaid": "0.5.9"
|
|
39
|
+
"react-syntax-highlighter": "^15.6.1"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@microsoft/api-extractor": "^7.49.2",
|