1、install simditor

2、import simditor && scss

import $ from "jquery"
import Simditor from "Simditor";
import "Simditor/styles/Simditor.scss" const toolbar = ['title','bold','italic','underline','striketthrough','fontScale','color','|','ol','ul','hr',"|","link",'table'];
class RichEditor extends React.Component {
constructor(props){
super(props);
}
componentDidMount() {
this.loadEditor();
}
loadEditor() {
this.textarea = this.refs['textarea'];
this.editor = new Simditor({
textarea: $(this.textarea),
placeholder: this.props.placeholder,
toolbar: toolbar,
params: {}
this.bindEditorEvent();
this.setValue(this.props.value);
if (this.props.focus) {
const first = this.editor.body.find('p,li,pre,h1~h4'...).first();
this.editor.focus();
this.editor.selection.setRangeAtStartOf(first);
}
})
} bindEditorEvent() {
this.editor.on('valuechanged',()=>{
this.props.onValueChange(this.editor.getValue())
})
}
setValue(value) {
this.editor.setValue(value)
} render() {
return (
<textarea id={this.props.id} ref="textarea">
)
}
}

react use simditor的更多相关文章

  1. React后台管理系统-rich-editor组件

    1.Simditor组件的github地址:https://github.com/mycolorway/simditor 网址:http://simditor.tower.im/ 2.在util里边新 ...

  2. react构建前端项目方法汇总

    react简介: 一.使用react 创建一个PC端的项目 (a):使用 yemon 创建一个 webpack 的 react 的项目 控制台安装并且产看 yemon 的版本 yo -v (b): 全 ...

  3. react组件的生命周期

    写在前面: 阅读了多遍文章之后,自己总结了一个.一遍加强记忆,和日后回顾. 一.实例化(初始化) var Button = React.createClass({ getInitialState: f ...

  4. 十分钟介绍mobx与react

    原文地址:https://mobxjs.github.io/mobx/getting-started.html 写在前面:本人英语水平有限,主要是写给自己看的,若有哪位同学看到了有问题的地方,请为我指 ...

  5. RxJS + Redux + React = Amazing!(译一)

    今天,我将Youtube上的<RxJS + Redux + React = Amazing!>翻译(+机译)了下来,以供国内的同学学习,英文听力好的同学可以直接看原版视频: https:/ ...

  6. React 入门教程

    React 起源于Facebook内部项目,是一个用来构建用户界面的 javascript 库,相当于MVC架构中的V层框架,与市面上其他框架不同的是,React 把每一个组件当成了一个状态机,组件内 ...

  7. 通往全栈工程师的捷径 —— react

    腾讯Bugly特约作者: 左明 首先,我们来看看 React 在世界范围的热度趋势,下图是关键词“房价”和 “React” 在 Google Trends 上的搜索量对比,蓝色的是 React,红色的 ...

  8. 2017-1-5 天气雨 React 学习笔记

    官方example 中basic-click-counter <script type="text/babel"> var Counter = React.create ...

  9. RxJS + Redux + React = Amazing!(译二)

    今天,我将Youtube上的<RxJS + Redux + React = Amazing!>的后半部分翻译(+机译)了下来,以供国内的同学学习,英文听力好的同学可以直接看原版视频: ht ...

随机推荐

  1. keras中 LSTM 的 [samples, time_steps, features] 最终解释

    I am going through the following blog on LSTM neural network:http://machinelearningmastery.com/under ...

  2. tensorflow 中 softmax_cross_entropy_with_logits 与 sparse_softmax_cross_entropy_with_logits 的区别

    http://stackoverflow.com/questions/37312421/tensorflow-whats-the-difference-between-sparse-softmax-c ...

  3. php imagemagick库安装使用

    imagemagick介绍: ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. ...

  4. beego——错误处理

    beego通过Redirect方法来进行跳转: func (this *AddController) Get() { this.Redirect("/", 302) } 如何终止此 ...

  5. 微信小程序组件button

    表单组件button:官方文档 Demo Code: var types=['default', 'primary', 'warn']; var pageObject = { data: { defa ...

  6. shell文件安全与权限 笔记

    主要学习: 文件盒目录的权限 Setuid Chown和chgrp Umask 连接符号 一个文件已经创建,就具有三种访问方式 读,可以显示该文件的内容 写,可以编辑或删除它 执行,如果该文件时一个s ...

  7. Java并发之Semaphore的使用

    Java并发之Semaphore的使用 一.简介 今天突然发现,看着自己喜欢的球队发挥如此的棒,然后写着博客,这种感觉很爽.现在是半场时间,就趁着这个时间的空隙,说说Java并发包中另外一个重量级的类 ...

  8. vm安装centos7 Minimal 配置静态ip添加dns: 解决连不上网

    去centos官网下载需要的镜像:https://www.centos.org/ 安装完成后,在centos7中,ifconfig命令已经不存在了,查看ip的命令 # ip addr 发现ens*** ...

  9. CSS流体(自适应)布局下宽度分离原则

    CSS流体(自适应)布局下宽度分离原则 这篇文章发布于 2011年02月28日,星期一,00:48,归类于 css相关. 阅读 73990 次, 今日 5 次 by zhangxinxu from h ...

  10. Spark机器学习1·编程入门(scala/java/python)

    Spark安装目录 /Users/erichan/Garden/spark-1.4.0-bin-hadoop2.6 基本测试 ./bin/run-example org.apache.spark.ex ...