Index: _samples/sharedspaces_iframe.html
===================================================================
--- _samples/sharedspaces_iframe.html (revision 0)
+++ _samples/sharedspaces_iframe.html (revision 0)
@@ -0,0 +1,35 @@
+
+
+
+
+ .
- container = mainContainer.getChild( [0,0,0,0] );
+ // Get the element in the target.
+ element = targetDoc.getById( element[ 2 ] );
+
+ if ( element )
+ {
+ // Bridge the CKEDITOR object.
+ targetWindow.$.CKEDITOR = CKEDITOR;
- // When the editor gets focus, we show the space container, hiding others.
- editor.on( 'focus', function()
- {
- for ( var i = 0, sibling, children = element.getChildren() ; ( sibling = children.getItem( i ) ) ; i++ )
- {
- if ( sibling.type == CKEDITOR.NODE_ELEMENT
- && !sibling.equals( mainContainer )
- && sibling.hasClass( 'cke_shared' ) )
+ if ( !targetWindow.getCustomData( 'cke_getById' ) )
{
- sibling.hide();
+ // Expand element finding scope to include target document.
+ CKEDITOR.document.getById = CKEDITOR.tools.override( CKEDITOR.document.getById,
+ function( originalGetById )
+ {
+ return function( id )
+ {
+ return originalGetById.call( this, id ) || targetDoc.getById( id );
+ }
+ });
+
+ targetWindow.setCustomData( 'cke_getById', 1 );
}
+
+ var skinName = editor.skinName ;
+ if ( !targetWindow.getCustomData( 'cke_skin' + skinName + '_editor' ) )
+ {
+ // Loads editor skin part into target window.
+ var part = CKEDITOR.skins[ skinName ].editor;
+ for ( var c = 0 ; c < part.css.length ; c++ )
+ targetDoc.appendStyleSheet( part.css[ c ] );
+
+ targetWindow.setCustomData( 'cke_skin' + skinName, 1 );
+ }
}
+ }
+ }
+
+
+
+ // If the element is available, we'll then create the container for
+ // the space.
+ if ( element )
+ {
+ // On first editor make sure space is empty. If using an IFrame there may be left over toolbars
+ // TODO: This could probably be done better elsewhere.
+ if(!CKEDITOR.loading){
+ element.$.innerHTML = "";
+ CKEDITOR.loading = true;
+ }
+
+ // Creates an HTML structure that reproduces the editor class hierarchy.
+ var html =
+ '
' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '
';
- mainContainer.show();
- });
+ var mainContainer = element.append( CKEDITOR.dom.element.createFromHtml( html, element.getDocument() ) );
- editor.on( 'destroy', function()
- {
- mainContainer.remove();
- });
+ // Only the first container starts visible. Others get hidden.
+ if ( element.getCustomData( 'cke_hasshared' ) )
+ mainContainer.hide( );
+ else
+ element.setCustomData( 'cke_hasshared', 1 );
+
+
+
+ // Get the deeper inner
.
+ container = mainContainer.getChild( [0,0,0,0] );
+
+ // When the editor gets focus, we show the space container, hiding others.
+ editor.on( 'focus', function()
+ {
+ for ( var i = 0, sibling, children = element.getChildren() ; ( sibling = children.getItem( i ) ) ; i++ )
+ {
+ if ( sibling.type == CKEDITOR.NODE_ELEMENT
+ && !sibling.equals( mainContainer )
+ && sibling.hasClass( 'cke_shared' ) )
+ {
+ sibling.hide();
+ }
+ }
+
+ mainContainer.show();
+ });
+
+ editor.on( 'destroy', function()
+ {
+ mainContainer.remove();
+ });
+ }
}
return container;
@@ -168,6 +241,25 @@
buildDialog : function( editor )
{
+ var skinName = editor.skinName;
+
+ editor.on( 'dialogReady', function( evt )
+ {
+ var dialog = evt.data,
+ dialogDoc = dialog._.document,
+ targetWin = dialogDoc.getWindow();
+
+ if( !( targetWin.equals( CKEDITOR.document.getWindow() )
+ || targetWin.getCustomData( 'cke_skin' + skinName + '_dialog') ) )
+ {
+ // Loads dialog skin part into dialog living window.
+ var part = CKEDITOR.skins[ skinName ].dialog;
+ for ( var c = 0 ; c < part.css.length ; c++ )
+ dialogDoc.appendStyleSheet( part.css[ c ] );
+ }
+ } );
+
+
var baseIdNumber = CKEDITOR.tools.getNextNumber();
var element = CKEDITOR.dom.element.createFromHtml( [