X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fpreview%2Fplugin.js;h=da2e1fc1a18b460a264dde8274018d80c89c6791;hb=6e682412d5cc0dfaedb376482e585bf2989c6863;hp=dd53d4396ecd48f68a5db6a07a832e7b28e1ced2;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/plugins/preview/plugin.js b/_source/plugins/preview/plugin.js index dd53d43..da2e1fc 100644 --- a/_source/plugins/preview/plugin.js +++ b/_source/plugins/preview/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -9,10 +9,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license (function() { + var pluginPath; + var previewCmd = { modes : { wysiwyg:1, source:1 }, canUndo : false, + readOnly : 1, exec : function( editor ) { var sHTML, @@ -24,7 +27,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { sHTML = editor.getData() .replace( //, '$&' + baseTag ) - .replace( /[^>]*(?=<\/title>)/, editor.lang.preview ); + .replace( /[^>]*(?=<\/title>)/, '$& — ' + editor.lang.preview ); } else { @@ -78,14 +81,26 @@ For licensing, see LICENSE.html or http://ckeditor.com/license '})() )'; } + // With Firefox only, we need to open a special preview page, so + // anchors will work properly on it. (#9047) + if ( CKEDITOR.env.gecko ) + { + window._cke_htmlToLoad = sHTML; + sOpenUrl = pluginPath + 'preview.html'; + } + var oWindow = window.open( sOpenUrl, null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ); - if ( !isCustomDomain ) + if ( !isCustomDomain && !CKEDITOR.env.gecko ) { - oWindow.document.open(); - oWindow.document.write( sHTML ); - oWindow.document.close(); + var doc = oWindow.document; + doc.open(); + doc.write( sHTML ); + doc.close(); + + // Chrome will need this to show the embedded. (#8016) + CKEDITOR.env.webkit && setTimeout( function() { doc.body.innerHTML += ''; }, 0 ); } } }; @@ -97,6 +112,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { init : function( editor ) { + pluginPath = this.path; + editor.addCommand( pluginName, previewCmd ); editor.ui.addButton( 'Preview', {