mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4968 201d5d3c-b55e-5fd7-737f-ddc643e51545
102 lines
No EOL
2.7 KiB
JavaScript
102 lines
No EOL
2.7 KiB
JavaScript
/**
|
|
* @namespace
|
|
*/
|
|
xq.plugin = {};
|
|
|
|
/**
|
|
* @requires Xquared.js
|
|
*/
|
|
xq.plugin.Base = xq.Class(/** @lends xq.plugin.Base.prototype */{
|
|
/**
|
|
* Abstract base class for Xquared plugins.
|
|
*
|
|
* @constructs
|
|
*/
|
|
initialize: function() {},
|
|
|
|
/**
|
|
* Loads plugin. Automatically called by xq.Editor.
|
|
*
|
|
* @param {xq.Editor} editor Editor instance.
|
|
*/
|
|
load: function(editor) {
|
|
this.editor = editor;
|
|
if(this.isEventListener()) this.editor.addListener(this);
|
|
|
|
this.onBeforeLoad(this.editor);
|
|
this.editor.addShortcuts(this.getShortcuts() || []);
|
|
this.editor.addAutocorrections(this.getAutocorrections() || []);
|
|
this.editor.addAutocompletions(this.getAutocompletions() || []);
|
|
this.editor.addTemplateProcessors(this.getTemplateProcessors() || []);
|
|
this.editor.addContextMenuHandlers(this.getContextMenuHandlers() || []);
|
|
this.onAfterLoad(this.editor);
|
|
},
|
|
|
|
/**
|
|
* Unloads plugin. Automatically called by xq.Editor
|
|
*/
|
|
unload: function() {
|
|
this.onBeforeUnload(this.editor);
|
|
for(var key in this.getShortcuts()) this.editor.removeShortcut(key);
|
|
for(var key in this.getAutocorrections()) this.editor.removeAutocorrection(key);
|
|
for(var key in this.getAutocompletions()) this.editor.removeAutocompletion(key);
|
|
for(var key in this.getTemplateProcessors()) this.editor.removeTemplateProcessor(key);
|
|
for(var key in this.getContextMenuHandlers()) this.editor.removeContextMenuHandler(key);
|
|
this.onAfterUnload(this.editor);
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
* Always returns false.<br />
|
|
* <br />
|
|
* Derived class may override this to make a plugin as a event listener.<br />
|
|
* Whenever you override this function, you should also implement at least one event handler for xq.Editor.
|
|
*/
|
|
isEventListener: function() {return false},
|
|
|
|
/**
|
|
* Callback function. Derived class may override this.
|
|
*/
|
|
onBeforeLoad: function(editor) {},
|
|
|
|
/**
|
|
* Callback function. Derived class may override this.
|
|
*/
|
|
onAfterLoad: function(editor) {},
|
|
|
|
/**
|
|
* Callback function. Derived class may override this.
|
|
*/
|
|
onBeforeUnload: function(editor) {},
|
|
|
|
/**
|
|
* Callback function. Derived class may override this.
|
|
*/
|
|
onAfterUnload: function(editor) {},
|
|
|
|
/**
|
|
* Callback function. Derived class may override this.
|
|
*/
|
|
getShortcuts: function() {return [];},
|
|
|
|
/**
|
|
* Callback function. Derived class may override this.
|
|
*/
|
|
getAutocorrections: function() {return [];},
|
|
|
|
/**
|
|
* Callback function. Derived class may override this.
|
|
*/
|
|
getAutocompletions: function() {return [];},
|
|
|
|
/**
|
|
* Callback function. Derived class may override this.
|
|
*/
|
|
getTemplateProcessors: function() {return [];},
|
|
|
|
/**
|
|
* Callback function. Derived class may override this.
|
|
*/
|
|
getContextMenuHandlers: function() {return [];}
|
|
}); |