md2ui 1.0.19 → 1.0.21

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.
Files changed (29) hide show
  1. package/README.md +65 -20
  2. package/bin/build.js +13 -2
  3. package/bin/md2ui.js +25 -12
  4. package/package.json +4 -4
  5. package/public/docs/02-Markdown/346/270/262/346/237/223/00-/345/237/272/347/241/200/350/257/255/346/263/225.md +2 -0
  6. package/public/docs/02-Markdown/346/270/262/346/237/223/06-Mermaid/345/244/215/346/235/202/345/233/276/350/241/250/346/265/213/350/257/225.md +1376 -0
  7. package/public/docs/02-Markdown/346/270/262/346/237/223/assets/img-1777383093712.png +0 -0
  8. package/public/docs/03-/345/257/274/350/210/252/344/270/216/345/270/203/345/261/200/05-/345/244/247/347/272/262/345/216/213/345/212/233/346/265/213/350/257/225.md +340 -0
  9. package/public/docs/07-/347/247/273/345/212/250/347/253/257/351/200/202/351/205/215/00-/345/223/215/345/272/224/345/274/217/345/270/203/345/261/200.md +4 -4
  10. package/src/App.vue +36 -61
  11. package/src/components/ImageZoom.vue +9 -123
  12. package/src/components/MermaidNodeView.vue +10 -2
  13. package/src/components/MobileSearch.vue +97 -0
  14. package/src/components/TableOfContents.vue +42 -6
  15. package/src/composables/useDocManager.js +134 -44
  16. package/src/composables/useDocTree.js +26 -50
  17. package/src/composables/useMarkdown.js +51 -140
  18. package/src/composables/useMermaidCache.js +15 -0
  19. package/src/composables/useScroll.js +317 -32
  20. package/src/composables/useSearch.js +12 -11
  21. package/src/config.js +1 -4
  22. package/src/services/DocService.js +0 -16
  23. package/src/style.css +235 -10
  24. package/src/utils/imageConverter.js +129 -0
  25. package/vite-plugin-doc-api.js +158 -157
  26. package/vite.config.js +5 -1
  27. package/src/components/SearchPanel.vue +0 -90
  28. package/src/components/TableBubbleMenu.vue +0 -177
  29. package/src/composables/useExportPdf.js +0 -102
@@ -1,102 +0,0 @@
1
- import { ref } from 'vue'
2
-
3
- /**
4
- * PDF 导出 — 基于浏览器 window.print() 实现
5
- * 通过创建独立的打印窗口,只包含文档内容,生成干净的 PDF
6
- */
7
- export function useExportPdf() {
8
- const exportingPdf = ref(false)
9
-
10
- async function exportToPdf(title = '文档') {
11
- exportingPdf.value = true
12
- try {
13
- const contentEl = document.querySelector('.markdown-content')
14
- if (!contentEl) return
15
-
16
- // 克隆内容,移除不需要打印的元素
17
- const clone = contentEl.cloneNode(true)
18
- clone.querySelectorAll('.code-block-actions').forEach(el => el.remove())
19
- clone.querySelectorAll('.image-copy-btn, .mermaid-copy-btn').forEach(el => el.remove())
20
- clone.querySelectorAll('.table-toolbar').forEach(el => el.remove())
21
-
22
- // 收集页面中的样式
23
- const styles = []
24
- for (const sheet of document.styleSheets) {
25
- try {
26
- for (const rule of sheet.cssRules) {
27
- styles.push(rule.cssText)
28
- }
29
- } catch {
30
- // 跨域样式表忽略
31
- }
32
- }
33
-
34
- // 创建打印窗口
35
- const printWindow = window.open('', '_blank')
36
- if (!printWindow) {
37
- alert('请允许弹出窗口以导出 PDF')
38
- return
39
- }
40
-
41
- const safeTitle = title.replace(/[<>&"]/g, c =>
42
- ({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' }[c]))
43
-
44
- printWindow.document.write(`<!DOCTYPE html>
45
- <html lang="zh-CN">
46
- <head>
47
- <meta charset="UTF-8">
48
- <title>${safeTitle}</title>
49
- <style>
50
- ${styles.join('\n')}
51
- body {
52
- margin: 0;
53
- padding: 20px 40px;
54
- background: #fff;
55
- color: #1a1e1b;
56
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
57
- font-size: 14px;
58
- line-height: 1.6;
59
- }
60
- .markdown-content {
61
- max-width: 100%;
62
- padding: 0;
63
- margin: 0;
64
- }
65
- .code-block-wrapper { break-inside: avoid; border: 1px solid #ddd; }
66
- .code-block-header { background: #f5f5f5; }
67
- table { break-inside: avoid; }
68
- .mermaid { break-inside: avoid; }
69
- .heading-anchor { display: none !important; }
70
- @media print {
71
- a[href^="http"]::after {
72
- content: " (" attr(href) ")";
73
- font-size: 0.85em;
74
- color: #666;
75
- word-break: break-all;
76
- }
77
- a[data-doc-key]::after { content: none; }
78
- }
79
- </style>
80
- </head>
81
- <body>
82
- <article class="markdown-content">${clone.innerHTML}</article>
83
- </body>
84
- </html>`)
85
- printWindow.document.close()
86
-
87
- // 等待加载完成后触发打印
88
- printWindow.onload = () => {
89
- setTimeout(() => {
90
- printWindow.print()
91
- printWindow.onafterprint = () => printWindow.close()
92
- }, 500)
93
- }
94
- } catch (err) {
95
- console.error('导出 PDF 失败:', err)
96
- } finally {
97
- exportingPdf.value = false
98
- }
99
- }
100
-
101
- return { exportingPdf, exportToPdf }
102
- }