Installation
If your ckeditor build does not already contain LITE, drop the
lite folder into ckeditor's plugins folderGetting Started
- Include the lite plugin's interface in your html, e.g.
<script type="text/javascript" src="ckeditor/plugins/lite/lite-interface.js"></script>
You don't have to include this file, but doing so will allow you to use the constants defined in it, e.g.LITE.Commands.TOGGLE_TRACKING, LITE.Events.ACCEPT - If
LITEis not included in ckedito's plugins list, add it to the editor's configuration. The simplest way to do this is by adding the following line to ckeditor'sconfig.js:config.extraPlugins = 'lite';
If your configuration already contains some plugin tweaking, just make sure thatLITEis included in the editor's plugins list. - If you wish to make any other configuration changes via
config.js, verify that the editor's configuation contains alitesection by adding the following lines to ckeditor'sconfig.js:var lite = config.lite|| {}; config.lite = lite; - If your page doesn't include jQuery, the
LITEplugin will load it during its initialization. By default the code is loaded from thelits/jsfolder. If you want to provide a different path, you can do so by configuring the value oflite.jQueryPathin ckeditor'sconfig.js. The path you specify should be relative to thelitefolder.config.lite.jQueryPath = "../common/jquery.min.js";
Configuration
- By default, LITE loads a minifed version of
ice, located in itsjsfolder. To loadicefrom a different location, or load other versions (e.g. full sources for debugging), edit yourconfig.jsand set a value toconfig.lite.includes, e.g.config.lite.includes = ["js/my-includes.min.js", "js/some-plugins.min.js"];
Paths are relative to the LITE plugin folder - Select the
LITEcommands you want to include in ckeditor's toolbar. By default all the commands inlite-interace.jsare available in the toolbar except for toggle tooltips. To configure this, editconfig.jsand set a value to theconfig.lite.commands, e.g.// display only the show/hide, accept all and reject all commands. config.lite.commands = [LITE.Commands.TOGGLE_SHOW, LITE.Commands.ACCEPT_ALL, LITE.Commands.REJECT_ALL];
- Some more LITE options may be set through the
config.liteobject:userName- the initial username used by theICEchange trackeruserId- the initial user ID used by theICEchange trackertitleTemplate- the template of the text shown as a title (tooltip) when the cursor hovers over a tracked change region. The default value isChanged by %u %t,%urepresenting the user name and%trepresenting a time stamp relative to the current time (e.g. now, 2 minutes ago, May 31). The titles are refreshed periodically. If you provide an empty template, no title will be displayed.userStyles- a map of id=>style number which allows you to consistenly display styles per user id. By default LITE creates a new style per user as it is introduced.tooltips- set totrue(or omit altogether) to get the default implementation of LITE tooltips, based on Opentip. You can also settooltipsto an object with various configuration options.isTracking- set tofalseto start the plugin's life with change tracking turned off.
- You may also tweak the configuration in your code by listening to the CKEditor
configLoadedevent and then modifying the editor'sconfig.liteobject.
Methods
Get a reference to the lite plugin
To interact with theliteplugin, you need to obtain a reference to the actual plugin object which is unique for each instance of CKEditor. The safest way to do this is by listening to the eventLITE.Events.INITfired by the editor instance. Thedatamember of the event will contain a property calledlitewhich references the lite plugin instance, initialized and ready for action.You can also obtain a reference directly from a fully initialized CKEditor by calling
myEditor.plugins.lite.findPlugin(myEditor).toggleTracking(bTrack, bNotify)
Toggles change tracking in the editor.Parameters
bTrack- boolean. Ifundefined, change tracking is toggled, otherwise it is set to this valuebNotify- boolean. If false, theLITE.Events.TRACKINGevent is not fired.
toggleShow(bShow, bNotify)
Change the visibility of tracked changes. Visible changes are marked by a special style, otherwise insertions appear in their original format and deletions are hidden.Parameters
bShow- boolean. Ifundefined, change visibility is toggled, otherwise it is set to this valuebNotify- boolean. If false, theLITE.Events.SHOW_HIDEevent is not fired.
acceptAll(options)
Accept some or all the pending changes.Parameters
options- optional object filter the changes to which this operation applies with the following properties:excludean array of user ids to exclude from the the operation (takes precedence overinclude)includean array of user ids to include from the the operationfiltera filter function that accepts an object of the form{userid, time, data}and returns aboolean. Only changes for which the filter returnstrueare included in the operation. Thefilteroption can work with bothexcludeandinclude.
optionsblock, including custom ones, are preserved when it is sent back in theACCEPTorREJECTevents (see below).rejectAll(options)
Reject all the pending changes.Parameters
options- optional object to filter the changes to which this operation applies. See theacceptAllmethod for details.
countChanges(options)
Returns a count of the tracked changes in the editor.Parameters
options- optional object to filter the counted changes. See theacceptAllmethod for details.
hasChanges()
Sets the name and id of the current user. Each tracked change is associated with a user id.Parameters
- none
setUserInfo(info)
Sets the name and id of the current user. Each tracked change is associated with a user id.Parameters
info- An object with two members -idandname
setChangeData(data)
Associates an arbitrary string with the changes made from now on. This string is passed to the optionalfilterfunction inoptionsblock passed to various methods that accept change filtering. For example, you may associate a revision number with the current change set and later on filter changes according to their revision.Parameters
data- Arbitrary data (converted to a string by theLITEplugin).
Events
The LITE plugin events are listen inlite-interface.js under LITE.Events. The following events are fired by the LITE plugin instance through its instance of ckeditor, with the parameter in the data member of the event info:
- INIT (parameters: lite, the LITE instance)Fired each time
LITEcreates and initializes an instance of theICEchange tracker. This happens, e.g., when you switch back fromSourcemode toWysiwyg. - ACCEPT(parameter : the
optionsobject passed to acceptAll, if relevant)Fired after some changes (possibly all) were accepted.- REJECT (parameter : the
optionsobject passed to acceptAll, if relevant)Fired after some changes (possibly all) were rejected.- SHOW_HIDE(parameter: show <boolean>)
Fired after a change in the visibility of tracked changes.- TRACKING (parameter: tracking<boolean>)
Fired after a change in the change tracking state. - REJECT (parameter : the