+++ /dev/null
-/*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-CKEDITOR.dialog.add( 'pastefromword', function( editor )\r
-{\r
- return {\r
- title : editor.lang.pastefromword.title,\r
- minWidth : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 370 : 350,\r
- minHeight : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 270 : 260,\r
- htmlToLoad : '<!doctype html><script type="text/javascript">'\r
- + 'window.onload = function()'\r
- + '{'\r
- + 'if ( ' + CKEDITOR.env.ie + ' ) '\r
- + 'document.body.contentEditable = "true";'\r
- + 'else '\r
- + 'document.designMode = "on";'\r
- + 'var iframe = new window.parent.CKEDITOR.dom.element( frameElement );'\r
- + 'var dialog = iframe.getCustomData( "dialog" );'\r
- + ''\r
- + 'iframe.getFrameDocument().on( "keydown", function( e )\\r
- {\\r
- if ( e.data.getKeystroke() == 27 )\\r
- dialog.hide();\\r
- });'\r
- + 'dialog.fire( "iframeAdded", { iframe : iframe } );'\r
- + '};'\r
- + '</script><style>body { margin: 3px; height: 95%; } </style><body></body>',\r
- cleanWord : function( editor, html, ignoreFont, removeStyles )\r
- {\r
- // Remove comments [SF BUG-1481861].\r
- html = html.replace(/<\!--[\s\S]*?-->/g, '' ) ;\r
-\r
- html = html.replace(/<o:p>\s*<\/o:p>/g, '') ;\r
- html = html.replace(/<o:p>[\s\S]*?<\/o:p>/g, ' ') ;\r
-\r
- // Remove mso-xxx styles.\r
- html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' ) ;\r
-\r
- // Remove margin styles.\r
- html = html.replace( /\s*MARGIN: 0(?:cm|in) 0(?:cm|in) 0pt\s*;/gi, '' ) ;\r
- html = html.replace( /\s*MARGIN: 0(?:cm|in) 0(?:cm|in) 0pt\s*"/gi, "\"" ) ;\r
-\r
- html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, '' ) ;\r
- html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;\r
-\r
- html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;\r
-\r
- html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;\r
-\r
- html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;\r
-\r
- html = html.replace( /\s*tab-stops:[^;"]*;?/gi, '' ) ;\r
- html = html.replace( /\s*tab-stops:[^"]*/gi, '' ) ;\r
-\r
- // Remove FONT face attributes.\r
- if ( ignoreFont )\r
- {\r
- html = html.replace( /\s*face="[^"]*"/gi, '' ) ;\r
- html = html.replace( /\s*face=[^ >]*/gi, '' ) ;\r
-\r
- html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, '' ) ;\r
- }\r
-\r
- // Remove Class attributes\r
- html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;\r
-\r
- // Remove styles.\r
- if ( removeStyles )\r
- html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;\r
-\r
- // Remove style, meta and link tags\r
- html = html.replace( /<STYLE[^>]*>[\s\S]*?<\/STYLE[^>]*>/gi, '' ) ;\r
- html = html.replace( /<(?:META|LINK)[^>]*>\s*/gi, '' ) ;\r
-\r
- // Remove empty styles.\r
- html = html.replace( /\s*style="\s*"/gi, '' ) ;\r
-\r
- html = html.replace( /<SPAN\s*[^>]*>\s* \s*<\/SPAN>/gi, ' ' ) ;\r
-\r
- html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;\r
-\r
- // Remove Lang attributes\r
- html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;\r
-\r
- html = html.replace( /<SPAN\s*>([\s\S]*?)<\/SPAN>/gi, '$1' ) ;\r
-\r
- html = html.replace( /<FONT\s*>([\s\S]*?)<\/FONT>/gi, '$1' ) ;\r
-\r
- // Remove XML elements and declarations\r
- html = html.replace(/<\\?\?xml[^>]*>/gi, '' ) ;\r
-\r
- // Remove w: tags with contents.\r
- html = html.replace( /<w:[^>]*>[\s\S]*?<\/w:[^>]*>/gi, '' ) ;\r
-\r
- // Remove Tags with XML namespace declarations: <o:p><\/o:p>\r
- html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ;\r
-\r
- html = html.replace( /<(U|I|STRIKE)> <\/\1>/g, ' ' ) ;\r
-\r
- html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;\r
-\r
- // Remove "display:none" tags.\r
- html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none[\s\S]*?<\/\1>/ig, '' ) ;\r
-\r
- // Remove language tags\r
- html = html.replace( /<(\w[^>]*) language=([^ |>]*)([^>]*)/gi, "<$1$3") ;\r
-\r
- // Remove onmouseover and onmouseout events (from MS Word comments effect)\r
- html = html.replace( /<(\w[^>]*) onmouseover="([^\"]*)"([^>]*)/gi, "<$1$3") ;\r
- html = html.replace( /<(\w[^>]*) onmouseout="([^\"]*)"([^>]*)/gi, "<$1$3") ;\r
-\r
- if ( editor.config.pasteFromWordKeepsStructure )\r
- {\r
- // The original <Hn> tag send from Word is something like this: <Hn style="margin-top:0px;margin-bottom:0px">\r
- html = html.replace( /<H(\d)([^>]*)>/gi, '<h$1>' ) ;\r
-\r
- // Word likes to insert extra <font> tags, when using MSIE. (Wierd).\r
- html = html.replace( /<(H\d)><FONT[^>]*>([\s\S]*?)<\/FONT><\/\1>/gi, '<$1>$2<\/$1>' );\r
- html = html.replace( /<(H\d)><EM>([\s\S]*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' );\r
- }\r
- else\r
- {\r
- html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' ) ;\r
- html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' ) ;\r
- html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' ) ;\r
- html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' ) ;\r
- html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' ) ;\r
- html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' ) ;\r
-\r
- html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ;\r
-\r
- // Transform <P> to <DIV>\r
- var re = new RegExp( '(<P)([^>]*>[\\s\\S]*?)(<\/P>)', 'gi' ) ; // Different because of a IE 5.0 error\r
- html = html.replace( re, '<div$2<\/div>' ) ;\r
-\r
- // Remove empty tags (three times, just to be sure).\r
- // This also removes any empty anchor\r
- html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;\r
- html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;\r
- html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;\r
- }\r
-\r
- return html ;\r
- },\r
- onShow : function()\r
- {\r
- // To avoid JAWS putting virtual cursor back to the editor document,\r
- // disable main document 'contentEditable' during dialog opening.\r
- if ( CKEDITOR.env.ie )\r
- this.getParentEditor().document.getBody().$.contentEditable = 'false';\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
- var container = this.getContentElement( 'general', 'editing_area' ).getElement(),\r
- iframe = CKEDITOR.dom.element.createFromHtml( '<iframe src="javascript:void(0)" frameborder="0" allowtransparency="1"></iframe>' );\r
-\r
- var lang = this.getParentEditor().lang;\r
-\r
- iframe.setStyles(\r
- {\r
- width : '346px',\r
- height : '152px',\r
- 'background-color' : 'white',\r
- border : '1px solid black'\r
- } );\r
- iframe.setCustomData( 'dialog', this );\r
-\r
- var accTitle = lang.editorTitle.replace( '%1', lang.pastefromword.title );\r
-\r
- if ( CKEDITOR.env.ie )\r
- container.setHtml( '<legend style="position:absolute;top:-1000000px;left:-1000000px;">'\r
- + CKEDITOR.tools.htmlEncode( accTitle )\r
- + '</legend>' );\r
- else\r
- {\r
- container.setHtml( '' );\r
- container.setAttributes(\r
- {\r
- role : 'region',\r
- title : accTitle\r
- } );\r
- iframe.setAttributes(\r
- {\r
- role : 'region',\r
- title : ' '\r
- } );\r
- }\r
- container.append( iframe );\r
- if ( CKEDITOR.env.ie )\r
- container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' );\r
-\r
- if ( CKEDITOR.env.isCustomDomain() )\r
- {\r
- CKEDITOR._cke_htmlToLoad = this.definition.htmlToLoad;\r
- iframe.setAttribute( 'src',\r
- 'javascript:void( (function(){' +\r
- 'document.open();' +\r
- 'document.domain="' + document.domain + '";' +\r
- 'document.write( window.parent.CKEDITOR._cke_htmlToLoad );' +\r
- 'delete window.parent.CKEDITOR._cke_htmlToLoad;' +\r
- 'document.close();' +\r
- '})() )' );\r
- }\r
- else\r
- {\r
- var doc = iframe.$.contentWindow.document;\r
- doc.open();\r
- doc.write( this.definition.htmlToLoad );\r
- doc.close();\r
- }\r
- },\r
- onOk : function()\r
- {\r
- var container = this.getContentElement( 'general', 'editing_area' ).getElement(),\r
- iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ),\r
- editor = this.getParentEditor(),\r
- html = this.definition.cleanWord( editor, iframe.$.contentWindow.document.body.innerHTML,\r
- this.getValueOf( 'general', 'ignoreFontFace' ),\r
- this.getValueOf( 'general', 'removeStyle' ) );\r
-\r
- // Insertion should happen after main document design mode turned on.\r
- setTimeout( function(){\r
- editor.insertHtml( html );\r
- }, 0 );\r
- },\r
- onHide : function()\r
- {\r
- if ( CKEDITOR.env.ie )\r
- this.getParentEditor().document.getBody().$.contentEditable = 'true';\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
- contents :\r
- [\r
- {\r
- id : 'general',\r
- label : editor.lang.pastefromword.title,\r
- elements :\r
- [\r
- {\r
- type : 'html',\r
- style : 'white-space:normal;width:346px;display:block',\r
- onShow : function()\r
- {\r
- /*\r
- * SAFARI BUG: The advice label would overflow if the table layout\r
- * isn't fixed.\r
- */\r
- if ( CKEDITOR.env.webkit )\r
- this.getElement().getAscendant( 'table' ).setStyle( 'table-layout', 'fixed' );\r
- },\r
- html : editor.lang.pastefromword.advice\r
- },\r
- {\r
- type : 'html',\r
- id : 'editing_area',\r
- style : 'width: 100%; height: 100%;',\r
- html : '<fieldset></fieldset>',\r
- focus : function()\r
- {\r
- var div = this.getElement();\r
- var iframe = div.getElementsByTag( 'iframe' );\r
- if ( iframe.count() < 1 )\r
- return;\r
- iframe = iframe.getItem( 0 );\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
- iframe.$.contentWindow.focus();\r
- }, 500 );\r
- }\r
- },\r
- {\r
- type : 'vbox',\r
- padding : 0,\r
- children :\r
- [\r
- {\r
- type : 'checkbox',\r
- id : 'ignoreFontFace',\r
- label : editor.lang.pastefromword.ignoreFontFace,\r
- 'default' : editor.config.pasteFromWordIgnoreFontFace\r
- },\r
- {\r
- type : 'checkbox',\r
- id : 'removeStyle',\r
- label : editor.lang.pastefromword.removeStyle,\r
- 'default' : editor.config.pasteFromWordRemoveStyle\r
- }\r
- ]\r
- }\r
- ]\r
- }\r
- ]\r
- };\r
-} );\r