1+ function init ( Survey ) {
2+ var widget = {
3+ name : "editor" ,
4+ title : "Editor" ,
5+ iconName : "icon-editor" ,
6+ widgetIsLoaded : function ( ) { return typeof CKEDITOR !== undefined ; } ,
7+ isFit : function ( question ) {
8+ return question . getType ( ) === 'editor' ;
9+ } ,
10+ htmlTemplate : "<textarea rows='10' cols='80' style: {width:'100%'}></textarea>" ,
11+ activatedByChanged : function ( activatedBy ) {
12+ Survey . JsonObject . metaData . addClass ( "editor" , [ ] , null , "empty" ) ;
13+ Survey . JsonObject . metaData . addProperty ( "editor" , { name : "height" , default : 300 } ) ;
14+ } ,
15+ afterRender : function ( question , el ) {
16+ CKEDITOR . editorConfig = function ( config ) {
17+ config . language = 'es' ;
18+ config . height = question . height ;
19+ config . toolbarCanCollapse = true ;
20+ } ;
21+ var editor = CKEDITOR . replace ( el ) ;
22+ var isValueChanging = false ;
23+ var updateValueHandler = function ( ) {
24+ if ( isValueChanging ) return ;
25+ editor . setData ( question . value ) ;
26+ } ;
27+ editor . on ( 'change' , function ( ) {
28+ isValueChanging = true ;
29+ question . value = editor . getData ( ) ;
30+ isValueChanging = false ;
31+ } ) ;
32+ question . valueChangedCallback = updateValueHandler ;
33+ updateValueHandler ( ) ;
34+ } ,
35+ willUnmount : function ( question , el ) {
36+ }
37+ }
38+
39+ Survey . CustomWidgetCollection . Instance . addCustomWidget ( widget , "customtype" ) ;
40+ }
41+
42+ if ( typeof Survey !== "undefined" ) {
43+ init ( Survey ) ;
44+ }
45+
46+ export default init ;
0 commit comments