remons-render-markdown 1.0.0-beta.2 → 1.0.0-beta.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "remons-render-markdown",
3
- "version": "1.0.0-beta.2",
4
- "description": "一个基于 React 的 Markdown 渲染组件,支持 GFM(GitHub Flavored Markdown)、代码高亮、Mermaid 图表等功能。",
3
+ "version": "1.0.0-beta.3",
4
+ "description": "一个基于 React 的 Markdown 渲染组件,支持 GFM(GitHub Flavored Markdown)、代码高亮、Mermaid 图表、Tabs 渲染等功能。",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
7
7
  "module": "./dist/index.mjs",
@@ -13,7 +13,6 @@
13
13
  },
14
14
  "./dist/index.css": "./dist/index.css"
15
15
  },
16
- "style": "./dist/index.css",
17
16
  "files": [
18
17
  "dist"
19
18
  ],
@@ -34,7 +33,7 @@
34
33
  "gfm",
35
34
  "mermaid"
36
35
  ],
37
- "author": "",
36
+ "author": "remons",
38
37
  "license": "MIT",
39
38
  "peerDependencies": {
40
39
  "react": ">=18.0.0",
@@ -79,5 +78,9 @@
79
78
  "markdown-it-link-attributes": "^4.0.1",
80
79
  "markdown-it-toc-done-right": "^4.2.0",
81
80
  "methods-r": "^2.0.0-rc.1"
81
+ },
82
+ "repository": {
83
+ "type": "git",
84
+ "url": "https://github.com/liRemons/render-markdown.git"
82
85
  }
83
86
  }
package/readme.md CHANGED
@@ -63,6 +63,7 @@ import RenderMarkdown, { markdownFormat, languagesCommon, initHighlighter } fro
63
63
  | isShowCollapsed | boolean | ❌ | true | 是否显示代码折叠按钮 |
64
64
  | codeType | string | ❌ | - | 指定代码类型(如 'javascript' 等),不传则按 Markdown 渲染 |
65
65
  | editButton | React.ReactNode | ❌ | - | 自定义编辑按钮 |
66
+ | backTopTarget | HTMLElement | ❌ | body | 返回顶部按钮监听的容器 |
66
67
 
67
68
  ### markdownFormat 函数
68
69
 
@@ -301,7 +302,56 @@ title: 图表标题
301
302
 
302
303
  ![alert 渲染图](https://remons.cn:3008/upload/md_assets/alert.png)
303
304
 
304
- #### 目录锚点
305
+ #### MermaidRenderer 组件
306
+
307
+ 独立的 Mermaid 图表渲染组件,支持缩放、全屏、下载、源码查看等功能。
308
+
309
+ ```tsx
310
+ import { renderMermaid } from 'remons-render-markdown';
311
+ import 'remons-render-markdown/dist/index.css';
312
+
313
+ function MermaidComponent() {
314
+ const mermaidCode = `
315
+ ---
316
+ title: 流程图示例
317
+ ---
318
+ graph TD
319
+ A[开始] --> B[处理]
320
+ B --> C[结束]
321
+ `;
322
+
323
+ return (
324
+ <div>
325
+ {
326
+ renderMermaid({ source: mermaidCode })
327
+ }
328
+ </div>
329
+ );
330
+ }
331
+ ```
332
+
333
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
334
+ |------|------|------|--------|------|
335
+ | source | string | ✅ | - | Mermaid 代码字符串,支持 `---title: xxx---` 格式设置标题 |
336
+ | debounceMs | number | ❌ | 300 | 图表渲染时的 debounce 时间(毫秒) |
337
+ | enablePanzoom | boolean | ❌ | true | 是否启用缩放和平移功能 |
338
+ | showDownload | boolean | ❌ | true | 是否显示下载按钮(支持 SVG/PNG 格式) |
339
+ | showSourceView | boolean | ❌ | false | 是否显示源码查看按钮和工具栏 |
340
+ | showCollapse | boolean | ❌ | false | 是否显示折叠/展开按钮 |
341
+ | defaultCollapsed | boolean | ❌ | true | 默认折叠状态 |
342
+ | className | string | ❌ | "" | 自定义样式类名 |
343
+ | minHeight | number | ❌ | 200 | 最小高度(像素) |
344
+ | showDriverGuide | boolean | ❌ | false | 是否显示新手引导 |
345
+
346
+ **功能特性:**
347
+ - 缩放:支持放大、缩小、重置视图
348
+ - 全屏:支持浏览器原生全屏模式
349
+ - 下载:支持下载 SVG 和 PNG 格式
350
+ - 源码查看:点击按钮可查看 Mermaid 源码
351
+ - 折叠/展开:支持图表的折叠和展开
352
+ - 缩略图模式:最小化时显示缩略图
353
+ - 深色模式:自动适配主题
354
+
305
355
 
306
356
  ## 注意事项
307
357