Skip to content

Commit 10de461

Browse files
更新react vue的说明
1 parent 72fd4c6 commit 10de461

9 files changed

Lines changed: 25 additions & 18 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#忽略
3+
**/node_modules/*
34
node_modules/*
45
npm-debug.log
56

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- 直接下载:[https://github.com/wangfupeng1988/wangEditor/releases](https://github.com/wangfupeng1988/wangEditor/releases)
1919
- 使用`npm`下载:`npm install wangeditor` (注意 `wangeditor` 全部是**小写字母**
2020
- 使用`bower`下载:`bower install wangEditor` (前提保证电脑已安装了`bower`
21-
- 使用CDN:[//unpkg.com/wangeditor@3.0.1/release/wangEditor.min.js](https://unpkg.com/wangeditor@3.0.1/release/wangEditor.min.js)(其中`@3.0.1`代表了`npm`中发布的版本)
21+
- 使用CDN:[//unpkg.com/wangeditor/release/wangEditor.min.js](https://unpkg.com/wangeditor/release/wangEditor.min.js)
2222

2323

2424
## 使用

docs/dev/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
上线
1818

19-
- 修改`package.json`版本,修改 unpkg 链接中的版本(文档中有两处)修改`in-react``in-vue`中的`wangeditor`版本
19+
- 修改`package.json`版本
2020
- 提交到github,并创建tag
2121
- 提交到 npm
22-
- 同步到官网
23-
- 更新文档
22+
- 同步到官网 min.js
23+
- 更新 .md 文档
2424
- 文档同步到 kancloud
2525
- ……
2626

docs/usage/01-getstart/01-demo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## 下载
44

55
- 点击 [https://github.com/wangfupeng1988/wangEditor/releases](https://github.com/wangfupeng1988/wangEditor/releases) 下载最新版。进入`release`文件夹下找到`wangEditor.js`或者`wangEditor.min.js`即可
6-
- 使用CDN:[//unpkg.com/wangeditor@3.0.1/release/wangEditor.min.js](https://unpkg.com/wangeditor@3.0.1/release/wangEditor.min.js)(其中`@3.0.1`代表了`npm`中发布的版本)
6+
- 使用CDN:[//unpkg.com/wangeditor/release/wangEditor.min.js](https://unpkg.com/wangeditor/release/wangEditor.min.js)
77
- 使用`bower`下载:`bower install wangEditor` (前提保证电脑已安装了`bower`
88

99
*PS:支持`npm`安装,请参见后面的章节*

docs/usage/05-other/06-vue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
如果需要将 wangEditor 用于 Vue 中,可参见如下示例
44

55
- 下载源码 `git clone [email protected]:wangfupeng1988/wangEditor.git`
6-
- 进入 vue 示例目录 `cd wangEditor/example/demo/in-vue/`,查看`src/App.js`即可
6+
- 进入 vue 示例目录 `cd wangEditor/example/demo/in-vue/`,查看`src/components/Editor.vue`即可
77
- 也可以运行`npm install && npm run dev`查看在 vue 中的效果(`http://localhost:8080/`

example/demo/in-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dependencies": {
66
"react": "^15.5.4",
77
"react-dom": "^15.5.4",
8-
"wangeditor": "^3.0.1"
8+
"wangeditor": ">=3.0.0"
99
},
1010
"devDependencies": {
1111
"react-scripts": "1.0.7"

example/demo/in-react/src/App.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class App extends Component {
77
constructor(props, context) {
88
super(props, context);
99
this.state = {
10+
editorContent: ''
1011
}
1112
}
1213
render() {
@@ -19,24 +20,28 @@ class App extends Component {
1920
<p className="App-intro">
2021
To get started, edit <code>src/App.js</code> and save to reload.
2122
</p>
23+
24+
{/* 将生成编辑器 */}
2225
<div ref="editorElem" style={{textAlign: 'left'}}>
2326
</div>
27+
2428
<button onClick={this.clickHandle.bind(this)}>获取内容</button>
2529
</div>
2630
);
2731
}
2832
componentDidMount() {
2933
const elem = this.refs.editorElem
3034
const editor = new E(elem)
35+
// 使用 onchange 函数监听内容的变化,并实时更新到 state 中
36+
editor.customConfig.onchange = html => {
37+
this.setState({
38+
editorContent: html
39+
})
40+
}
3141
editor.create()
32-
33-
this.setState({
34-
editor: editor
35-
})
3642
}
3743
clickHandle() {
38-
const editor = this.state.editor
39-
alert(editor.txt.html())
44+
alert(this.state.editorContent)
4045
}
4146
}
4247

example/demo/in-vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"vue": "^2.3.3",
14-
"wangeditor": "^3.0.1"
14+
"wangeditor": ">=3.0.0"
1515
},
1616
"devDependencies": {
1717
"autoprefixer": "^6.7.2",

example/demo/in-vue/src/components/Editor.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212
name: 'editor',
1313
data () {
1414
return {
15+
editorContent: ''
1516
}
1617
},
1718
methods: {
1819
getContent: function () {
19-
var editor = this.editor
20-
alert(editor.txt.html())
20+
alert(this.editorContent)
2121
}
2222
},
2323
mounted() {
2424
var editor = new E('#editorElem')
25+
editor.customConfig.onchange = (html) => {
26+
this.editorContent = html
27+
}
2528
editor.create()
26-
27-
this.editor = editor
2829
}
2930
}
3031
</script>

0 commit comments

Comments
 (0)