* Feature #6712 corected: htmlArea RTE: correction to DefaultInline plugin and enhanc...
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 15 Nov 2007 01:19:20 +0000 (01:19 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 15 Nov 2007 01:19:20 +0000 (01:19 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2709 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/DefaultInline/default-inline.js

index ba10905..d26071b 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
        * Feature #6712: htmlArea RTE: make hotkeys configurable in PageTSConfig
        * Feature #6712 continued: htmlArea RTE: adding hotkeys to default configuration settings
        * Bugfix: htmlArea RTE: Correction to InlineDefault plugin causing frame reload.
+       * Feature #6712 corected: htmlArea RTE: correction to DefaultInline plugin and enhanced API
 
 2007-11-14  Ingmar Schlecht  <ingmar@typo3.org>
 
index 4083104..864eda7 100644 (file)
@@ -3,6 +3,7 @@
        * Feature #6712: htmlArea RTE: make hotkeys configurable in PageTSConfig
        * Feature #6712 continued: htmlArea RTE: adding hotkeys to default configuration settings
        * Bugfix: htmlArea RTE: Correction to InlineDefault plugin causing frame reload.
+       * Feature #6712 corected: htmlArea RTE: correction to DefaultInline plugin and enhanced API
 
 2007-11-13  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
index 8a1296f..8faef31 100644 (file)
@@ -2362,14 +2362,14 @@ HTMLArea._editorEvent = function(ev) {
                                                                        }
                                                                        break;
                                                                default:
-                                                                       if (editor._toolbarObjects[editor.config.hotKeyList[key]]) {
+                                                                       if (editor._toolbarObjects[editor.config.hotKeyList[key].cmd]) {
                                                                                cmd = editor.config.hotKeyList[key].cmd;
                                                                                if(cmd == "FormatBlock") value = (HTMLArea.is_ie || HTMLArea.is_safari) ? "<p>" : "p";
                                                                        }
                                                        }
                                                }
                                }
-                               if(cmd) {
+                               if(cmd && !editor.config.hotKeyList[key].action) {
                                        editor.execCommand(cmd, false, value);
                                        HTMLArea._stopEvent(ev);
                                        return false;
@@ -3347,7 +3347,8 @@ HTMLArea.plugin = HTMLArea.Base.extend({
                var toolbar = this.editorConfiguration.toolbar;
                var n = toolbar.length;
                for ( var i = 0; i < n; ++i ) {
-                       if (toolbar[i].join(",").indexOf(buttonId) != -1) {
+                       var buttonInToolbar = new RegExp( "^(" + toolbar[i].join("|") + ")$", "i");
+                       if (buttonInToolbar.test(buttonId)) {
                                return true;
                        }
                }
@@ -3379,6 +3380,7 @@ HTMLArea.plugin = HTMLArea.Base.extend({
                                        if (buttonConfiguration.hotKey) {
                                                var hotKeyConfiguration = {
                                                        id      : buttonConfiguration.hotKey,
+                                                       cmd     : buttonConfiguration.id,
                                                        action  : hotKeyAction
                                                };
                                                return this.registerHotKey(hotKeyConfiguration);
@@ -3459,6 +3461,25 @@ HTMLArea.plugin = HTMLArea.Base.extend({
        },
        
        /**
+        * Returns the buttonId corresponding to the hotkey, if any
+        *
+        * @param       string          key: the hotkey
+        *
+        * @return      string          the buttonId or ""
+        */
+       translateHotKey : function(key) {
+               if (typeof(this.editorConfiguration.hotKeyList[key]) !== "undefined") {
+                       var buttonId = this.editorConfiguration.hotKeyList[key].cmd;
+                       if (typeof(buttonId) !== "undefined") {
+                               return buttonId;
+                       } else {
+                               return "";
+                       }
+               }
+               return "";
+       },
+       
+       /**
         * 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.
index 7186320..ada24ea 100644 (file)
@@ -81,7 +81,8 @@ DefaultInline = HTMLArea.plugin.extend({
         */
        onButtonPress : function (editor, id, UI, param) {
                        // Could be a button or its hotkey
-               var buttonId = DefaultInline.hotKeyList[id]?DefaultInline.hotKeyList[id]:id;
+               var buttonId = this.translateHotKey(id);
+               buttonId = buttonId ? buttonId : id;
                editor.focusEditor();
                try {
                        editor._doc.execCommand(buttonId, UI, param);
@@ -102,7 +103,7 @@ DefaultInline = HTMLArea.plugin.extend({
                var buttonId, n = buttonList.length, commandState;
                for (var i = 0; i < n; ++i) {
                        buttonId = buttonList[i][0];
-                       if (typeof(editor._toolbarObjects[buttonId]) !== "undefined") {
+                       if (this.isButtonInToolbar(buttonId)) {
                                commandState = false;
                                if ((editor._editMode != "textmode")) {
                                        try {
@@ -127,11 +128,3 @@ DefaultInline.buttonList = [
        ["Underline", null]
 ];
 
-/* The list of hotkeys handled by this plugin */
-DefaultInline.hotKeyList = {
-       b : "Bold",
-       i : "Italic",
-       s : "StrikeThrough",
-       u : "Underline"
-};
-