//console.log(editor) ;
//alert("myCommand");
//var sel = editor.getSelection();
//var text = ( sel&&sel.getType()==CKEDITOR.SELECTION_TEXT&&sel.getSelectedText()!==null )?sel.getSelectedText():'';
//console.log(text) ;

 // selection something in the editor, and get the selection:
 //var sel = editor.getSelection();

 // make the selection to a range array
 //var ranges = sel.getRanges();

 // to create bookmarks version 2 out of the ranges
 //var bm = ranges.createBookmarks2() ;

 // ok, now you can selection something else in the editor
 // and we will restore the bookmark
 // this will return in the console a selection object.
 //editor.getSelection().selectBookmarks(bm)
 // select ranges
 //console.log(ranges) ;
 //editor.getSelection().selectRanges(ranges)

//var bookmarks = editor.getSelection().createBookmarks2();
//console.log(sel) ;

//console.log(bm) ;

//console.log(selected_text) ;
                                 //  var newElement = new CKEDITOR.dom.element("a");              // Make Paragraff
                                 //  newElement.setAttributes({href: 'http://dev.kvzrm.ru'})                 // Set Attributes
                                 //  newElement.setHtml(selected_text);                           // Set text to element
                                 //  editor.insertElement(newElement);                            // Add Element


                                 /*editor.applyStyle(new CKEDITOR.style({
                                             Element : 'pre',
                                             Attributes : { class : 'Myclass' },
                                             Styles : { color : 'red','font-family' : 'Courier'}
                                           }));*/

                               // это работало
                               //var range = editor.getSelection().getRanges()[0];
                               //console.log(range.startPath().elements[0].$); //Выводит то что нужно
                               //alert(range.startPath().elements[0].$);// Выводит [ObjectHTML***]


//console.log(editor.getSelection()) ;
var selected_text = range.startPath().elements[0].$.outerHTML; // Get Text
//console.log(range.startPath().elements) ;

var text = editor.getSelection().getSelectedText();
//console.log(text) ;

/*CKEDITOR.plugins.add( 'Timestamp', {
                       icons: 'timestamp',
                       init: function( editor ) {
                           //Plugin logic goes here.
                           console.log('Плагин иницилизирован') ;
                       }
                   });*/

                  /* CKEDITOR.editorConfig = function( config ) {
                               	// Define changes to default configuration here. For example:
                               	config.language = 'ru';
                               	// config.uiColor = '#AADC6E';
                               	config.filebrowserWindowWidth = '800';
                               	config.filebrowserWindowHeight = '250';
                               	config.resize_enabled = true;
                               	config.htmlEncodeOutput = false;
                               	config.entities = false;
                               	config.extraPlugins = 'timestamp';

                               	config.codemirror_theme = 'rubyblue';
                               	config.toolbar = 'Custom';
                               };


                   */



// var text=window.editor.getData();


// const editorData = window.editor.data.get();


// Now, use `editorData` and `commentThreadsData` to save the data in your application.
// For example, you can set them as values of hidden input fields.
//  console.log( editorData );

// console.log('commentThreadsData') ;
//  console.log(JSON.stringify(commentThreadsData));


//send_ajax_request({cmd:'quiz/section_save',section_id:<?echo $this->rec_section['pkey']?>,manual:text,comments:JSON.stringify(commentThreadsData)}) ;
// send_selected_text_fo_ajax(window.editor,data.threadId,data.commentId,data.content) ;

/*return Promise.resolve( {
                                  threadId: 'thread-1',
                                  comments: [
                                      {
                                          commentId: 'comment-1',
                                          authorId: 'user-2',
                                          content: '<p>Are we sure we want to use a made-up disorder name?</p>',
                                          date: new Date()
                                      }
                                  ],
                                  isFromAdapter: true
                              } );*/

