rc-editor-core
Advanced tools
Comparing version 0.6.19 to 0.7.0
@@ -11,2 +11,6 @@ 'use strict'; | ||
var _propTypes = require('prop-types'); | ||
var PropTypes = _interopRequireWildcard(_propTypes); | ||
var _draftJs = require('draft-js'); | ||
@@ -16,6 +20,4 @@ | ||
var _setImmediate = require('fbjs/lib/setImmediate'); | ||
require('setimmediate'); | ||
var _setImmediate2 = _interopRequireDefault(_setImmediate); | ||
var _Toolbar = require('../Toolbar'); | ||
@@ -76,2 +78,6 @@ | ||
_this.cancelForceUpdateImmediate = function () { | ||
clearImmediate(_this.forceUpdateImmediate); | ||
_this.forceUpdateImmediate = null; | ||
}; | ||
_this.handlePastedText = function (text, html) { | ||
@@ -228,2 +234,5 @@ var editorState = _this.state.editorState; | ||
EditorCore.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
if (this.forceUpdateImmediate) { | ||
this.cancelForceUpdateImmediate(); | ||
} | ||
if (this.controlledMode) { | ||
@@ -238,2 +247,6 @@ var decorators = nextProps.value.getDecorator(); | ||
EditorCore.prototype.componentWillUnmount = function componentWillUnmount() { | ||
this.cancelForceUpdateImmediate(); | ||
}; | ||
EditorCore.prototype.generatorDefaultValue = function generatorDefaultValue(editorState) { | ||
@@ -306,3 +319,3 @@ var defaultValue = this.props.defaultValue; | ||
var enabledEvents = ['onUpArrow', 'onDownArrow', 'handleReturn', 'onFocus', 'onBlur', 'handlePastedText']; | ||
var enabledEvents = ['onUpArrow', 'onDownArrow', 'handleReturn', 'onFocus', 'onBlur', 'onTab', 'handlePastedText']; | ||
var eventHandler = {}; | ||
@@ -340,6 +353,13 @@ enabledEvents.forEach(function (event) { | ||
this.props.onChange(newEditorState); | ||
if (this.controlledMode) { | ||
this.forceUpdateImmediate = setImmediate(function () { | ||
return _this6.setState({ | ||
editorState: new _draftJs.EditorState(_this6.state.editorState.getImmutable()) | ||
}); | ||
}); | ||
} | ||
} | ||
if (!this.controlledMode) { | ||
this.setState({ editorState: newEditorState }, focusEditor ? function () { | ||
return (0, _setImmediate2["default"])(function () { | ||
return setImmediate(function () { | ||
return _this6.refs.editor.focus(); | ||
@@ -449,3 +469,4 @@ }); | ||
toolbars = _props2.toolbars, | ||
style = _props2.style; | ||
style = _props2.style, | ||
readOnly = _props2.readOnly; | ||
var _state = this.state, | ||
@@ -459,3 +480,3 @@ editorState = _state.editorState, | ||
var Toolbar = toolbar.component; | ||
return React.createElement("div", { style: style, className: prefixCls + '-editor', onClick: this.focus.bind(this) }, React.createElement(Toolbar, { editorState: editorState, prefixCls: prefixCls, className: prefixCls + '-toolbar', plugins: toolbarPlugins, toolbars: toolbars }), React.createElement("div", { className: prefixCls + '-editor-wrapper', ref: function ref(ele) { | ||
return React.createElement("div", { style: style, className: prefixCls + '-editor ' + (readOnly ? 'readonly' : ''), onClick: this.focus.bind(this) }, React.createElement(Toolbar, { editorState: editorState, prefixCls: prefixCls, className: prefixCls + '-toolbar', plugins: toolbarPlugins, toolbars: toolbars }), React.createElement("div", { className: prefixCls + '-editor-wrapper', ref: function ref(ele) { | ||
return _this8._editorWrapper = ele; | ||
@@ -481,6 +502,6 @@ }, style: style, onClick: function onClick(ev) { | ||
EditorCore.childContextTypes = { | ||
getEditorState: React.PropTypes.func, | ||
setEditorState: React.PropTypes.func | ||
getEditorState: PropTypes.func, | ||
setEditorState: PropTypes.func | ||
}; | ||
exports["default"] = EditorCore; | ||
module.exports = exports['default']; |
{ | ||
"name": "rc-editor-core", | ||
"version": "0.6.19", | ||
"version": "0.7.0", | ||
"description": "editor-core ui component for react", | ||
@@ -59,5 +59,6 @@ "keywords": [ | ||
"draft-js": "^0.10.0", | ||
"fbjs": "^0.8.9", | ||
"immutable": "^3.7.4", | ||
"lodash": "^4.16.5" | ||
"lodash": "^4.16.5", | ||
"prop-types": "^15.5.8", | ||
"setimmediate": "^1.0.5" | ||
}, | ||
@@ -64,0 +65,0 @@ "pre-commit": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54775
1096
5
+ Addedprop-types@^15.5.8
+ Addedsetimmediate@^1.0.5
- Removedfbjs@^0.8.9