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

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",
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,8 @@ 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 | 返回顶部按钮监听的容器 |
67
+ | showDriverGuide | boolean | ❌ | false | 是否显示新手引导 |
66
68
 
67
69
  ### markdownFormat 函数
68
70
 
@@ -301,7 +303,55 @@ title: 图表标题
301
303
 
302
304
  ![alert 渲染图](https://remons.cn:3008/upload/md_assets/alert.png)
303
305
 
304
- #### 目录锚点
306
+ #### renderMermaid 方法
307
+
308
+ 支持渲染独立的 Mermaid 图表渲染组件,支持缩放、全屏、下载、源码查看等功能。
309
+
310
+ ```tsx
311
+ import { renderMermaid } from 'remons-render-markdown';
312
+ import 'remons-render-markdown/dist/index.css';
313
+
314
+ function MermaidComponent() {
315
+ const mermaidCode = `
316
+ ---
317
+ title: 流程图示例
318
+ ---
319
+ graph TD
320
+ A[开始] --> B[处理]
321
+ B --> C[结束]
322
+ `;
323
+
324
+ return (
325
+ <div>
326
+ {
327
+ renderMermaid({ source: mermaidCode })
328
+ }
329
+ </div>
330
+ );
331
+ }
332
+ ```
333
+
334
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
335
+ |------|------|------|--------|------|
336
+ | source | string | ✅ | - | Mermaid 代码字符串,支持设置标题 |
337
+ | debounceMs | number | ❌ | 300 | 图表渲染时的 debounce 时间(毫秒) |
338
+ | enablePanzoom | boolean | ❌ | true | 是否启用缩放和平移功能 |
339
+ | showDownload | boolean | ❌ | true | 是否显示下载按钮(支持 SVG/PNG 格式) |
340
+ | showSourceView | boolean | ❌ | false | 是否显示源码查看按钮和工具栏 |
341
+ | showCollapse | boolean | ❌ | false | 是否显示折叠/展开按钮 |
342
+ | defaultCollapsed | boolean | ❌ | true | 默认折叠状态 |
343
+ | className | string | ❌ | "" | 自定义样式类名 |
344
+ | minHeight | number | ❌ | 200 | 最小高度(像素) |
345
+
346
+ **功能特性:**
347
+ - 缩放:支持放大、缩小、重置视图
348
+ - 全屏:支持浏览器原生全屏模式
349
+ - 下载:支持下载 SVG 和 PNG 格式
350
+ - 源码查看:点击按钮可查看 Mermaid 源码
351
+ - 折叠/展开:支持图表的折叠和展开
352
+ - 缩略图模式:最小化时显示缩略图
353
+ - 深色模式:自动适配主题
354
+
305
355
 
306
356
  ## 注意事项
307
357