Ticket #2910: 2910.patch
File 2910.patch, 18.2 KB (added by , 11 years ago) |
---|
-
_source/core/command.js
7 7 { 8 8 this.state = ( 'state' in commandDefinition ) ? commandDefinition.state : CKEDITOR.TRISTATE_OFF; 9 9 10 this.exec = function( )10 this.exec = function( editor, data ) 11 11 { 12 commandDefinition.exec.call( this, editor);12 return commandDefinition.exec.call( this, editor, data ); 13 13 }; 14 14 15 15 CKEDITOR.tools.extend( this, commandDefinition ); -
_source/core/config.js
147 147 * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea'; 148 148 */ 149 149 150 plugins : 'basicstyles,blockquote,button, elementspath,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,newpage,pagebreak,preview,print,removeformat,smiley,sourcearea,table,specialchar,tab,toolbar,wysiwygarea',150 plugins : 'basicstyles,blockquote,button,clipboard,elementspath,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,newpage,pagebreak,pastetext,preview,print,removeformat,smiley,sourcearea,table,specialchar,tab,toolbar,wysiwygarea', 151 151 152 152 /** 153 153 * The theme to be used to build the UI. -
_source/lang/en.js
31 31 source : 'Source', 32 32 newPage : 'New Page', 33 33 preview : 'Preview', 34 cut : 'Cut', 35 copy : 'Copy', 36 paste : 'Paste', 37 pastetext : 'Paste as plain text', 34 38 print : 'Print', 35 39 underline : 'Underline', 36 40 bold : 'Bold', … … 371 375 title : 'Insert a Smiley' 372 376 }, 373 377 378 clipboard : 379 { 380 title : 'Paste', 381 titlePlain : 'Paste as Plain Text', 382 cutError : 'Your browser security settings don\'t permit the editor to automatically execute cutting operations. Please use the keyboard for that (Ctrl+X).', 383 copyError : 'Your browser security settings don\'t permit the editor to automatically execute copying operations. Please use the keyboard for that (Ctrl+C).', 384 pasteMsg : 'Please paste inside the following box using the keyboard (Ctrl+V) and hit OK', 385 securityMsg : 'Because of your browser security settings, the editor is not able to access your clipboard data directly. You are required to paste it again in this window.' 386 }, 387 374 388 elementsPath : 375 389 { 376 390 eleTitle : '%1 element' -
_source/plugins/clipboard/dialogs/paste.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 (function() 7 { 8 var pasteDialog = function( editor, type ) 9 { 10 var isCustomDomain = CKEDITOR.env.ie && document.domain != window.location.hostname, 11 pasteArea, 12 securityMsg = '', 13 height = 170; 14 15 if ( type == 'pasteText' ) 16 pasteArea = CKEDITOR.dom.element.createFromHtml( '<textarea cols=80 rows=13 id="frmData" ></textarea>' ); 17 else 18 { 19 pasteArea = CKEDITOR.dom.element.createFromHtml( '<iframe src="javascript:void(0)" id="frmData" frameborder="0" allowtransparency="1"></iframe>' ); 20 var htmlToLoad = '<!doctype html><script type="text/javascript">' 21 + 'window.onload = function()' 22 + '{' 23 + 'if ( ' + CKEDITOR.env.ie + ' ) ' 24 + 'document.body.contentEditable = "true";' 25 + 'else ' 26 + 'document.designMode = "on";' 27 + 'window.focus();' 28 + '};' 29 + '</script><style>body { margin: 3px; } </style><body></body>'; 30 31 // For document.domain compatibility (#123) we must do all the magic in 32 // the URL for IE. 33 if ( isCustomDomain ) 34 { 35 pasteArea.setAttribute( 'src', 'javascript:void( (function(){' + 36 'document.open();' + 37 'document.domain=\'' + document.domain + '\';' + 38 'document.write( window.parent.CKEDITOR._cke_htmlToLoad );' + 39 'document.close();' + 40 'document.body.contentEditable = true;' + 41 'delete window.parent.CKEDITOR._cke_htmlToLoad;' + 42 'window.focus();' + 43 '})() )' 44 ); 45 } 46 47 height = 130; 48 securityMsg = '<div style="white-space:normal;width:340px;">'+editor.lang.clipboard.securityMsg +'</div>'; 49 } 50 pasteArea.setStyles( 51 { 52 width : '346px', 53 resize : 'none', // Turn off resize in Chrome and Safari 54 'background-color' : 'white', 55 height : height + 'px', 56 border : '1px solid black' 57 }); 58 59 return { 60 title : ( type == 'pasteText' ) ? editor.lang.clipboard.titlePlain : editor.lang.clipboard.title, 61 minWidth : 400, 62 minHeight : 330, 63 onLoad : function() 64 { 65 var container = this.getContentElement( 'general', 'content' ).getElement(); 66 container.setHtml( '' ); 67 container.append( pasteArea ); 68 }, 69 onShow : function() 70 { 71 if ( type != 'pasteText' ) 72 { 73 if ( isCustomDomain ) 74 CKEDITOR._cke_htmlToLoad = htmlToLoad; 75 else 76 { 77 // Avoid errors if the pasted content has any script that fails: #389 78 var oDoc = pasteArea.$.contentWindow.document; 79 oDoc.open(); 80 oDoc.write( htmlToLoad ); 81 oDoc.close(); 82 83 if ( CKEDITOR.env.ie ) 84 oDoc.body.contentEditable = true; 85 else 86 oDoc.designMode = 'on'; 87 88 pasteArea.$.contentWindow.focus(); 89 } 90 } 91 else 92 { 93 pasteArea.setValue( '' ); 94 pasteArea.focus(); 95 } 96 }, 97 onOk : function() 98 { 99 var editor = this.getParentEditor(), 100 html, 101 input = CKEDITOR.document.getById( 'frmData' ); 102 103 if ( type != 'pasteText' ) 104 { 105 if ( input.$.contentDocument ) 106 oBody = input.$.contentDocument.body; 107 else 108 oBody = input.$.contentWindow.document.body; 109 html = oBody.innerHTML; 110 111 // Fix relative anchor URLs (IE automatically adds the current page URL). 112 var re = new RegExp( window.location + "#", "g" ); 113 html = html.replace( re, '#'); 114 } 115 else 116 html = input.getValue(); 117 118 this.restoreSelection(); 119 this.clearSavedSelection(); 120 121 var data = { from : 'pasteDialog', type : type, content : html }; 122 data = editor.fire( 'dialogPaste', data ) 123 if ( data !== false ) 124 editor.insertHtml( data.content ); 125 }, 126 contents : [ 127 { 128 id : 'general', 129 label : editor.lang.common.generalTab, 130 elements : [ 131 { 132 type : 'html', 133 id : 'securityMsg', 134 html : securityMsg 135 }, 136 { 137 type : 'html', 138 id : 'pasteMsg', 139 html : '<div style="white-space:normal;width:340px;">'+editor.lang.clipboard.pasteMsg +'</div>' 140 }, 141 { 142 type : 'html', 143 id : 'content', 144 style : 'width:340px;height:' + height + 'px', 145 html : '<div></div>' 146 } 147 ] 148 } 149 ] 150 }; 151 }; 152 153 CKEDITOR.dialog.add( 'pasteDialog', function( editor ) 154 { 155 return pasteDialog( editor, 'paste' ) 156 } 157 ); 158 CKEDITOR.dialog.add( 'pastetext', function( editor ) 159 { 160 return pasteDialog( editor, 'pasteText' ) 161 } 162 ); 163 })(); -
_source/plugins/clipboard/plugin.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 /** 7 * @file Clipboard support 8 */ 9 10 (function() 11 { 12 // Cut and Copy command. 13 tryToCutCopy = ( CKEDITOR.env.ie ) ? 14 function( editor, type, data ) 15 { 16 var enabled = null, 17 eventName = 'on' + type.toLowerCase(); // Event name: onCut or onCopy. 18 var onEvent = function() 19 { 20 enabled = true; 21 }; 22 23 // The following seems to be the only reliable way to detect that 24 // cut/copy is enabled in IE. It will fire the oncut/oncopy event 25 // only if the security settings enabled the command to execute. 26 editor.document.getBody().$.attachEvent( eventName, onEvent ); 27 editor.document.$.execCommand( type ); 28 editor.document.getBody().$.detachEvent( eventName, onEvent ); 29 30 if ( enabled ) 31 return editor.fire( 'on' + type, data ); // Fire onCut or onCopy. 32 33 return null; 34 } 35 : // !IE. 36 function( editor, type, data ) 37 { 38 try 39 { 40 // Other browsers throw an error if the command is disabled. 41 editor.document.$.execCommand( type ); 42 return editor.fire( 'on' + type, data ); // Fire onCut or onCopy. 43 } 44 catch( e ) 45 { 46 return null; 47 } 48 }; 49 50 var cutCopy = function ( type ) 51 { 52 this.type = type ? 'cut': 'copy'; 53 54 this.exec = function( editor, data ) 55 { 56 if ( !data ) 57 data = { from : 'clipboardHandler', type : this.type }; 58 59 if ( editor.fire( 'before' + this.type, data ) == false ) // Fire beforeCut or beforeCopy. 60 return ( data.from == 'keystrokeHandler' ); // Error - return true if it was from keystrokeHandler to stop the propagation, 61 62 if ( data.from == 'keystrokeHandler' ) 63 return !editor.fire( 'on' + this.type, data ); // Fire onCut or onCopy. False from fire() stops the event. 64 65 var res = tryToCutCopy( editor, this.type, data ); 66 if ( res == null ) 67 alert( editor.lang.clipboard[ this.type + 'Error' ] ); // Show cutError or copyError. 68 69 return res; 70 }; 71 }; 72 73 // Paste command: 74 var paste = function () 75 { 76 if ( CKEDITOR.env.ie ) 77 { 78 return { 79 // Possible only in IE 80 getClipboardData : function( editor ) 81 { 82 var enabled = false; 83 var onEvent = function() 84 { 85 enabled = true; 86 }; 87 88 // The following seams to be the only reliable way to check is script 89 // pasting operations are enabled in the security settings of IE6 and IE7. 90 // It adds a little bit of overhead to the check, but so far that's the 91 // only way, mainly because of IE7. 92 document.body.attachEvent( 'onpaste', onEvent ); 93 94 var oDiv = CKEDITOR.document.getById( '_cke_hiddenDiv' ), 95 oTextRange = document.body.createTextRange(); 96 97 if ( !oDiv ) 98 { 99 oDiv = new CKEDITOR.dom.element( 'div' ); 100 oDiv.$.id = '_cke_hiddenDiv'; 101 var oDivStyle = oDiv.$.style; 102 oDivStyle.position = 'absolute'; 103 oDivStyle.visibility = oDivStyle.overflow = 'hidden'; 104 oDivStyle.width = oDivStyle.height = '1px'; 105 106 oDiv.appendTo( editor.element.getParent() ); 107 } 108 109 oDiv.setHtml( '' ); 110 oTextRange.moveToElementText( oDiv.$ ); 111 112 // The execCommand in will fire the "onpaste", only if the 113 // security settings are enabled. 114 oTextRange.execCommand( 'Paste' ); 115 var html = oDiv.getHtml(); 116 oDiv.setHtml( '' ); 117 118 document.body.detachEvent( 'onpaste', onEvent ); 119 120 return enabled ? html : false; 121 }, 122 exec : function( editor, data ) 123 { 124 var sHTML = this.getClipboardData( editor ); 125 if ( sHTML === false ) 126 { 127 data = { from : 'clipboardHandler', content : '' }; // Clipboard content in data.content. 128 if ( editor.fire( 'paste', data ) !== false ) // False = don't show the Paste dialog. 129 editor.getCommand( 'pasteDialog' ).exec( editor ); 130 } 131 else 132 { 133 data = { from : 'clipboardHandler', content : sHTML }; // Clipboard content in data.content. 134 if ( editor.fire( 'paste', data ) === false ) // False = don't paste. 135 return true; 136 137 // Instead of inserting the retrieved HTML, let's leave the OS work for us, 138 // by calling editor.ExecuteNamedCommand( 'Paste' ). It could give better results. 139 editor.focus(); // Prevent IE from pasting at the begining of the document. 140 editor.document.$.execCommand( 'Paste' ); 141 } 142 return true; // Return true to stop the propagation. 143 } 144 }; 145 } 146 147 // Not IE. 148 return { 149 exec : function( editor, data ) 150 { 151 if ( data && data.from == 'keystrokeHandler' ) 152 return !editor.fire( 'paste', data ); // true stops the propagation. 153 154 if ( !data ) 155 data = { from : 'clipboardHandler', content : '' }; // Sometimes we can't preview the clipboard content. 156 try 157 { 158 if ( CKEDITOR.env.webkit ) // Force the paste dialog for Safari and Chrome (#50). 159 throw ''; 160 161 if ( editor.fire( 'paste', data ) ) 162 editor.document.$.execCommand( 'Paste', null, true ); 163 } 164 catch (e) 165 { 166 // Open the Paste dialog 167 editor.getCommand( 'pasteDialog' ).exec( editor ); 168 } 169 } 170 }; 171 }; 172 173 // Register a plugin named "clipboard". 174 CKEDITOR.plugins.add( 'clipboard', 175 { 176 init : function( editor, pluginPath ) 177 { 178 addButtonCommand = function ( buttonName, commandName, command ) 179 { 180 editor.addCommand( commandName, command ); 181 editor.ui.addButton( buttonName, 182 { 183 label : editor.lang[ commandName ], 184 command : commandName 185 }); 186 } 187 addButtonCommand( 'Cut', 'cut', new cutCopy( true ) ); 188 addButtonCommand( 'Copy', 'copy', new cutCopy( false ) ); 189 addButtonCommand( 'Paste', 'paste', paste() ); 190 191 CKEDITOR.dialog.add( 'pasteDialog', this.path + 'dialogs/paste.js' ); 192 editor.addCommand( 'pasteDialog', new CKEDITOR.dialogCommand( 'pasteDialog' ) ); 193 } 194 }); 195 })(); -
_source/plugins/keystrokes/plugin.js
88 88 if ( !cancel ) 89 89 { 90 90 if ( command ) 91 cancel = ( this._.editor.execCommand( command ) !== false ); 91 { 92 var data = { from : 'keystrokeHandler' }; 93 cancel = ( this._.editor.execCommand( command, data ) !== false ); 94 } 92 95 93 96 if ( !cancel ) 94 97 cancel = !!this.blockedKeystrokes[ keyCombination ]; -
_source/plugins/pastetext/plugin.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 /** 7 * @file Paste as plain text plugin 8 */ 9 10 // Register a plugin named "pastetext". 11 CKEDITOR.plugins.add( 'pastetext', 12 { 13 init : function( editor, pluginPath ) 14 { 15 var commandName = 'pastetext'; 16 17 editor.addCommand( commandName, new CKEDITOR.dialogCommand( commandName ) ); 18 editor.ui.addButton( 'PasteText', 19 { 20 label : editor.lang[ commandName ], 21 command : commandName 22 }); 23 CKEDITOR.dialog.add( commandName, CKEDITOR.plugins.getPath( 'clipboard' ) + 'dialogs/paste.js' ); 24 25 // Event fired in onOk in the Paste dialog. 26 editor.on( 'dialogPaste', function( event ) 27 { 28 var editor = event.editor; 29 // If forcePasteAsPlainText or from 'Paste as Plain text' dialog, 30 if ( event.data && event.data.content && ( editor.config.forcePasteAsPlainText || event.data.type == 'pasteText' ) ) 31 event.data.content = CKEDITOR.plugins.pasteText.getPlain( event.data.content ); 32 }); 33 34 if ( editor.config.forcePasteAsPlainText ) 35 { 36 editor.on( 'paste', function( event ) 37 { 38 var editor = event.editor, 39 text = ( event.data && event.data.content != '' ) ? event.data.content : ''; 40 text = ( window.clipboardData ) ? clipboardData.getData( "Text" ) : text; 41 42 // Try to clean up. 43 if ( text != '' ) 44 editor.insertHtml( CKEDITOR.plugins.pasteText.getPlain( text ) ); 45 else 46 { 47 // Open the Paste dialog. 48 CKEDITOR.tools.setTimeout( 49 function( editor ) 50 { 51 editor.getCommand( 'pastetext' ).exec( editor ); 52 }, 53 1, this, editor ); 54 } 55 event.data = false; // False = stop proceeding in the clipboard handler. 56 event.stop(); 57 }); 58 } 59 }, 60 requires : [ 'clipboard' ] 61 }); 62 63 CKEDITOR.plugins.pasteText = 64 { 65 getPlain : function ( text ) 66 { 67 text = CKEDITOR.tools.htmlEncode( text ); 68 var closeTagIndex = text.search( '</p>' ), 69 startTagIndex = text.search( '<p>' ); 70 if ( ( closeTagIndex != -1 && startTagIndex != -1 && closeTagIndex < startTagIndex ) 71 || ( closeTagIndex != -1 && startTagIndex == -1 ) ) 72 { 73 var prefix = text.substr( 0, closeTagIndex ); 74 text = text.substr( closeTagIndex + 4 ); 75 } 76 return text; 77 } 78 } 79 80 CKEDITOR.config.forcePasteAsPlainText = false; -
_source/plugins/toolbar/plugin.js
208 208 [ 209 209 'Source', '-', 210 210 'NewPage', 'Preview', 'Print', '-', 211 'Cut', 'Copy', 'Paste', 'PasteText', '-', 211 212 'Bold', 'Italic', 'Underline', 'Strike', '-', 212 213 'NumberedList', 'BulletedList', '-', 213 214 'Outdent', 'Indent', 'Blockquote', '-', -
_source/skins/default/toolbar.css
156 156 background-position: 0 -64px; 157 157 } 158 158 159 .cke_skin_default a.cke_button_cut .cke_icon 160 { 161 background-position: 0 -96px; 162 } 163 164 .cke_skin_default a.cke_button_copy .cke_icon 165 { 166 background-position: 0 -112px; 167 } 168 169 .cke_skin_default a.cke_button_paste .cke_icon 170 { 171 background-position: 0 -128px; 172 } 173 174 .cke_skin_default a.cke_button_pastetext .cke_icon 175 { 176 background-position: 0 -144px; 177 } 178 159 179 .cke_skin_default a.cke_button_find .cke_icon 160 180 { 161 181 background-position: 0 -240px;