@@ -48,13 +48,35 @@ var ContentEditable = function (_React$Component) {
48
48
html = _props . html ,
49
49
props = _objectWithoutProperties ( _props , [ 'tagName' , 'html' ] ) ;
50
50
51
+ var contentEditableState = true ;
52
+
53
+ if ( this . props . plaintextOnly ) {
54
+ contentEditableState = "plaintext-only" ;
55
+ }
56
+
57
+ if ( this . props . typing ) {
58
+ contentEditableState = "typing" ;
59
+ }
60
+
61
+ if ( this . props . caret ) {
62
+ contentEditableState = "caret" ;
63
+ }
64
+
65
+ if ( this . props . events ) {
66
+ contentEditableState = "events" ;
67
+ }
68
+
69
+ if ( this . props . disabled ) {
70
+ contentEditableState = false ;
71
+ }
72
+
51
73
return _react2 . default . createElement ( tagName || 'div' , _extends ( { } , props , {
52
74
ref : function ref ( e ) {
53
75
return _this2 . htmlEl = e ;
54
76
} ,
55
77
onInput : this . emitChange ,
56
78
onBlur : this . props . onBlur || this . emitChange ,
57
- contentEditable : ! this . props . disabled ,
79
+ contentEditable : contentEditableState ,
58
80
dangerouslySetInnerHTML : { __html : html }
59
81
} ) , this . props . children ) ;
60
82
}
@@ -100,12 +122,12 @@ var ContentEditable = function (_React$Component) {
100
122
if ( ! this . htmlEl ) return ;
101
123
var html = this . htmlEl . innerHTML ;
102
124
if ( this . props . onChange && html !== this . lastHtml ) {
103
- // Clone event with Object.assign to avoid
125
+ // Clone event with Object.assign to avoid
104
126
// "Cannot assign to read only property 'target' of object"
105
- var evt = Object . assign ( { } , evt , {
106
- target : {
107
- value : html
108
- }
127
+ var evt = Object . assign ( { } , evt , {
128
+ target : {
129
+ value : html
130
+ }
109
131
} ) ;
110
132
this . props . onChange ( evt ) ;
111
133
}
@@ -117,4 +139,4 @@ var ContentEditable = function (_React$Component) {
117
139
} ( _react2 . default . Component ) ;
118
140
119
141
exports . default = ContentEditable ;
120
- module . exports = exports [ 'default' ] ;
142
+ module . exports = exports [ 'default' ] ;
0 commit comments