GithubHelp home page GithubHelp logo

react-umeditor's Introduction

react-umeditor

Version Downloads

React Editor like Umeditor

Install

npm install react-umeditor --save

Use

javascript

var React = require('react');
var Editor = require('react-umeditor');

class App extends React.Component {
	constructor(props){
		super(props);
		this.state = {
			content: ""
		}
	}
	handleChange(content){
		this.setState({
			content: content
		})
	}
	getIcons(){
		var icons = [
			"source | undo redo | bold italic underline strikethrough fontborder emphasis | ",
			"paragraph fontfamily fontsize | superscript subscript | ",
			"forecolor backcolor | removeformat | insertorderedlist insertunorderedlist | selectall | ",
			"cleardoc  | indent outdent | justifyleft justifycenter justifyright | touppercase tolowercase | ",
			"horizontal date time  | image emotion spechars | inserttable"
		]
		return icons;
	}
	getPlugins(){
		return {
			"image": { 
				"uploader": { 
					"name":"file", 
					"url": "/api/upload" 
				} 
			} 
		}
	}
	render(){
	    var icons = this.getIcons();
		var plugins = this.getPlugins();
		return (<Editor ref="editor" 
			icons={icons} 
			value={this.state.content} defaultValue="<p>React Umeditor</p>" 
			onChange={this.handleChange.bind(this)} 
			plugins={plugins} />)
	}
}

html

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Editor Demo</title>
	
	<!-- mathquill & umeditor stylesheet & if you have the formula icon -->
	<link rel="stylesheet" href="../../dist/third-part/mathquill/mathquill.css"/>
	
	<link rel="stylesheet" href="app.css" type="text/css" />
</head>
<body>
	<div id="react-container"></div>
	
	<!-- jquery & mathquill javascript & if you have the formula icon -->
	<script src="../../dist/third-part/jquery.min.js"></script>
	<script src="../../dist/third-part/mathquill/mathquill.js"></script>
	
	<!-- your react script -->
	<script src="bundle.js"></script>
	<script src="app.js"></script>
</body>
</html>

Example

Ref Functions

You can this.refs.editor.xxx()! The xxx maybe is as follows:

  • findDOMNode: find refs by ref name "root","editarea","toolbar","color"
  • setContent: set html of editor
  • getContent: get html of editor
  • focusEditor: focus the editor

Props

You can set the props!The props maybe is as follows:

  • onFocus: the focus event
  • onChange: the text change event { content: string }
  • defaultValue: default value of editor
  • value: value of editor
  • icons: icons of toolbar
  • plugins: settings of plugins
    • toolbar: settings of toolbar
      • icons: custom icons
        • name: name of icon
        • title: title of icon
        • onIconClick: handle event
        • mapRangeState: filter rangeState
        • props: props of icon & component
        • component: custom component, eg. dialog
    • image: settings of image dialog
      • uploader: settings of image uploader
        • name: form name of xhr
        • url: url of server
        • data: other formData of xhr
        • filter: filter json style body
      • customUploader: custom file uploader(see FileUploader)

Icons

Support icons, As fllow:

source undo redo bold italic underline strikethrough fontborder emphasis 
paragraph fontfamily fontsize superscript subscript 
forecolor backcolor removeformat insertorderedlist insertunorderedlist  selectall 
cleardoc  indent outdent justifyleft justifycenter justifyright  touppercase tolowercase 
horizontal date time  image emotion spechars inserttable formula

Snapshot

snapshot

Develop

// clone code
git clone https://github.com/liuhong1happy/react-umeditor
cd react-umeditor
// install require
npm install
// build
npm run build
// run example server
cd example
npm run example

Todo - Version 1.0

  • 1. Custom Image Uploader Props
  • 2. Custom Toolbar Icon
  • 3. ES6 Style
  • 4. React16
  • 5. Tests (Toolbar & Example & New Feature)
  • 6. Docs (README.md & Docs & Example Docs)

Contribute

Changes and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specific branch and request to pull into master! If you can, please make sure the editor fully works before sending the PR, as that will help speed up the process.

See more document

Concat

Email: [email protected]

QQ Group: 247978846

react-umeditor's People

Contributors

djyde avatar liuhong1happy avatar lrongww avatar lzhgostudy avatar watsy0007 avatar wuhaoa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-umeditor's Issues

怎么绑定七牛服务器去上传图片?

我现在的需求是在编辑器里能上传图片,现在看react-umeditor的介绍里是使用plugins来告诉编辑器uploader,我现在用的是七牛服务器的上传服务,它需要一个上传token,我该在哪里传递这个参数?
还有就是在哪里处理上传完成的回调?

[公告]升级0.8.0

  1. 调整EditorResize放置位置。
  2. 拆分editor.js,分出EditorCore实现核心逻辑,原editor做上层封装和加载调度。

使用七牛上传的bug

使用0.4.1版本的七牛上传图片的plugins的时候,
第一张能上传成功,
然后继续上传第二张的时候,会上传失败,状态码返回614

请教下关于初始高度,宽度的问题?

如何设置编辑器的初始宽高啊?

类似UEditor的

initialFrameWidth {Number} [默认值:1000] //初始化编辑器宽度,默认1000

initialFrameHeight {Number} [默认值:320] //初始化编辑器高度,默认320

[bug]两个不同页面都使用此组件,来回切换后一直处于正在加载

在两个不同页面使用此组件,在两个页面间多次来回切换后,组件处于正在加载中

目前解决方案
在父组件的componentDidMount中设置编辑器的loaded state 为 true

componentDidMount() {
  this.editor.setState({
    loaded: true,
  });
}

// ES6 style
render() {
  <Editor
    ref={(editor) => {this.editor = editor}}
    icons={icons}
    plugins={plugins}
    />
}

页面自发失去焦点

当其他的input(type=text)和该编辑器在同一表单中,编辑其他的input会自发失去焦点,umeditor会自动获取焦点

图片上传绝对是个坑。

{'data': {'image_src': xxx} , status:'success'},这是上传自己服务器的返回数据格式。

开发者并没有提到。加群也没人理我。

是我自己google出来的。

绝对是个坑,警示后人!

MathQuill is not defined

RT 报这个错误

// 需要外部引用MathQuill
var MQ = MathQuill ? MathQuill.getInterface(2) : null;

在react项目中的使用问题

在项目中引入使用的的时候,npm install react-umeditor --save安装以后

<link rel="stylesheet" href="../../dist/third-part/mathquill/mathquill.css"/> <link rel="stylesheet" href="../../dist/react-umeditor.css" type="text/css" />
<script src="../../dist/third-part/jquery.min.js"></script> <script src="../../dist/third-part/mathquill/mathquill.js"></script>

这些都必须要重新引入一下么?
能集成在react-umeditor中么?

组件功能建议

1 、实现@提及功能,并能知道当前位置,在编辑内容中输入@可以根据不同位置获取不同的提及内容
参考
image

2、 开放keydown及keyup等接口,并能知道当前文档内容位置,便于根据输入内容做些校验等工作。

3、开放一个原生的umeditor对象,可以使用umeditor对象的相关方法

路由改变永远显示 正在加载...

image
image
对比npm上的编译后代码和github项目源码,发现这两处写法有差异,导致onEditorMount未被触发,EditorEventEmitter中的this.isStart第一次赋值后永远为true,所以路由更改后页面一直显示 正在加载...

2016年8月27日集中问题解决

  1. 清空文档按钮不能清除题干内容
  2. toggle Dropdown\Box\Dialog
  3. open only one dialog
  4. 当富文本编辑框和其他输入框一起时,在其他输入框输入数据会自动失去焦点。
  5. 添加字体边框,清除格式对字体边框无效 或者 点击边框重新取消。
  6. 添加字体边框,在修改字体大小,边框大小未做改变。

9月6日问题集中解决

  1. 设置value和setContent不生效的问题。
  2. 上传图片回调字段的问题。
  3. 光标放置文本段落上,相应功能按钮没有处于active状态。
  4. 因开发人员设置editor-container的样式属性position为static,造成的dialog、dropdown等坐标计算问题。

表情、图片选中后的一系列问题

1、表情图片选中后出现选中框,点删除键或者delete删除不了
2、将光标移到要删除图片、表情的位置后,点删除键,可以删除,但是选中框依然存在
111
3、选中框移除不了

在其他页面触发了setState操作

我尝试将编辑器用在这个项目上, 编辑器可以正常加载. 但是加载了编辑器页面后切换到其他页面, 点击鼠标会报warning. 初学react, 不是很懂如何解决

image

警告信息是

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the EditorCore component.

最后两行是

handleRangeChange   @   EditorCore.react.js:226
handleMouseUp   @   EditorContentEditableDiv.react.js:109

完整的是
image

关于最近会升级到1.0版本的公告

最近的bug会在这几天集中解决,如果有问题也请联系 [email protected] 或者加入qq群247978846

升级前,需要做的工作如下:

  1. 会对所有功能全方位系统性的测试
  2. 会组建若干个示例,以讲解不同场景下的使用方式。
  3. 会创建相应的文档,以便开发能迅速切入,能让使用者更好的参考。
  4. 修改代码统一代码风格为ES6
  5. 加入onChange事件的支持

后端打包报错

在node环境下没有NodeList和window这类对象, 在后端打包的时候会报错

菜单栏功能不全?

菜单栏目前有诸如:链接:link,取消链接:unlink,全屏:fullscreen等等功能没有实现,请问后续会添加吗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.