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. android 6 (API 23) 及更高版本 面向 NDK 开发者的 Android 变更

    Android N 已经出来,有了好大的变化,对于我们开发者来说,最大的影响莫过于**NDK**相关东西. 以下是在中国谷歌开发者社区看到的.里面有好多的变化,欢迎大家来讨论. 发布人:开发顾问 Dm ...

  2. corethink功能模块探索开发(十六)后台搜索功能

    效果图: 代码很简单,就是添加搜索框,搜索字段,在初始化页面查询的时候添加查询条件. 1.添加搜索框 添加到删除按钮后边. ->setSearch('请输入设备名称/MAC/宿舍号', U('i ...

  3. linux环境配置时钟同步ntpd服务

    配置: 服务器1:192.168.169.139 服务器2:192.168.169.140 服务器3:192.168.169.141 目的:NTP能与互联网的时间保持同步,而且本身也是一台NTP服务器 ...

  4. 使用ansible 完成yum安装lamp环境

    使用ansible 完成yum安装lamp环境 [root@node2 ~]# cd /etc/ansible/playbook/[root@node2 playbook]# lslamp[root@ ...

  5. Angular 学习笔记 :初识 $digest , $watch , $apply,浅析用法 。

    传统的浏览器事件循环 :浏览器本身一直在等待事件,并作出响应.如果你点击一个button或者在input 中输入字符,我们在 JS 中 监听这些事件并设定了回调函数,那么这些事件被触发以后,回调函数就 ...

  6. ruby项目文件上传功能实现

    这里我将从视图.控制器各个层面进行讲解. rails 提供了文件上传功能,可以直接进行下面的编码 <%= form_for :document, :html =>{:multipart = ...

  7. Kattis - cokolada【水】

    Kattis - cokolada[水] 题意 有一个人想吃巧克力,但是巧克力都是按照 2 的幂次的数量包装的,然后他想吃一定数量块的巧克力,然后可以敲碎,每次敲碎都分成两半,比如四块装的分成两块就是 ...

  8. python中数据类型转换

    python中list和str互转   1.list转str 假设有一个名为test_list的list,转换后的str名为test_str 则转换方法: test_str = "" ...

  9. mysql 进阶查询(学习笔记)

    学习笔记,来源:实验楼 ,链接: https://www.shiyanlou.com/courses/9   一.日期计算: 1.要想确定每个宠物有多大,可以使用函数TIMESTAMPDIFF()计算 ...

  10. toLatin1 toLocal8Bit

    toLatin1.toLocal8Bit都是QString转QByteArray的方法,Latin1代表ASCII,Local8Bit代表unicode