loopindex / ckeditor-track-changes

Track changes plugin for CKEditor, based on ICE (track changes for TinyMCE).
www.loopindex.com
Other
51 stars 55 forks source link

tracking on but changes hidden? #137

Open porjo opened 6 years ago

porjo commented 6 years ago

I'd like to enable tracking, but have the changes hidden by default. It's not clear how I would achieve this.

Could an isVisible config option be added to complement the existing isTracking option?

My attempts to use toggleShow() after initialization have failed. Listening for LITE.Events.INIT fails with LITE is not defined e.g.

CKEDITOR.on( 'instanceReady', function( e ) { 
               e.editor.on( LITE.Events.INIT, function( evt ) { 
                        evt.data.lite.toggleShow(false);
                }); 
});

Finding the plugin instance from the editor instance fails with this._tracker is null e.g.

CKEDITOR.on( 'instanceReady', function( e ) { 
        e.editor.plugins.lite.findPlugin(e.editor).toggleShow(false);
});

(using Ckeditor 4.6.2 with bundled track changes plugin)

nikmaslik commented 6 years ago

For inline editor toggleShow works in 4.5.10 version :

 var editor = CKEDITOR.inline(editorId, config);
 editor.on(LITE.Events.INIT, function (event) {
                var lite = event.data.lite;
                lite.toggleTracking(true, false);
                lite.toggleShow(false, false);  
                });
porjo commented 6 years ago

I've found that if I wrap the editor.on() in a setTimeout() of 3 seconds e.g.

var editor = CKEDITOR.inline(editorId, config);
setTimeout(function() {
  editor.on(LITE.Events.INIT, function (event) {
    var lite = event.data.lite;
    lite.toggleTracking(true, false);
    lite.toggleShow(false, false);  
  });
},3000);

it works as required - otherwise I get LITE is not defined error. I have many other ckeditor instances on the same page, so I'm guessing it is taking a long time for everything to be ready. What is a better way to handle that?

EDIT: I came up with this workaround

var liteCheck = setInterval(function () {
                if(typeof LITE !== "undefined" ) { 
                        editor.on( LITE.Events.INIT, function( evt ) { 
                                evt.data.lite.toggleShow(false, false);
                        });
                        clearInterval(liteCheck);
                }
        }, 100);