react use simditor
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的更多相关文章
- React后台管理系统-rich-editor组件
1.Simditor组件的github地址:https://github.com/mycolorway/simditor 网址:http://simditor.tower.im/ 2.在util里边新 ...
- react构建前端项目方法汇总
react简介: 一.使用react 创建一个PC端的项目 (a):使用 yemon 创建一个 webpack 的 react 的项目 控制台安装并且产看 yemon 的版本 yo -v (b): 全 ...
- react组件的生命周期
写在前面: 阅读了多遍文章之后,自己总结了一个.一遍加强记忆,和日后回顾. 一.实例化(初始化) var Button = React.createClass({ getInitialState: f ...
- 十分钟介绍mobx与react
原文地址:https://mobxjs.github.io/mobx/getting-started.html 写在前面:本人英语水平有限,主要是写给自己看的,若有哪位同学看到了有问题的地方,请为我指 ...
- RxJS + Redux + React = Amazing!(译一)
今天,我将Youtube上的<RxJS + Redux + React = Amazing!>翻译(+机译)了下来,以供国内的同学学习,英文听力好的同学可以直接看原版视频: https:/ ...
- React 入门教程
React 起源于Facebook内部项目,是一个用来构建用户界面的 javascript 库,相当于MVC架构中的V层框架,与市面上其他框架不同的是,React 把每一个组件当成了一个状态机,组件内 ...
- 通往全栈工程师的捷径 —— react
腾讯Bugly特约作者: 左明 首先,我们来看看 React 在世界范围的热度趋势,下图是关键词“房价”和 “React” 在 Google Trends 上的搜索量对比,蓝色的是 React,红色的 ...
- 2017-1-5 天气雨 React 学习笔记
官方example 中basic-click-counter <script type="text/babel"> var Counter = React.create ...
- RxJS + Redux + React = Amazing!(译二)
今天,我将Youtube上的<RxJS + Redux + React = Amazing!>的后半部分翻译(+机译)了下来,以供国内的同学学习,英文听力好的同学可以直接看原版视频: ht ...
随机推荐
- UML_visio安装及使用
安装:百度云安装visio 64bit 类图在visio当中 用例图 来自为知笔记(Wiz)
- Codeforces Round #304 (Div.2)
A. Soldier and Bananas 题意:有个士兵要买w个香蕉,香蕉起步价为k元/个,每多买一个则贵k元.问初始拥有n元的士兵需要借多少钱? 思路:简单题 #include<iostr ...
- Java源码解释之Integer.bitCount
Java中的Integer.bitCount(i)的返回值是i的二进制表示中1的个数.源码如下: public static int bitCount(int i) { // HD, Figure 5 ...
- Wannafly交流赛1 _A_有理数 【水】
Wannafly交流赛1 A有理数 [水] 链接:https://www.nowcoder.com/acm/contest/69/A 来源:牛客网 题目描述 有一个问题如下: 给你一个有理数v,请找到 ...
- Java 基础总结(一)
本文参见:http://www.cnblogs.com/dolphin0520/category/361055.html 1. String,StringBuffer,StringBuilder 1) ...
- ASP.NET MVC CheckBoxFor的int to bool
当我们使用CheckBoxFor类型需要使用bool ,可以将 int转换成bool <div class="form-group"> <label class= ...
- Go语言学习之数据类型以及类型转换(The way to go)
生命不止,继续go go go 介绍来go中的变量和常量,今天介绍一下go中的基本类型. 可以分为四大类,现在一点点道来. Boolean Types 布尔类型,不用过多介绍来吧,就是true和fal ...
- MapReduce:给出children-parents(孩子——父母)表,要求输出grandchild-grandparent(孙子——爷奶)表
hadoop中使用MapReduce单表关联案例: MapReduce:给出children-parents(孩子——父母)表,要求输出grandchild-grandparent(孙子——爷奶)表. ...
- 详细解读ARM寄存器之CPSR【转】
本文转载自:https://blog.csdn.net/david_luyang/article/details/6276533 详细解读ARM寄存器之CPSR 整理人:卢阳 QQ:820927872 ...
- SpringBoot Bean作用域
Bean在一般容器中都存在以下2种作用域: singleton 默认值,IoC容器只存在单例 prototype 每当从IoC容器中取出一个Bean,则创建一个新的Bean 在Web容器中存在4种作用 ...