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 ...
随机推荐
- golang 常用的日期方法和时区的坑
import( "time" ) 1.获取当前时间 time.Now(),返回类型:time结构. 2.字符串转为日期 t, _ := time.ParseInLocation(& ...
- 4 TensorFlow入门之dropout解决overfitting问题
------------------------------------ 写在开头:此文参照莫烦python教程(墙裂推荐!!!) ---------------------------------- ...
- webdeploy启用备份 msdeploy 启用backup
前提准备:完整安装Microsoft Web Deploy 3 下载页面:WebDeploy_amd64_zh-CN.msi msdeploy 同步站点 命令所在目录C:\Program Files\ ...
- maven依赖排除、顺序原则、版本统一管理
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-core& ...
- Android 6.0 Kotlin 蓝牙BLE扫描
package com.arci.myapplication import android.os.Bundleimport android.support.design.widget.Snackbar ...
- HackerRank - common-child【DP】
HackerRank - common-child[DP] 题意 给出两串长度相等的字符串,找出他们的最长公共子序列e 思路 字符串版的LCS AC代码 #include <iostream&g ...
- Unity 碰撞检测 OnTriggerEnter 入门
当我们需要检测两个物体A和B发生碰撞的时候,必须要满足一下条件 1:A和B必须有碰撞边界,你可以点开一个A,在属性窗口点击AddComponent,在physis(物理)目录下看到以下这些 ,根据形状 ...
- linux redhat下oracle11G安装
首先由于使用的是虚拟机,所有要修改ip 在LINUX下修改IP分为二种情况, 1.调试时修改IP,仅在当前生效,重启后恢复为原有IP ifconfig eth0 192.168.63.27 netma ...
- Jmeter使用非 GUI 模式,即命令行模式运行实例讲
转载:http://www.cnblogs.com/leeboke/p/5238269.html 参考资料:https://girliemangalo.wordpress.com/2009/10/29 ...
- PHP memcache扩展模块安装
安装php扩展模块memcache memcache 的工作就是在专门的机器的内存里维护一张巨大的hash表,来存储经常被读写的一些数组与文件,从而极大的提高网站的运行效率,减轻后端数据库的读写压力. ...