Project

General

Profile

Feature #17714 » rtehtmlarea_feature_6579_hotkey.patch

Administrator Admin, 2007-11-14 04:08

View differences:

typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js (working copy)
};
// Default hotkeys
this.hotKeyList = {
a: "SelectAll",
l: "JustifyLeft",
e: "JustifyCenter",
r: "JustifyRight",
j: "JustifyFull",
n: "FormatBlock",
v: "Paste",
0: "CleanWord",
z: "Undo",
y: "Redo"
a: { cmd: "SelectAll", action: null},
l: { cmd: "JustifyLeft", action: null},
e: { cmd: "JustifyCenter", action: null},
r: { cmd: "JustifyRight", action: null},
j: { cmd: "JustifyFull", action: null},
n: { cmd: "FormatBlock", action: null},
v: { cmd: "Paste", action: null},
0: { cmd: "CleanWord", action: null},
z: { cmd: "Undo", action: null},
y: { cmd: "Redo", action: null}
};
// Initialize tooltips from the I18N module, generate correct image path
......
*/
HTMLArea.Config.prototype.registerDropdown = function(dropDownConfiguration) {
if (typeof(this.customSelects[dropDownConfiguration.id]) != "undefined") {
HTMLArea._appendToLog("WARNING [HTMLArea.Config::registerDropdown]: A dropdown with the same ID " + dropDownConfiguration.id + " already exists.");
HTMLArea._appendToLog("ERROR [HTMLArea.Config::registerDropdown]: A dropdown with the same ID " + dropDownConfiguration.id + " already exists.");
return false;
}
if (typeof(this.btnList[dropDownConfiguration.id]) != "undefined") {
HTMLArea._appendToLog("WARNING [HTMLArea.Config::registerDropdown]: A button with the same ID " + dropDownConfiguration.id + " already exists.");
HTMLArea._appendToLog("ERROR [HTMLArea.Config::registerDropdown]: A button with the same ID " + dropDownConfiguration.id + " already exists.");
return false;
}
this.customSelects[dropDownConfiguration.id] = dropDownConfiguration;
return true;
};
/*
* Register a hotkey with the editor configuration.
*/
HTMLArea.Config.prototype.registerHotKey = function(hotKeyConfiguration) {
if (typeof(this.hotKeyList[hotKeyConfiguration.id]) != "undefined") {
HTMLArea._appendToLog("ERROR [HTMLArea.Config::registerHotKey]: A hotkey with the same key " + hotKeyConfiguration.id + " already exists.");
return false;
}
this.hotKeyList[hotKeyConfiguration.id] = hotKeyConfiguration;
return true;
};
/***************************************************
* EDITOR FRAMEWORK
***************************************************/
......
return false;
// other hotkeys
default:
if (editor.config.hotKeyList[key]) {
switch (editor.config.hotKeyList[key]) {
if (editor.config.hotKeyList[key] && editor.config.hotKeyList[key].cmd) {
switch (editor.config.hotKeyList[key].cmd) {
case "SelectAll":
case "CleanWord":
cmd = editor.config.hotKeyList[key];
cmd = editor.config.hotKeyList[key].cmd;
break;
case "Paste":
if (HTMLArea.is_ie || HTMLArea.is_safari) {
cmd = editor.config.hotKeyList[key];
cmd = editor.config.hotKeyList[key].cmd;
} else if (editor.config.cleanWordOnPaste) {
window.setTimeout("HTMLArea.wordCleanLater(" + owner._editorNo + ", false);", 50);
}
break;
default:
if (editor._toolbarObjects[editor.config.hotKeyList[key]]) {
cmd = editor.config.hotKeyList[key];
cmd = editor.config.hotKeyList[key].cmd;
if(cmd == "FormatBlock") value = (HTMLArea.is_ie || HTMLArea.is_safari) ? "<p>" : "p";
}
}
......
HTMLArea._stopEvent(ev);
return false;
} else {
for (var pluginId in editor.plugins) {
if (editor.plugins.hasOwnProperty(pluginId)) {
var pluginInstance = editor.plugins[pluginId].instance;
if (typeof(pluginInstance.onHotKey) === "function") {
if (!pluginInstance.onHotKey(key)) {
HTMLArea._stopEvent(ev);
return false;
}
}
if (editor.config.hotKeyList[key] && editor.config.hotKeyList[key].action) {
if (!editor.config.hotKeyList[key].action(editor, key)) {
HTMLArea._stopEvent(ev);
return false;
}
}
editor.updateToolbar();
......
},
/**
* Registors a hotkey
*
* @param object hotKeyConfiguration: the configuration object of the hotkey:
* id : the key
* action : name of the function invoked when a hotkey is pressed
*
* @return boolean true if the hotkey was successfully registered
*/
registerHotKey : function (hotKeyConfiguration) {
if (typeof((hotKeyConfiguration.action) === "string") && (typeof(this[hotKeyConfiguration.action]) === "function")) {
var actionFunctionReference = this.makeFunctionReference(hotKeyConfiguration.action);
hotKeyConfiguration.action = actionFunctionReference;
return this.editorConfiguration.registerHotKey(hotKeyConfiguration);
} else {
this.appendToLog("registerHotKey", "Function " + hotKeyConfiguration.action + " was not defined when registering hotkey " + hotKeyConfiguration.id);
}
},
/**
* The toolbar refresh handler of the plugin
* This function may be defined by the plugin subclass.
* If defined, the function will be invoked whenever the toolbar state is refreshed.
typo3/sysext/rtehtmlarea/htmlarea/plugins/DefaultInline/default-inline.js (working copy)
*/
configurePlugin : function (editor) {
/* Registering plugin "About" information */
/*
* Registering plugin "About" information
*/
var pluginInformation = {
version : "1.0",
developer : "Stanislas Rolland",
......
};
this.registerPluginInformation(pluginInformation);
/* Registering the buttons */
/*
* Registering the buttons
*/
var buttonList = DefaultInline.buttonList;
var n = buttonList.length;
for (var i = 0; i < n; ++i) {
......
};
this.registerButton(buttonConfiguration);
}
/*
* Registering the hotkeys
*/
for (var hotKey in DefaultInline.hotKeyList) {
if (DefaultInline.hotKeyList.hasOwnProperty(hotKey)) {
var hotKeyConfiguration = {
id : hotKey,
action : "onHotKey"
};
this.registerHotKey(hotKeyConfiguration);
}
}
return true;
},
......
/*
* This function gets called when some hot key is pressed
*/
onHotKey : function(key) {
onHotKey : function(editor, key) {
if (DefaultInline.hotKeyList[key] && this.editor._toolbarObjects[DefaultInline.hotKeyList[key]]) {
return this.onButtonPress(this.editor, DefaultInline.hotKeyList[key]);
var toolbarObject = this.editor._toolbarObjects[DefaultInline.hotKeyList[key]];
var toolbarHTMLObject = document.getElementById(toolbarObject.elementId);
if (!toolbarHTMLObject.disabled) {
return this.onButtonPress(this.editor, DefaultInline.hotKeyList[key]);
}
} else {
return true;
}
(6-6/6)