+++ /dev/null
-/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-// Register a plugin named "sample".\r
-CKEDITOR.plugins.add( 'keystrokes',\r
-{\r
- beforeInit : function( editor )\r
- {\r
- /**\r
- * Controls keystrokes typing in this editor instance.\r
- * @name CKEDITOR.editor.prototype.keystrokeHandler\r
- * @type CKEDITOR.keystrokeHandler\r
- * @example\r
- */\r
- editor.keystrokeHandler = new CKEDITOR.keystrokeHandler( editor );\r
-\r
- editor.specialKeys = {};\r
- },\r
-\r
- init : function( editor )\r
- {\r
- var keystrokesConfig = editor.config.keystrokes,\r
- blockedConfig = editor.config.blockedKeystrokes;\r
-\r
- var keystrokes = editor.keystrokeHandler.keystrokes,\r
- blockedKeystrokes = editor.keystrokeHandler.blockedKeystrokes;\r
-\r
- for ( var i = 0 ; i < keystrokesConfig.length ; i++ )\r
- keystrokes[ keystrokesConfig[i][0] ] = keystrokesConfig[i][1];\r
-\r
- for ( i = 0 ; i < blockedConfig.length ; i++ )\r
- blockedKeystrokes[ blockedConfig[i] ] = 1;\r
- }\r
-});\r
-\r
-/**\r
- * Controls keystrokes typing in an editor instance.\r
- * @constructor\r
- * @param {CKEDITOR.editor} editor The editor instance.\r
- * @example\r
- */\r
-CKEDITOR.keystrokeHandler = function( editor )\r
-{\r
- if ( editor.keystrokeHandler )\r
- return editor.keystrokeHandler;\r
-\r
- /**\r
- * List of keystrokes associated to commands. Each entry points to the\r
- * command to be executed.\r
- * @type Object\r
- * @example\r
- */\r
- this.keystrokes = {};\r
-\r
- /**\r
- * List of keystrokes that should be blocked if not defined at\r
- * {@link keystrokes}. In this way it is possible to block the default\r
- * browser behavior for those keystrokes.\r
- * @type Object\r
- * @example\r
- */\r
- this.blockedKeystrokes = {};\r
-\r
- this._ =\r
- {\r
- editor : editor\r
- };\r
-\r
- return this;\r
-};\r
-\r
-(function()\r
-{\r
- var cancel;\r
-\r
- var onKeyDown = function( event )\r
- {\r
- // The DOM event object is passed by the "data" property.\r
- event = event.data;\r
-\r
- var keyCombination = event.getKeystroke();\r
- var command = this.keystrokes[ keyCombination ];\r
- var editor = this._.editor;\r
-\r
- cancel = ( editor.fire( 'key', { keyCode : keyCombination } ) === true );\r
-\r
- if ( !cancel )\r
- {\r
- if ( command )\r
- {\r
- var data = { from : 'keystrokeHandler' };\r
- cancel = ( editor.execCommand( command, data ) !== false );\r
- }\r
-\r
- if ( !cancel )\r
- {\r
- var handler = editor.specialKeys[ keyCombination ];\r
- cancel = ( handler && handler( editor ) === true );\r
-\r
- if ( !cancel )\r
- cancel = !!this.blockedKeystrokes[ keyCombination ];\r
- }\r
- }\r
-\r
- if ( cancel )\r
- event.preventDefault( true );\r
-\r
- return !cancel;\r
- };\r
-\r
- var onKeyPress = function( event )\r
- {\r
- if ( cancel )\r
- {\r
- cancel = false;\r
- event.data.preventDefault( true );\r
- }\r
- };\r
-\r
- CKEDITOR.keystrokeHandler.prototype =\r
- {\r
- /**\r
- * Attaches this keystroke handle to a DOM object. Keystrokes typed\r
- ** over this object will get handled by this keystrokeHandler.\r
- * @param {CKEDITOR.dom.domObject} domObject The DOM object to attach\r
- * to.\r
- * @example\r
- */\r
- attach : function( domObject )\r
- {\r
- // For most browsers, it is enough to listen to the keydown event\r
- // only.\r
- domObject.on( 'keydown', onKeyDown, this );\r
-\r
- // Some browsers instead, don't cancel key events in the keydown, but in the\r
- // keypress. So we must do a longer trip in those cases.\r
- if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )\r
- domObject.on( 'keypress', onKeyPress, this );\r
- }\r
- };\r
-})();\r
-\r
-/**\r
- * A list of keystrokes to be blocked if not defined in the {@link CKEDITOR.config.keystrokes}\r
- * setting. In this way it is possible to block the default browser behavior\r
- * for those keystrokes.\r
- * @type Array\r
- * @default (see example)\r
- * @example\r
- * // This is actually the default value.\r
- * config.blockedKeystrokes =\r
- * [\r
- * CKEDITOR.CTRL + 66 /*B*/,\r
- * CKEDITOR.CTRL + 73 /*I*/,\r
- * CKEDITOR.CTRL + 85 /*U*/\r
- * ];\r
- */\r
-CKEDITOR.config.blockedKeystrokes =\r
-[\r
- CKEDITOR.CTRL + 66 /*B*/,\r
- CKEDITOR.CTRL + 73 /*I*/,\r
- CKEDITOR.CTRL + 85 /*U*/\r
-];\r
-\r
-/**\r
- * A list associating keystrokes to editor commands. Each element in the list\r
- * is an array where the first item is the keystroke, and the second is the\r
- * name of the command to be executed.\r
- * @type Array\r
- * @default (see example)\r
- * @example\r
- * // This is actually the default value.\r
- * config.keystrokes =\r
- * [\r
- * [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ],\r
- * [ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ],\r
- *\r
- * [ CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ],\r
- *\r
- * [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ],\r
- * [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ],\r
- * [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ],\r
- *\r
- * [ CKEDITOR.CTRL + 76 /*L*/, 'link' ],\r
- *\r
- * [ CKEDITOR.CTRL + 66 /*B*/, 'bold' ],\r
- * [ CKEDITOR.CTRL + 73 /*I*/, 'italic' ],\r
- * [ CKEDITOR.CTRL + 85 /*U*/, 'underline' ],\r
- *\r
- * [ CKEDITOR.ALT + 109 /*-*/, 'toolbarCollapse' ]\r
- * ];\r
- */\r
-CKEDITOR.config.keystrokes =\r
-[\r
- [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ],\r
- [ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ],\r
-\r
- [ CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ],\r
- [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ],\r
-\r
- [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ],\r
- [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ],\r
- [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ],\r
-\r
- [ CKEDITOR.CTRL + 76 /*L*/, 'link' ],\r
-\r
- [ CKEDITOR.CTRL + 66 /*B*/, 'bold' ],\r
- [ CKEDITOR.CTRL + 73 /*I*/, 'italic' ],\r
- [ CKEDITOR.CTRL + 85 /*U*/, 'underline' ],\r
-\r
- [ CKEDITOR.ALT + ( CKEDITOR.env.ie || CKEDITOR.env.webkit ? 189 : 109 ) /*-*/, 'toolbarCollapse' ],\r
- [ CKEDITOR.ALT + 48 /*0*/, 'a11yHelp' ]\r
-];\r
-\r
-/**\r
- * Fired when any keyboard key (or combination) is pressed into the editing area.\r
- * @name CKEDITOR.editor#key\r
- * @event\r
- * @param {Number} data.keyCode A number representing the key code (or\r
- * combination). It is the sum of the current key code and the\r
- * {@link CKEDITOR.CTRL}, {@link CKEDITOR.SHIFT} and {@link CKEDITOR.ALT}\r
- * constants, if those are pressed.\r
- */\r