client/js/renderer/nodeeditor.js
changeset 600 e12243191095
parent 530 9823b527c3a1
child 625 4d67ae41b9b3
--- a/client/js/renderer/nodeeditor.js	Thu Mar 31 17:12:55 2016 +0200
+++ b/client/js/renderer/nodeeditor.js	Tue Apr 05 18:32:32 2016 +0200
@@ -1,5 +1,5 @@
 
-define(['jquery', 'underscore', 'requtils', 'renderer/baseeditor', 'renderer/shapebuilder', 'ckeditor-jquery'], function ($, _, requtils, BaseEditor, ShapeBuilder) {
+define(['jquery', 'underscore', 'requtils', 'renderer/baseeditor', 'renderer/shapebuilder', 'ckeditor-core'], function ($, _, requtils, BaseEditor, ShapeBuilder, CKEditor) {
     'use strict';
 
     var Utils = requtils.getUtils();
@@ -51,11 +51,11 @@
             }));
             this.redraw();
             var _this = this,
-                editorInstance = _this.options.show_node_editor_description_richtext ?
-                    $(".Rk-Edit-Description").ckeditor(_this.options.richtext_editor_config) :
+                editorInstance = (this.renderer.isEditable()  && _this.options.show_node_editor_description_richtext) ?
+                    CKEditor.inline("Rk-Edit-Description-"+_model.get("_id"), _this.options.richtext_editor_config) :
                     false,
-                editorInstanceTitle = _this.options.show_node_editor_title_richtext ?
-                    $(".Rk-Edit-Title").ckeditor(_this.options.richtext_editor_config) :
+                editorInstanceTitle = (this.renderer.isEditable() && _this.options.show_node_editor_title_richtext) ?
+                    CKEditor.inline("Rk-Edit-Title-"+_model.get("_id"), _this.options.richtext_editor_config) :
                     false,
                 closeEditor = function() {
                     _this.renderer.removeRepresentation(_this);
@@ -74,19 +74,15 @@
                 _this.editor_$.find(".Rk-Edit-Goto").off('click');
 
                 if(_this.options.show_node_editor_description_richtext) {
-                    if(typeof editorInstance.editor !== 'undefined') {
-                        var _editor = editorInstance.editor;
-                        delete editorInstance.editor;
-                        _editor.focusManager.blur(true);
-                        _editor.destroy();
+                    if(editorInstance) {
+                        editorInstance.focusManager.blur(true);
+                        editorInstance.destroy();
                     }
                 }
                 if(_this.options.show_node_editor_title_richtext) {
-                    if(typeof editorInstanceTitle.editor !== 'undefined') {
-                        var _editor_title = editorInstanceTitle.editor;
-                        delete editorInstanceTitle.editor;
-                        _editor_title.focusManager.blur(true);
-                        _editor_title.destroy();
+                    if(editorInstanceTitle) {
+                        editorInstanceTitle.focusManager.blur(true);
+                        editorInstanceTitle.destroy();
                     }
                 }
             };
@@ -118,10 +114,10 @@
                         }
                         if (_this.options.show_node_editor_description) {
                             if(_this.options.show_node_editor_description_richtext) {
-                                if(typeof editorInstance.editor !== 'undefined' &&
-                                    editorInstance.editor.checkDirty()) {
-                                    _data.description = editorInstance.editor.getData();
-                                    editorInstance.editor.resetDirty();
+                                if(editorInstance &&
+                                    editorInstance.checkDirty()) {
+                                    _data.description = editorInstance.getData();
+                                    editorInstance.resetDirty();
                                 }
                             }
                             else {
@@ -130,10 +126,10 @@
                         }
                         if (_this.options.show_node_editor_title) {
                             if(_this.options.show_node_editor_title_richtext) {
-                                if(typeof editorInstanceTitle.editor !== 'undefined' &&
-                                        editorInstanceTitle.editor.checkDirty()) {
-                                    _data.title = editorInstanceTitle.editor.getData();
-                                    editorInstanceTitle.editor.resetDirty();
+                                if(editorInstanceTitle &&
+                                        editorInstanceTitle.checkDirty()) {
+                                    _data.title = editorInstanceTitle.getData();
+                                    editorInstanceTitle.resetDirty();
                                 }
                             }
                             else {
@@ -171,18 +167,18 @@
                 this.editor_$.find("input, textarea, select").on("change keyup paste", onFieldChange);
                 if( _this.options.show_node_editor_description &&
                     _this.options.show_node_editor_description_richtext &&
-                    typeof editorInstance.editor !== 'undefined')
+                    editorInstance)
                 {
-                    editorInstance.editor.on("change", onFieldChange);
-                    editorInstance.editor.on("blur", onFieldChange);
+                    editorInstance.on("change", onFieldChange);
+                    editorInstance.on("blur", onFieldChange);
                 }
-                
+
                 if( _this.options.show_node_editor_title &&
                     _this.options.show_node_editor_title_richtext &&
-                    typeof editorInstanceTitle.editor !== 'undefined')
+                    editorInstanceTitle)
                 {
-                    editorInstanceTitle.editor.on("change", onFieldChange);
-                    editorInstanceTitle.editor.on("blur", onFieldChange);
+                    editorInstanceTitle.on("change", onFieldChange);
+                    editorInstanceTitle.on("blur", onFieldChange);
                 }
 
                 if(_this.options.allow_image_upload) {