| 10 | | var iframeId = 'cke_' + CKEDITOR.tools.getNextNumber(); |
| 11 | | |
| 12 | | // For document.domain compatibility (#123) we must do all the magic in |
| 13 | | // the URL for IE. |
| 14 | | var src = |
| 15 | | isCustomDomain ? |
| 16 | | 'javascript:void((function(){' + |
| 17 | | 'document.open();' + |
| 18 | | 'document.domain=\'' + document.domain + '\';' + |
| 19 | | 'document.write( window.parent.CKEDITOR._htmlToLoad );' + |
| 20 | | 'document.close();' + |
| 21 | | 'document.body.contentEditable = true;' + |
| 22 | | 'delete window.parent.CKEDITOR._htmlToLoad;' + |
| 23 | | 'window.focus();' + |
| 24 | | '})())' |
| 25 | | : |
| 26 | | 'javascript:void(0)'; |
| 27 | | |
| 28 | | var iframeHtml = |
| 29 | | '<iframe' + |
| 30 | | ' src="' + src + '"' + |
| 31 | | ' id="' + iframeId + '"' + |
| 32 | | ' style="width:346px;background-color:white;height:130px;border:1px solid black"' + |
| 33 | | ' frameborder="0"' + |
| 34 | | ' allowtransparency="1">' + |
| 35 | | '</iframe>'; |
| 36 | | |
| 37 | | var htmlToLoad = |
| 38 | | '<!doctype html>' + |
| 39 | | '<script type="text/javascript">' + |
| 40 | | 'window.onload = function()' + |
| 41 | | '{' + |
| 42 | | ( CKEDITOR.env.ie ? |
| 43 | | 'document.body.contentEditable = "true";' : |
| 44 | | 'document.designMode = "on";' ) + |
| 45 | | 'window.focus();' + |
| 46 | | '};' + |
| 47 | | // Avoid errors if the pasted content has any script that |
| 48 | | // fails. (#389) |
| 49 | | 'window.onerror = function()' + |
| 50 | | '{' + |
| 51 | | 'return true;' + |
| 52 | | '};' + |
| 53 | | '</script><body style="margin:3px"></body>'; |
| 54 | | |
| | 15 | htmlToLoad : '<!doctype html><script type="text/javascript">' |
| | 16 | + 'window.onload = function()' |
| | 17 | + '{' |
| | 18 | + 'if ( ' + CKEDITOR.env.ie + ' ) ' |
| | 19 | + 'document.body.contentEditable = "true";' |
| | 20 | + 'else ' |
| | 21 | + 'document.designMode = "on";' |
| | 22 | + 'var iframe = new window.parent.CKEDITOR.dom.element( frameElement );' |
| | 23 | + 'var dialog = iframe.getCustomData( "dialog" );' |
| | 24 | + 'dialog.fire( "iframeAdded", { iframe : iframe } );' |
| | 25 | + '};' |
| | 26 | + '</script><style>body { margin: 3px; height: 95%; } </style><body></body>', |
| 63 | | if ( isCustomDomain ) |
| 64 | | CKEDITOR._htmlToLoad = htmlToLoad; |
| | 30 | if ( CKEDITOR.env.ie ) |
| | 31 | this.getParentEditor().document.getBody().$.contentEditable = 'false'; |
| | 32 | |
| | 33 | // FIREFOX BUG: Force the browser to render the dialog to make the to-be- |
| | 34 | // inserted iframe editable. (#3366) |
| | 35 | this.parts.dialog.$.offsetHeight; |
| | 36 | |
| | 37 | var container = this.getContentElement( 'general', 'editing_area' ).getElement(), |
| | 38 | iframe = CKEDITOR.dom.element.createFromHtml( '<iframe src="javascript:void(0)" frameborder="0" allowtransparency="1"></iframe>' ); |
| | 39 | |
| | 40 | var lang = this.getParentEditor().lang; |
| | 41 | |
| | 42 | iframe.setStyles( |
| | 43 | { |
| | 44 | width : '346px', |
| | 45 | height : '130px', |
| | 46 | 'background-color' : 'white', |
| | 47 | border : '1px solid black' |
| | 48 | } ); |
| | 49 | iframe.setCustomData( 'dialog', this ); |
| | 50 | |
| | 51 | var accTitle = lang.editorTitle.replace( '%1', lang.clipboard.title ); |
| | 52 | |
| | 53 | if ( CKEDITOR.env.ie ) |
| | 54 | container.setHtml( '<legend style="position:absolute;top:-1000000px;left:-1000000px;">' |
| | 55 | + CKEDITOR.tools.htmlEncode( accTitle ) |
| | 56 | + '</legend>' ); |
| 69 | | var $doc = iframe.$.contentWindow.document; |
| 70 | | $doc.open(); |
| 71 | | $doc.write( htmlToLoad ); |
| 72 | | $doc.close(); |
| 73 | | |
| 74 | | iframe.$.contentWindow.focus(); |
| | 75 | if ( isCustomDomain ) |
| | 76 | { |
| | 77 | CKEDITOR._cke_htmlToLoad = this.definition.htmlToLoad; |
| | 78 | iframe.setAttribute( 'src', |
| | 79 | 'javascript:void( (function(){' + |
| | 80 | 'document.open();' + |
| | 81 | 'document.domain="' + document.domain + '";' + |
| | 82 | 'document.write( window.parent.CKEDITOR._cke_htmlToLoad );' + |
| | 83 | 'delete window.parent.CKEDITOR._cke_htmlToLoad;' + |
| | 84 | 'document.close();' + |
| | 85 | '})() )' ); |
| 113 | | id : 'content', |
| 114 | | style : 'width:340px;height:130px', |
| 115 | | html : '<div>' + iframeHtml + '</div>' |
| | 130 | id : 'editing_area', |
| | 131 | style : 'width: 100%; height: 100%;', |
| | 132 | html : '<fieldset></fieldset>', |
| | 133 | focus : function() |
| | 134 | { |
| | 135 | var div = this.getElement(); |
| | 136 | var iframe = div.getElementsByTag( 'iframe' ); |
| | 137 | if ( iframe.count() < 1 ) |
| | 138 | return; |
| | 139 | iframe = iframe.getItem( 0 ); |
| | 140 | |
| | 141 | // #3291 : JAWS needs the 500ms delay to detect that the editor iframe |
| | 142 | // iframe is no longer editable. So that it will put the focus into the |
| | 143 | // Paste from Word dialog's editable area instead. |
| | 144 | setTimeout( function() |
| | 145 | { |
| | 146 | iframe.$.contentWindow.focus(); |
| | 147 | }, 500 ); |
| | 148 | } |