Skip to content

Commit 9bc419b

Browse files
committed
dosc: 完善文档
1 parent 124ee3e commit 9bc419b

File tree

16 files changed

+256
-301
lines changed

16 files changed

+256
-301
lines changed

.github/workflows/publish.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: Npm Publish
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
jobs:
12+
publish-npm:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: actions/setup-node@v2
17+
with:
18+
node-version: '16.x'
19+
registry-url: https://registry.npmjs.org/
20+
21+
- name: Install Dependencies
22+
run: yarn
23+
24+
- name: Build Package
25+
run: yarn run build
26+
27+
- name: Publish To Npm
28+
run: npm publish --access=public
29+
env:
30+
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH}}
31+
32+
# https://github.com/marketplace/actions/zip-release
33+
- name: Archive Release
34+
uses: thedoctor0/zip-release@master
35+
with:
36+
filename: release.zip
37+
exclusions: '*.git* /*node_modules/*'
38+
39+
# https://github.com/actions/create-release
40+
- name: Create GitHub Release
41+
id: create_release
42+
uses: actions/create-release@v1
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
with:
46+
tag_name: ${{ github.ref }}
47+
release_name: release ${{ github.ref }}
48+
49+
# https://github.com/actions/upload-release-asset
50+
- name: Upload Release Asset
51+
uses: actions/upload-release-asset@v1
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
with:
55+
upload_url: ${{ steps.create_release.outputs.upload_url }}
56+
asset_path: ./release.zip
57+
asset_name: release.zip
58+
asset_content_type: application/zip

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ yarn add @wangeditor/editor wangeditor5-for-vue2
1212
npm install @wangeditor/editor wangeditor5-for-vue2
1313
```
1414

15-
## 用户文档
15+
## 使用文档
1616

1717
- [wangeditor5](https://www.wangeditor.com/v5/)
1818
- [wangeditor5-for-vue2](https://clinfc.github.io/wangeditor5-for-vue2/)
19+
- [wangeditor5-for-vue3](https://clinfc.github.io/wangeditor5-for-vue3/)
1920

2021
## 功能亮点
2122

@@ -41,8 +42,8 @@ npm install @wangeditor/editor wangeditor5-for-vue2
4142

4243
### 兼容性
4344

44-
- vue@^2
45-
- @wangeditor/editor@^0.14.0
45+
- `vue@^2`
46+
- `@wangeditor/editor@^0.14.0`
4647

4748
### 交流
4849

docs/.vuepress/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module.exports = {
2525
{ text: 'reloadEditor', link: '/guide/use-wang-editor.md#reloadeditor' },
2626
{ text: 'WeEditableOption', link: '/guide/use-wang-editor.md#weeditableoption' },
2727
{ text: 'WeToolbarOption', link: '/guide/use-wang-editor.md#wetoolbaroption' },
28+
{ text: '会触发重载的配置项', link: '/guide/use-wang-editor.md#会触发重载的配置项' },
2829
],
2930
},
3031
{
@@ -47,7 +48,7 @@ module.exports = {
4748
{ text: 'Github', link: 'https://github.com/clinfc/wangeditor5-for-vue2' },
4849
],
4950
sidebar: {
50-
'/guide/': ['', 'use-wang-editor', 'reloadbefore', 'v-model', 'relevance'],
51+
'/guide/': ['', 'props', 'use-wang-editor', 'reloadbefore', 'v-model', 'relevance'],
5152
},
5253
},
5354
},

docs/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ home: true
33
lang: zh-CN
44
heroText: wangeditor5-for-vue2
55
tagline: 在 Vue2 中使用 wangEditor v5
6-
actions:
7-
- text: 快速开始
8-
link: /guide/README.md
9-
type: success
6+
actionText: 快速开始
7+
actionLink: /guide/README
108
features:
119
- title: 动态配置
1210
details: 符合 Vue 使用习惯,数据驱动,通过修改配置即可更新编辑器(编辑器创建后修改配置项仍生效)

docs/guide/README.md

Lines changed: 34 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ npm install @wangeditor/editor wangeditor5-for-vue2
1515
### 全局注册
1616

1717
```js
18-
import { createApp } from 'vue'
18+
import Vue from 'vue'
1919
import { WeToolbar, WeEditable, WeEditor } from 'wangeditor5-for-vue2'
2020
import '@wangeditor/editor/dist/css/style.css'
2121

@@ -51,116 +51,78 @@ export default {
5151
}
5252
```
5353

54-
## 完全示例
54+
## 示例
5555

5656
### WeToolbar + WeEditable
5757

58-
```html
58+
```vue
5959
<template>
6060
<div>
61-
<we-toolbar :option="we.toolbar" :reloadbefore="toolbarReloadbefore" />
62-
<we-editable
63-
:option="we.editable"
64-
:reloadbefore="editableReloadbefore"
65-
:json.sync="data.json"
66-
:html.sync="data.html"
67-
/>
61+
<we-toolbar :option="toolbar" />
62+
<we-editable :option="editable" :json.sync="data.json" :html.sync="data.html" />
6863
</div>
6964
</template>
7065
7166
<script>
7267
import { useWangEditor } from 'wangeditor5-for-vue2'
7368
export default {
7469
data() {
75-
return {
76-
we: {
77-
toolbar: null,
78-
editable: null,
79-
getToolbar: null,
80-
getEditable: null,
81-
clearContent: null,
82-
reloadEditor: null,
70+
const { toolbar, editable, getToolbar, getEditable, clearContent, reloadEditor } = useWangEditor({
71+
config: {
72+
placeholder: 'WeToolbar + WeEditable 示例',
73+
onCreated: (inst) => {
74+
console.log(inst)
75+
// 使用了箭头函数,因此 this 指向当前组件实例
76+
console.log(this.editable.config.placeholder)
77+
},
8378
},
79+
})
80+
81+
return {
82+
toolbar,
83+
editable,
84+
getToolbar,
85+
getEditable,
86+
clearContent,
87+
reloadEditor,
8488
data: {
8589
json: '',
8690
html: '',
8791
},
8892
}
8993
},
90-
created() {
91-
this.we = useWangEditor({
92-
config: {
93-
placeholder: 'WeToolbar + WeEditable 示例',
94-
},
95-
})
96-
},
97-
methods: {
98-
toolbarReloadbefore(inst) {
99-
console.log(inst)
100-
alert(`toolbar 即将重载:${new Date().toLocaleString()}`)
101-
},
102-
editableReloadbefore(inst) {
103-
console.log(inst)
104-
alert(`editable 即将重载:${new Date().toLocaleString()}`)
105-
},
106-
},
10794
}
10895
</script>
10996
```
11097

11198
### WeEditor
11299

113-
```html
100+
```vue
114101
<template>
115-
<we-editor
116-
:toolbar-option="we.toolbar"
117-
:editable-option="we.editable"
118-
:json.sync="data.json"
119-
:html.sync="data.html"
120-
/>
102+
<we-editor :toolbar-option="toolbar" :editable-option="editable" :json.sync="data.json" :html.sync="data.html" />
121103
</template>
122104
123105
<script>
124106
import { useWangEditor } from 'wangeditor5-for-vue2'
125107
export default {
126108
data() {
127109
return {
128-
we: {
129-
toolbar: null,
130-
editable: null,
131-
getToolbar: null,
132-
getEditable: null,
133-
clearContent: null,
134-
reloadEditor: null,
135-
},
136110
data: {
137111
json: '',
138112
html: '',
139113
},
114+
...useWangEditor({
115+
config: {
116+
placeholder: 'WeEditor 示例',
117+
onCreated: (inst) => {
118+
console.log(inst)
119+
// 使用了箭头函数,因此 this 指向当前组件实例
120+
console.log(this.editable.config.placeholder)
121+
},
122+
},
123+
}),
140124
}
141125
},
142-
created() {
143-
this.we = useWangEditor({
144-
config: {
145-
placeholder: 'WeEditor 示例',
146-
},
147-
})
148-
},
149126
}
150127
</script>
151128
```
152-
153-
#### props
154-
155-
| prop | 描述 | 类型 |
156-
| :--------------------- | :------------------------------------------------- | :----------------------------- |
157-
| `toolbarOption` | 菜单栏配置项 | `Required<WeToolbarOption>` |
158-
| `toolbarClass` | 菜单栏的 `class attribute` | `String` |
159-
| `toolbarStyle` | 菜单栏的 `style attribute` | `String` |
160-
| `toolbarReloadbefore` | 菜单栏重载前的回调函数 | `(toolbar: Toolbar) => void` |
161-
| `editableOption` | 编辑区配置项 | `Required<WeEditableOption>` |
162-
| `editableClass` | 编辑区的 `class attribute` | `String` |
163-
| `editableStyle` | 编辑区的 `style attribute` | `String` |
164-
| `editableReloadbefore` | 编辑区重载前的回到函数 | `(editor: IDomEditor) => void` |
165-
| `json` | 编辑器内容,支持 `.sync` 修饰符 | `JSON String` |
166-
| `html` | 编辑器内容,支持 `.sync` 修饰符,优先级低于 `json` | `HTML String` |

docs/guide/props.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# props
2+
3+
## WeToolbar
4+
5+
| prop | 描述 | 类型 |
6+
| :------------ | :--------------------- | :--------------------------- |
7+
| `option` | 菜单栏配置项 | `Required<WeToolbarOption>` |
8+
| `eloadbefore` | 菜单栏重载前的回调函数 | `(toolbar: Toolbar) => void` |
9+
10+
## WeEditable
11+
12+
| prop | 描述 | 类型 |
13+
| :------------- | :------------------------------------------------- | :----------------------------- |
14+
| `option` | 菜单栏配置项 | `Required<WeToolbarOption>` |
15+
| `eloadbefore` | 菜单栏重载前的回调函数 | `(toolbar: Toolbar) => void` |
16+
| `option` | 编辑区配置项 | `Required<WeEditableOption>` |
17+
| `reloadbefore` | 编辑区重载前的回到函数 | `(editor: IDomEditor) => void` |
18+
| `json` | 编辑器内容,支持 `.sync` 修饰符 | `JSON String` |
19+
| `html` | 编辑器内容,支持 `.sync` 修饰符,优先级低于 `json` | `HTML String` |
20+
21+
## WeEditor
22+
23+
| prop | 描述 | 类型 |
24+
| :--------------------- | :------------------------------------------------- | :----------------------------- |
25+
| `toolbarOption` | 菜单栏配置项 | `Required<WeToolbarOption>` |
26+
| `toolbarClass` | 菜单栏的 `class attribute` | `String` |
27+
| `toolbarStyle` | 菜单栏的 `style attribute` | `String` |
28+
| `toolbarReloadbefore` | 菜单栏重载前的回调函数 | `(toolbar: Toolbar) => void` |
29+
| `editableOption` | 编辑区配置项 | `Required<WeEditableOption>` |
30+
| `editableClass` | 编辑区的 `class attribute` | `String` |
31+
| `editableStyle` | 编辑区的 `style attribute` | `String` |
32+
| `editableReloadbefore` | 编辑区重载前的回到函数 | `(editor: IDomEditor) => void` |
33+
| `json` | 编辑器内容,支持 `.sync` 修饰符 | `JSON String` |
34+
| `html` | 编辑器内容,支持 `.sync` 修饰符,优先级低于 `json` | `HTML String` |

docs/guide/reloadbefore.md

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
```html
88
<template>
99
<div>
10-
<we-toolbar :reloadbefore="toolbarReloadbefore" :option="we.toolbar" />
11-
<we-editable :reloadbefore="editableReloadbefore" :option="we.editable" />
10+
<we-toolbar :reloadbefore="toolbarReloadbefore" :option="toolbar" />
11+
<we-editable :reloadbefore="editableReloadbefore" :option="editable" />
1212
</div>
1313
</template>
1414

@@ -17,23 +17,13 @@
1717
export default {
1818
data() {
1919
return {
20-
we: {
21-
toolbar: null,
22-
editable: null,
23-
getToolbar: null,
24-
getEditable: null,
25-
clearContent: null,
26-
reloadEditor: null,
27-
},
20+
...useWangEditor({
21+
config: {
22+
placeholder: 'WeToolbar + WeEditable 示例',
23+
},
24+
}),
2825
}
2926
},
30-
created() {
31-
this.we1 = useWangEditor({
32-
config: {
33-
placeholder: 'WeToolbar + WeEditable 示例',
34-
},
35-
})
36-
},
3727
methods: {
3828
toolbarReloadbefore(inst) {
3929
console.log(inst)
@@ -55,8 +45,8 @@
5545
<we-editor
5646
:toolbar-reloadbefore="toolbarReloadbefore"
5747
:editable-reloadbefore="editableReloadbefore"
58-
:toolbar-option="we.toolbar"
59-
:editable-option="we.editable"
48+
:toolbar-option="toolbar"
49+
:editable-option="editable"
6050
/>
6151
</template>
6252

@@ -65,23 +55,13 @@
6555
export default {
6656
data() {
6757
return {
68-
we: {
69-
toolbar: null,
70-
editable: null,
71-
getToolbar: null,
72-
getEditable: null,
73-
clearContent: null,
74-
reloadEditor: null,
75-
},
58+
...useWangEditor({
59+
config: {
60+
placeholder: 'WeEditor 示例',
61+
},
62+
}),
7663
}
7764
},
78-
created() {
79-
this.we = useWangEditor({
80-
config: {
81-
placeholder: 'WeEditor 示例',
82-
},
83-
})
84-
},
8565
methods: {
8666
toolbarReloadbefore(inst) {
8767
console.log(inst)

0 commit comments

Comments
 (0)