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. 使用Free命令查看Linux服务器内存使用状况(-/+ buffers/cache详解)

    free命令可选参数 -b,-k,-m,-g show output in bytes, KB, MB, or GB -h human readable output (automatic unit ...

  2. Verilog学习总结

    1.多个always语句不能对同一变量赋值. 2.assign语句只能进行阻塞赋值,用来描述组合逻辑. 3.verilog描述方式:结构描述(门级描述和模块调用).数据流描述(assign,wire型 ...

  3. Xilinx中解决高扇出的方法

    Fanout,即扇出,指模块直接调用的下级模块的个数,如果这个数值过大的话,在FPGA直接表现为net delay较大,不利于时序收敛.因此,在写代码时应尽量避免高扇出的情况.但是,在某些特殊情况下, ...

  4. JS 中的substring ,substr ,slice,split,join

    substr with different arguments passed in: str.substring(startNum,stopNum ); str.slice(startNum,stop ...

  5. Spring.Net+NHibernate+Castle学习网站

    1.刘冬  http://www.cnblogs.com/GoodHelper/archive/2009/10/16/1584243.html 2.学习资料 http://www.cnblogs.co ...

  6. React:快速上手(3)——列表渲染

    React:快速上手(3)——列表渲染 使用map循环数组 了解一些ES6 ES6, 全称 ECMAScript 6.0 ,是 JaveScript 的下一个版本标准,2015.06 发版.ES6 主 ...

  7. ICMP与PING解析

    1.ICMP格式 ICMP是(Internet Control Message Protocol)Internet控制报文协议.它是TCP/IP协议族的一个子协议,用于在IP主机.路由器之间传递控制消 ...

  8. 深入理解JVM 垃圾收集器(上)

    HotSpot虚拟机中的垃圾收集器 GC评价标准 GC调优 响应时间 吞吐量 1.新生代收集器 Serial收集器 ParNew收集器 Parallel Scavenge收集器 2.老年代收集器 Se ...

  9. MSER(Maximally Stable Extremal Regions)算法总结

    ER与ER Tree形成过程 判断ER是否位MSER条件 MSER源码分析

  10. SpringMVC的HelloWorld快速入门!

    1.加入JAR包: commons-logging-1.1.3.jar spring-aop-4.0.0.RELEASE.jar spring-beans-4.0.0.RELEASE.jar spri ...