Mimimum syndical pour en faire un produit zope / cmf.
[ckeditor.git] / skins / ckeditor / _source / plugins / clipboard / dialogs / paste.js
diff --git a/skins/ckeditor/_source/plugins/clipboard/dialogs/paste.js b/skins/ckeditor/_source/plugins/clipboard/dialogs/paste.js
new file mode 100644 (file)
index 0000000..9a659ed
--- /dev/null
@@ -0,0 +1,223 @@
+/*\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
+CKEDITOR.dialog.add( 'paste', function( editor )\r
+{\r
+       var lang = editor.lang.clipboard;\r
+       var isCustomDomain = CKEDITOR.env.isCustomDomain();\r
+\r
+       function onPasteFrameLoad( win )\r
+       {\r
+               var doc = new CKEDITOR.dom.document( win.document ),\r
+                       docElement = doc.$;\r
+\r
+               var script = doc.getById( 'cke_actscrpt' );\r
+               script && script.remove();\r
+\r
+               CKEDITOR.env.ie ?\r
+                       docElement.body.contentEditable = "true" :\r
+                       docElement.designMode = "on";\r
+\r
+               // IE before version 8 will leave cursor blinking inside the document after\r
+               // editor blurred unless we clean up the selection. (#4716)\r
+               if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 )\r
+               {\r
+                       doc.getWindow().on( 'blur', function()\r
+                       {\r
+                               docElement.selection.empty();\r
+                       } );\r
+               }\r
+\r
+               doc.on( "keydown", function( e )\r
+               {\r
+                       var domEvent = e.data,\r
+                               key = domEvent.getKeystroke(),\r
+                               processed;\r
+\r
+                       switch( key )\r
+                       {\r
+                               case 27 :\r
+                                       this.hide();\r
+                                       processed = 1;\r
+                                       break;\r
+\r
+                               case 9 :\r
+                               case CKEDITOR.SHIFT + 9 :\r
+                                       this.changeFocus( true );\r
+                                       processed = 1;\r
+                       }\r
+\r
+                       processed && domEvent.preventDefault();\r
+               }, this );\r
+\r
+               editor.fire( 'ariaWidget', new CKEDITOR.dom.element( win.frameElement ) );\r
+       }\r
+\r
+       return {\r
+               title : lang.title,\r
+\r
+               minWidth : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 370 : 350,\r
+               minHeight : CKEDITOR.env.quirks ? 250 : 245,\r
+               onShow : function()\r
+               {\r
+                       // FIREFOX BUG: Force the browser to render the dialog to make the to-be-\r
+                       // inserted iframe editable. (#3366)\r
+                       this.parts.dialog.$.offsetHeight;\r
+\r
+                       this.setupContent();\r
+               },\r
+\r
+               onHide : function()\r
+               {\r
+                       if ( CKEDITOR.env.ie )\r
+                               this.getParentEditor().document.getBody().$.contentEditable = 'true';\r
+               },\r
+\r
+               onLoad : function()\r
+               {\r
+                       if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) && editor.lang.dir == 'rtl' )\r
+                               this.parts.contents.setStyle( 'overflow', 'hidden' );\r
+               },\r
+\r
+               onOk : function()\r
+               {\r
+                       this.commitContent();\r
+               },\r
+\r
+               contents : [\r
+                       {\r
+                               id : 'general',\r
+                               label : editor.lang.common.generalTab,\r
+                               elements : [\r
+                                       {\r
+                                               type : 'html',\r
+                                               id : 'securityMsg',\r
+                                               html : '<div style="white-space:normal;width:340px;">' + lang.securityMsg + '</div>'\r
+                                       },\r
+                                       {\r
+                                               type : 'html',\r
+                                               id : 'pasteMsg',\r
+                                               html : '<div style="white-space:normal;width:340px;">'+lang.pasteMsg +'</div>'\r
+                                       },\r
+                                       {\r
+                                               type : 'html',\r
+                                               id : 'editing_area',\r
+                                               style : 'width: 100%; height: 100%;',\r
+                                               html : '',\r
+                                               focus : function()\r
+                                               {\r
+                                                       var win = this.getInputElement().$.contentWindow;\r
+\r
+                                                       // #3291 : JAWS needs the 500ms delay to detect that the editor iframe\r
+                                                       // iframe is no longer editable. So that it will put the focus into the\r
+                                                       // Paste from Word dialog's editable area instead.\r
+                                                       setTimeout( function()\r
+                                                       {\r
+                                                               win.focus();\r
+                                                       }, 500 );\r
+                                               },\r
+                                               setup : function()\r
+                                               {\r
+                                                       var dialog = this.getDialog();\r
+                                                       var htmlToLoad =\r
+                                                               '<html dir="' + editor.config.contentsLangDirection + '"' +\r
+                                                               ' lang="' + ( editor.config.contentsLanguage || editor.langCode ) + '">' +\r
+                                                               '<head><style>body { margin: 3px; height: 95%; } </style></head><body>' +\r
+                                                               '<script id="cke_actscrpt" type="text/javascript">' +\r
+                                                               'window.parent.CKEDITOR.tools.callFunction( ' + CKEDITOR.tools.addFunction( onPasteFrameLoad, dialog ) + ', this );' +\r
+                                                               '</script></body>' +\r
+                                                               '</html>';\r
+\r
+                                                       var src =\r
+                                                               CKEDITOR.env.air ?\r
+                                                                       'javascript:void(0)' :\r
+                                                               isCustomDomain ?\r
+                                                                       'javascript:void((function(){' +\r
+                                                                               'document.open();' +\r
+                                                                               'document.domain=\'' + document.domain + '\';' +\r
+                                                                               'document.close();' +\r
+                                                                       '})())"'\r
+                                                               :\r
+                                                                       '';\r
+\r
+                                                       var iframe = CKEDITOR.dom.element.createFromHtml(\r
+                                                               '<iframe' +\r
+                                                                       ' class="cke_pasteframe"' +\r
+                                                                       ' frameborder="0" ' +\r
+                                                                       ' allowTransparency="true"' +\r
+                                                                       ' src="' + src + '"' +\r
+                                                                       ' role="region"' +\r
+                                                                       ' aria-label="' + lang.pasteArea + '"' +\r
+                                                                       ' aria-describedby="' + dialog.getContentElement( 'general', 'pasteMsg' ).domId + '"' +\r
+                                                                       ' aria-multiple="true"' +\r
+                                                                       '></iframe>' );\r
+\r
+                                                       iframe.on( 'load', function( e )\r
+                                                       {\r
+                                                               e.removeListener();\r
+\r
+                                                               var doc = iframe.getFrameDocument();\r
+                                                               doc.write( htmlToLoad );\r
+\r
+                                                               if ( CKEDITOR.env.air )\r
+                                                                       onPasteFrameLoad.call( this, doc.getWindow().$ );\r
+                                                       }, dialog );\r
+\r
+                                                       iframe.setCustomData( 'dialog', dialog );\r
+\r
+                                                       var container = this.getElement();\r
+                                                       container.setHtml( '' );\r
+                                                       container.append( iframe );\r
+\r
+                                                       // IE need a redirect on focus to make\r
+                                                       // the cursor blinking inside iframe. (#5461)\r
+                                                       if ( CKEDITOR.env.ie )\r
+                                                       {\r
+                                                               var focusGrabber = CKEDITOR.dom.element.createFromHtml( '<span tabindex="-1" style="position:absolute;" role="presentation"></span>' );\r
+                                                               focusGrabber.on( 'focus', function()\r
+                                                               {\r
+                                                                       iframe.$.contentWindow.focus();\r
+                                                               });\r
+                                                               container.append( focusGrabber );\r
+\r
+                                                               // Override focus handler on field.\r
+                                                               this.focus = function()\r
+                                                               {\r
+                                                                       focusGrabber.focus();\r
+                                                                       this.fire( 'focus' );\r
+                                                               };\r
+                                                       }\r
+\r
+                                                       this.getInputElement = function(){ return iframe; };\r
+\r
+                                                       // Force container to scale in IE.\r
+                                                       if ( CKEDITOR.env.ie )\r
+                                                       {\r
+                                                               container.setStyle( 'display', 'block' );\r
+                                                               container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' );\r
+                                                       }\r
+                                               },\r
+                                               commit : function( data )\r
+                                               {\r
+                                                       var container = this.getElement(),\r
+                                                               editor = this.getDialog().getParentEditor(),\r
+                                                               body = this.getInputElement().getFrameDocument().getBody(),\r
+                                                               bogus = body.getBogus(),\r
+                                                               html;\r
+                                                       bogus && bogus.remove();\r
+\r
+                                                       // Saving the contents so changes until paste is complete will not take place (#7500)\r
+                                                       html = body.getHtml();\r
+\r
+                                                       setTimeout( function(){\r
+                                                               editor.fire( 'paste', { 'html' : html } );\r
+                                                       }, 0 );\r
+                                               }\r
+                                       }\r
+                               ]\r
+                       }\r
+               ]\r
+       };\r
+});\r