|
3 | 3 | [](https://npmjs.org/package/@ant-design/md-editor)
|
4 | 4 | [](https://npmjs.org/package/@ant-design/md-editor)
|
5 | 5 |
|
6 |
| -A react library developed with dumi |
| 6 | +一个使用 dumi 开发的 React 库 |
7 | 7 |
|
8 |
| -## Usage |
| 8 | +## 用法 |
9 | 9 |
|
10 |
| -TODO |
| 10 | +```tsx |
| 11 | +import React from 'react'; |
| 12 | +import { MarkdownEditor } from '@ant-design/md-editor'; |
11 | 13 |
|
12 |
| -## Options |
| 14 | +export default () => { |
| 15 | + return ( |
| 16 | + <MarkdownEditor |
| 17 | + initValue={`## 创始人 |
13 | 18 |
|
14 |
| -TODO |
| 19 | +腾讯,全称深圳市腾讯计算机系统有限公司,是由五位创始人共同创立的,他们是马化腾、张志东、许晨晔、陈一丹和曾李青。 以下是关于这些创始人的详细信息: 马化腾 马化腾,1971 年 10 月 29 日出生于广东省东方县(现海南省东方市)八所港,广东汕头人,汉族,无党派人士。他毕业于深圳大学电子工程系计算机专业。马化腾是腾讯科技(深圳)有限公司的创始人、董事会主席、首席执行官,并曾是中华人民共和国第十二、十三届全国人民代表大会代表 。马化腾在 1998 年 11 月 11 日与合伙人共同注册成立了腾讯,并在 2004 年 6 月 16 日带领腾讯在香港联合交易所有限公司主板上市。 张志东 张志东,马化腾的同学,被称为 QQ 之父。他的计算机技术非常出色,曾是深圳大学最拔尖的学生之一。张志东在腾讯担任 CTO,并在 2014 年 9 月离职,转任腾讯公司终身荣誉顾问及腾讯学院荣誉院长等职位 。 |
| 20 | +`} |
| 21 | + /> |
| 22 | + ); |
| 23 | +}; |
| 24 | +``` |
15 | 25 |
|
16 |
| -## Development |
| 26 | +## 选项 |
| 27 | + |
| 28 | +### MarkdownEditor |
| 29 | + |
| 30 | +| 属性 | 类型 | 描述 | |
| 31 | +| ----------------------- | -------------------------------------------------------------------------- | --------------------------- | |
| 32 | +| className | `string` | 自定义类名 | |
| 33 | +| width | `string \| number` | 编辑器宽度 | |
| 34 | +| height | `string \| number` | 编辑器高度 | |
| 35 | +| codeProps | `{ Languages?: string[] }` | 代码高亮配置 | |
| 36 | +| image | `{ upload?: (file: File[] \| string[]) => Promise<string[] \| string> }` | 图片上传配置 | |
| 37 | +| initValue | `string` | 初始内容 | |
| 38 | +| readonly | `boolean` | 是否为只读模式 | |
| 39 | +| style | `React.CSSProperties` | 容器样式 | |
| 40 | +| contentStyle | `React.CSSProperties` | 内容区域样式 | |
| 41 | +| editorStyle | `React.CSSProperties` | 编辑器样式 | |
| 42 | +| toc | `boolean` | 是否显示目录 | |
| 43 | +| toolBar | `ToolBarProps` | 工具栏配置 | |
| 44 | +| rootContainer | `React.MutableRefObject<HTMLDivElement \| undefined>` | markdown 编辑器的根容器引用 | |
| 45 | +| fncProps | `fnProps` | 功能属性配置 | |
| 46 | +| editorRef | `React.MutableRefObject<MarkdownEditorInstance \| undefined>` | 编辑器实例引用 | |
| 47 | +| eleItemRender | `(props: ElementProps, defaultDom: React.ReactNode) => React.ReactElement` | 自定义渲染元素 | |
| 48 | +| initSchemaValue | `Elements[]` | 初始结构数据 | |
| 49 | +| onChange | `(value: string, schema: Elements[]) => void` | 内容变化回调 | |
| 50 | +| reportMode | `boolean` | 是否开启报告模式 | |
| 51 | +| slideMode | `boolean` | 是否开启 PPT 模式 | |
| 52 | +| typewriter | `boolean` | 是否开启打字机模式 | |
| 53 | +| insertAutocompleteProps | `InsertAutocompleteProps` | 自动补全配置 | |
| 54 | +| titlePlaceholderContent | `string` | 标题占位符内容 | |
| 55 | +| comment | `Comment` | 评论功能配置 | |
| 56 | + |
| 57 | +### ToolBarProps |
| 58 | + |
| 59 | +| 属性 | 类型 | 描述 | |
| 60 | +| --------- | ----------------- | ------------------------ | |
| 61 | +| min | boolean | 控制是否启用最小化模式 | |
| 62 | +| enable | boolean | 控制是否启用工具栏 | |
| 63 | +| extra | React.ReactNode[] | 额外的自定义工具栏项目 | |
| 64 | +| hideTools | ToolsKeyType[] | 指定需要隐藏的工具栏选项 | |
| 65 | + |
| 66 | +### fnProps |
| 67 | + |
| 68 | +| 属性 | 类型 | 描述 | |
| 69 | +| ------ | ------------------------------------------------------------------------------- | -------------- | |
| 70 | +| render | `(props: { children: string }, defaultDom: React.ReactNode) => React.ReactNode` | 自定义渲染元素 | |
| 71 | + |
| 72 | +### CommentProps |
| 73 | + |
| 74 | +| Property | Type | Description | |
| 75 | +| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | |
| 76 | +| enable | `boolean` | Flag to enable/disable the component | |
| 77 | +| onSubmit | `(id: string, comment: CommentDataType) => void` | Callback when comment is submitted | |
| 78 | +| commentList | `CommentDataType[]` | Array of comments to display | |
| 79 | +| deleteConfirmText | `string` | Text shown in delete confirmation dialog | |
| 80 | +| loadMentions | `(keyword: string) => Promise<{ name: string; avatar?: string }[]>` | Function to load mention suggestions based on keyword | |
| 81 | +| mentionsPlaceholder | `string` | Placeholder text for mentions input | |
| 82 | +| editorRender | `(defaultDom: ReactNode) => ReactNode` | Custom render function for editor | |
| 83 | +| previewRender | `(props: { comment: CommentDataType[] }, defaultDom: ReactNode) => React.ReactElement` | Custom render function for preview | |
| 84 | +| onDelete | `(id: string \| number, item: CommentDataType) => void` | Callback when comment is deleted | |
| 85 | +| listItemRender | `(doms: { checkbox: React.ReactNode; mentionsUser: React.ReactNode; children: React.ReactNode }, props: ElementProps<ListItemNode>) => React.ReactNode` | Custom render function for list items | |
| 86 | + |
| 87 | +## 开发 |
17 | 88 |
|
18 | 89 | ```bash
|
19 |
| -# install dependencies |
| 90 | +# 安装依赖 |
20 | 91 | $ pnpm install
|
21 | 92 |
|
22 |
| -# develop library by docs demo |
| 93 | +# 通过文档示例开发库 |
23 | 94 | $ pnpm start
|
24 | 95 |
|
25 |
| -# build library source code |
| 96 | +# 构建库源代码 |
26 | 97 | $ pnpm run build
|
27 | 98 |
|
28 |
| -# build library source code in watch mode |
| 99 | +# 以监视模式构建库源代码 |
29 | 100 | $ pnpm run build:watch
|
30 | 101 |
|
31 |
| -# build docs |
| 102 | +# 构建文档 |
32 | 103 | $ pnpm run docs:build
|
33 | 104 |
|
34 |
| -# check your project for potential problems |
| 105 | +# 检查项目中的潜在问题 |
35 | 106 | $ pnpm run doctor
|
36 | 107 | ```
|
37 |
| - |
38 |
| -## LICENSE |
39 |
| - |
40 |
| -MIT |
41 |
| - |
42 |
| -```pie |
43 |
| - "Dogs" : 386 |
44 |
| - "Cats" : 85 |
45 |
| - "Rats" : 15 |
46 |
| -``` |
|
0 commit comments