X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fwysiwygarea%2Fplugin.js;h=11fd76eb32f24108b9fcfd03ab6f95e94fb58a04;hb=c6e377a02b54abc07129d72b632763c727476a15;hp=d3b9e629d459699a04f79e90c68a9112df0d4ce3;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;p=ckeditor.git
diff --git a/_source/plugins/wysiwygarea/plugin.js b/_source/plugins/wysiwygarea/plugin.js
index d3b9e62..11fd76e 100644
--- a/_source/plugins/wysiwygarea/plugin.js
+++ b/_source/plugins/wysiwygarea/plugin.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -10,18 +10,18 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
(function()
{
- /**
- * List of elements in which has no way to move editing focus outside.
- */
+ // List of elements in which has no way to move editing focus outside.
var nonExitableElementNames = { table:1,pre:1 };
+
// Matching an empty paragraph at the end of document.
- var emptyParagraphRegexp = /\s*<(p|div|address|h\d|center)[^>]*>\s*(?:
]*>| |\u00A0| )?\s*(:?<\/\1>)?\s*$/gi;
+ var emptyParagraphRegexp = /\s*<(p|div|address|h\d|center)[^>]*>\s*(?:
]*>| |\u00A0| )?\s*(:?<\/\1>)?\s*(?=$|<\/body>)/gi;
function onInsertHtml( evt )
{
if ( this.mode == 'wysiwyg' )
{
this.focus();
+ this.fire( 'saveSnapshot' );
var selection = this.getSelection(),
data = evt.data;
@@ -46,6 +46,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
}
else
this.document.$.execCommand( 'inserthtml', false, data );
+
+ CKEDITOR.tools.setTimeout( function()
+ {
+ this.fire( 'saveSnapshot' );
+ }, 0, this );
}
}
@@ -84,7 +89,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var current, dtd;
if ( isBlock )
{
- while( ( current = range.getCommonAncestor( false, true ) )
+ while ( ( current = range.getCommonAncestor( false, true ) )
&& ( dtd = CKEDITOR.dtd[ current.getName() ] )
&& !( dtd && dtd [ elementName ] ) )
{
@@ -138,7 +143,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// DOM modification here should not bother dirty flag.(#4385)
function restoreDirty( editor )
{
- if( !editor.checkDirty() )
+ if ( !editor.checkDirty() )
setTimeout( function(){ editor.resetDirty(); } );
}
@@ -190,7 +195,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// If the fixed block is blank and already followed by a exitable
// block, we should revert the fix. (#3684)
- if( fixedBlock.getOuterHtml().match( emptyParagraphRegexp ) )
+ if ( fixedBlock.getOuterHtml().match( emptyParagraphRegexp ) )
{
var previousElement = fixedBlock.getPrevious( isNotWhitespace ),
nextElement = fixedBlock.getNext( isNotWhitespace );
@@ -209,7 +214,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
range.select();
// Notify non-IE that selection has changed.
- if( !CKEDITOR.env.ie )
+ if ( !CKEDITOR.env.ie )
editor.selectionChange();
}
@@ -220,7 +225,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
if ( lastNode && lastNode.getName && ( lastNode.getName() in nonExitableElementNames ) )
{
restoreDirty( editor );
- if( !CKEDITOR.env.ie )
+ if ( !CKEDITOR.env.ie )
body.appendBogus();
else
body.append( editor.document.createText( '\xa0' ) );
@@ -250,7 +255,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var isCustomDomain = CKEDITOR.env.isCustomDomain();
// Creates the iframe that holds the editable document.
- var createIFrame = function()
+ var createIFrame = function( data )
{
if ( iframe )
iframe.remove();
@@ -258,46 +263,42 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
fieldset.remove();
frameLoaded = 0;
- // The document domain must be set within the src
- // attribute;
- // Defer the script execution until iframe
- // has been added to main window, this is needed for some
- // browsers which will begin to load the frame content
- // prior to it's presentation in DOM.(#3894)
- var src = 'void( '
- + ( CKEDITOR.env.gecko ? 'setTimeout' : '' ) + '( function(){' +
- 'document.open();' +
- ( CKEDITOR.env.ie && isCustomDomain ? 'document.domain="' + document.domain + '";' : '' ) +
- 'document.write( window.parent[ "_cke_htmlToLoad_' + editor.name + '" ] );' +
+
+ iframe = CKEDITOR.dom.element.createFromHtml( '' );
+
+ // Register onLoad event for iframe element, which
+ // will fill it with content and set custom domain.
+ iframe.on( 'load', function( e )
+ {
+ e.removeListener();
+ var doc = iframe.getFrameDocument().$;
- // Loading via src attribute does not work in Opera.
- if ( CKEDITOR.env.opera )
- src = 'void(0);';
+ // Custom domain handling is needed after each document.open().
+ doc.open();
+ if ( isCustomDomain )
+ doc.domain = document.domain;
+ doc.write( data );
+ doc.close();
- iframe = CKEDITOR.dom.element.createFromHtml( '' );
+ } );
var accTitle = editor.lang.editorTitle.replace( '%1', editor.name );
if ( CKEDITOR.env.gecko )
{
- // Double checking the iframe will be loaded properly(#4058).
- iframe.on( 'load', function( ev )
- {
- ev.removeListener();
- contentDomReady( iframe.$.contentWindow );
- } );
-
// Accessibility attributes for Firefox.
mainElement.setAttributes(
{
@@ -340,7 +341,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// The script that launches the bootstrap logic on 'domReady', so the document
// is fully editable even before the editing iframe is fully loaded (#4455).
var activationScript =
- '';
@@ -416,7 +417,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// IE standard compliant in editing frame doesn't focus the editor when
// clicking outside actual content, manually apply the focus. (#1659)
- if( CKEDITOR.env.ie
+ if ( CKEDITOR.env.ie
&& domDocument.$.compatMode == 'CSS1Compat' )
{
var htmlElement = domDocument.getDocumentElement();
@@ -445,10 +446,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
if ( CKEDITOR.env.gecko )
{
var first = body;
- while( first.firstChild )
+ while ( first.firstChild )
first = first.firstChild;
- if( !first.nextSibling
+ if ( !first.nextSibling
&& ( 'BR' == first.tagName )
&& first.hasAttribute( '_moz_editor_bogus_node' ) )
{
@@ -475,31 +476,45 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
if ( CKEDITOR.env.ie )
{
- // Cancel default action for backspace in IE on control types. (#4047)
+ // Override keystrokes which should have deletion behavior
+ // on control types in IE . (#4047)
domDocument.on( 'keydown', function( evt )
{
- // Backspace.
- var control = evt.data.getKeystroke() == 8
- && editor.getSelection().getSelectedElement();
- if ( control )
+ var keyCode = evt.data.getKeystroke();
+
+ // Backspace OR Delete.
+ if ( keyCode in { 8 : 1, 46 : 1 } )
{
- // Make undo snapshot.
- editor.fire( 'saveSnapshot' );
- // Remove manually.
- control.remove();
- editor.fire( 'saveSnapshot' );
- evt.cancel();
+ var sel = editor.getSelection(),
+ control = sel.getSelectedElement();
+
+ if ( control )
+ {
+ // Make undo snapshot.
+ editor.fire( 'saveSnapshot' );
+
+ // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will
+ // break up the selection, safely manage it here. (#4795)
+ var bookmark = sel.getRanges()[ 0 ].createBookmark();
+ // Remove the control manually.
+ control.remove();
+ sel.selectBookmarks( [ bookmark ] );
+
+ editor.fire( 'saveSnapshot' );
+
+ evt.data.preventDefault();
+ }
}
} );
// PageUp/PageDown scrolling is broken in document
// with standard doctype, manually fix it. (#4736)
- if( domDocument.$.compatMode == 'CSS1Compat' )
+ if ( domDocument.$.compatMode == 'CSS1Compat' )
{
var pageUpDownKeys = { 33 : 1, 34 : 1 };
domDocument.on( 'keydown', function( evt )
{
- if( evt.data.getKeystroke() in pageUpDownKeys )
+ if ( evt.data.getKeystroke() in pageUpDownKeys )
{
setTimeout( function ()
{
@@ -586,54 +601,107 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
isLoadingData = true;
- // Get the HTML version of the data.
- if ( editor.dataProcessor )
+ var config = editor.config,
+ fullPage = config.fullPage,
+ docType = config.docType;
+
+ // Build the additional stuff to be included into