Skip to content

Commit 059136e

Browse files
committed
refactor(editor-md): demo优化
1 parent 5916100 commit 059136e

File tree

1 file changed

+35
-35
lines changed
  • packages/devui-vue/docs/components/editor-md

1 file changed

+35
-35
lines changed

packages/devui-vue/docs/components/editor-md/index.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { defineComponent, reactive, ref } from 'vue';
1515
1616
export default defineComponent({
1717
setup() {
18-
const content = ref('`Not use ngModel` aaa');
18+
const content = ref('# This is the title');
1919
const mdRules = reactive({
2020
linkify: {
2121
fuzzyLink: false,
@@ -127,7 +127,7 @@ import { defineComponent, reactive, ref } from 'vue';
127127
128128
export default defineComponent({
129129
setup() {
130-
const content = ref('`Not use ngModel` aaa');
130+
const content = ref('# This is the title');
131131
const mdRules = reactive({
132132
linkify: {
133133
fuzzyLink: false,
@@ -158,30 +158,25 @@ export default defineComponent({
158158

159159
### 配置图片文件上传
160160

161-
:::demo 设置imageUploadToServer后,编辑器对粘贴操作也将进行监听,若有图片也将触发imageUpload事件
161+
:::demo 设置 imageUploadToServer 后,编辑器对粘贴操作也将进行监听,若有图片也将触发 imageUpload 事件
162162

163163
```vue
164164
<template>
165-
<d-editor-md
166-
v-model="content"
167-
:image-upload-to-server="true"
168-
@content-change="valueChange"
169-
@image-upload="imageUpload"
170-
></d-editor-md>
165+
<d-editor-md v-model="content" :image-upload-to-server="true" @content-change="valueChange" @image-upload="imageUpload"></d-editor-md>
171166
</template>
172167
173168
<script>
174169
import { defineComponent, reactive, ref } from 'vue';
175170
176171
export default defineComponent({
177172
setup() {
178-
const content = ref('`Not use ngModel`');
173+
const content = ref('# This is the title');
179174
180175
const valueChange = (val) => {
181176
console.log(val);
182177
};
183178
184-
const imageUpload = ({file, callback}) => {
179+
const imageUpload = ({ file, callback }) => {
185180
let message;
186181
const rFilter = /^(image\/bmp|image\/gif|image\/jpge|image\/jpeg|image\/jpg|image\/png|image\/tiff)$/i;
187182
if (!rFilter.test(file.type)) {
@@ -200,10 +195,14 @@ export default defineComponent({
200195
xhr.open('POST', 'https://xxx.xxx.com/v1/xxx');
201196
xhr.setRequestHeader('yourKey', 'yourValue');
202197
203-
xhr.addEventListener('load', (evt) => {
204-
const result = JSON.parse(xhr.responseText);
205-
resolve(result);
206-
}, false);
198+
xhr.addEventListener(
199+
'load',
200+
(evt) => {
201+
const result = JSON.parse(xhr.responseText);
202+
resolve(result);
203+
},
204+
false
205+
);
207206
208207
const fd = new FormData();
209208
fd.append('file', file);
@@ -216,7 +215,7 @@ export default defineComponent({
216215
}
217216
});
218217
}
219-
}
218+
};
220219
221220
return { content, valueChange, imageUpload };
222221
},
@@ -228,28 +227,29 @@ export default defineComponent({
228227

229228
### EditorMd 参数
230229

231-
| 参数名 | 类型 | 默认值 | 说明 |
232-
| :-------------------- | :---------------------------------------- | :------- | :----------------------------------------------------------------------------------------------------------------- |
233-
| v-model | `string` | '' | 编辑器内容双向绑定 |
234-
| options | `object` | {} | 编辑器初始化时,自定义配置,可参考[CodeMirror Options](https://codemirror.net/doc/manual.html#config) |
235-
| base-url | `string` | -- | 设置渲染到 html 时,为相对 url 添加的 baseUrl |
236-
| custom-parse | `(html: string) => string` | -- | 自定义对渲染后的 html 处理,需要接收渲染后的 html,返回自定义处理后的 html |
237-
| md-rules | `object` | {} | 设置 markdown 对字符串的处理方式, 可参考[markdown-it](https://www.npmjs.com/package/markdown-it?activeTab=readme) |
238-
| mode | `'editonly' \| 'readonly' \| 'normal'` | 'normal' | 只写/只读/双栏显示模式选择,默认 'normal' 双栏模式显示 |
239-
| custom-renderer-rules | [ICustomRenderRule[]](#icustomrenderrule) | [] | 自定义 markdown 对节点的渲染方式,每条规则需要指定对应节点 key,并自定义渲染函数 |
240-
| custom-xss-rules | [ICustomXssRule[]](#icustomxssrule) | [] | 自定义 xss 对某种 tag 的过滤方式,每条规则需要指定 tag, 并给出需要加入白名单的属性数组 |
241-
| placeholder | `string` | '' | 编辑器无内容是的提示信息 |
242-
| fullscreen-z-index | `number` | 10 | 编辑器全屏状态的 z-index |
243-
| image-upload-to-server| `boolean` | false | 是否打开图片自定义上传开关(打开后将将监听图片的复制,toolbar图片功能上传,传出事件回调) |
230+
| 参数名 | 类型 | 默认值 | 说明 |
231+
| :--------------------- | :---------------------------------------- | :------- | :----------------------------------------------------------------------------------------------------------------- |
232+
| v-model | `string` | '' | 编辑器内容双向绑定 |
233+
| options | `object` | {} | 编辑器初始化时,自定义配置,可参考[CodeMirror Options](https://codemirror.net/doc/manual.html#config) |
234+
| base-url | `string` | -- | 设置渲染到 html 时,为相对 url 添加的 baseUrl |
235+
| custom-parse | `(html: string) => string` | -- | 自定义对渲染后的 html 处理,需要接收渲染后的 html,返回自定义处理后的 html |
236+
| md-rules | `object` | {} | 设置 markdown 对字符串的处理方式, 可参考[markdown-it](https://www.npmjs.com/package/markdown-it?activeTab=readme) |
237+
| mode | `'editonly' \| 'readonly' \| 'normal'` | 'normal' | 只写/只读/双栏显示模式选择,默认 'normal' 双栏模式显示 |
238+
| custom-renderer-rules | [ICustomRenderRule[]](#icustomrenderrule) | [] | 自定义 markdown 对节点的渲染方式,每条规则需要指定对应节点 key,并自定义渲染函数 |
239+
| custom-xss-rules | [ICustomXssRule[]](#icustomxssrule) | [] | 自定义 xss 对某种 tag 的过滤方式,每条规则需要指定 tag, 并给出需要加入白名单的属性数组 |
240+
| placeholder | `string` | '' | 编辑器无内容是的提示信息 |
241+
| fullscreen-z-index | `number` | 10 | 编辑器全屏状态的 z-index |
242+
| image-upload-to-server | `boolean` | false | 是否打开图片自定义上传开关(打开后将将监听图片的复制,toolbar 图片功能上传,传出事件回调) |
244243

245244
### EditorMd 事件
246245

247-
| 事件名 | 回调参数 | 说明 | 跳转 Demo |
248-
| :--------------------- | :--------------------------- | :------------------------------- | :-------- |
249-
| after-editor-init | `Function(instance: object)` | 编辑器初始化事件,返回编辑器对象 | |
250-
| content-change | `Function(content: string)` | 编辑器内容改变事件,返回当前内容 | |
251-
| preview-content-change | `Function()` | 预览内容改变时触发 | |
252-
| image-upload | `Function({file, callback})` | 打开图片上传开关后,图片上传事件回调,返回文件内容与callback函数 | |
246+
| 事件名 | 回调参数 | 说明 | 跳转 Demo |
247+
| :--------------------- | :--------------------------- | :----------------------------------------------------------------- | :-------- |
248+
| after-editor-init | `Function(instance: object)` | 编辑器初始化事件,返回编辑器对象 | |
249+
| content-change | `Function(content: string)` | 编辑器内容改变事件,返回当前内容 | |
250+
| preview-content-change | `Function()` | 预览内容改变时触发 | |
251+
| image-upload | `Function({file, callback})` | 打开图片上传开关后,图片上传事件回调,返回文件内容与 callback 函数 | |
252+
253253
### MdRender 参数
254254

255255
| 参数名 | 类型 | 默认值 | 说明 | 跳转 Demo |

0 commit comments

Comments
 (0)