Ticket #4228: shared_spaces_iframe 3.4.3.patch

File shared_spaces_iframe 3.4.3.patch, 17.8 KB (added by Brian Ernesto, 13 years ago)

3.4.3 IFrame out patch

  • _samples/sharedspaces_iframe.html

     
     1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2<!--
     3Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     4For licensing, see LICENSE.html or http://ckeditor.com/license
     5-->
     6<html xmlns="http://www.w3.org/1999/xhtml">
     7<head>
     8        <title>Shared Spaces - CKEditor Sample</title>
     9        <script type="text/javascript" src="sample.js"></script>
     10        <style id="styles" type="text/css">
     11
     12iframe
     13{
     14        height: 550px;
     15        width: 100%;
     16        overflow: auto;
     17        border: solid 1px #555;
     18        margin: 10px 0;
     19}
     20
     21        </style>
     22</head>
     23<body>
     24        <div id="html">
     25                <div id="topSpace">
     26                </div>
     27                <iframe src="sharedspaces_iframe/inner_iframe.html"></iframe>
     28                <div id="bottomSpace">
     29                </div>
     30        </div>
     31        <div id="code">
     32                <pre></pre>
     33        </div>
     34</body>
     35</html>
  • _source/core/skins.js

     
    2323        var loadPart = function( editor, skinName, part, callback )
    2424        {
    2525                // Get the skin definition.
    26                 var skinDefinition = loaded[ skinName ];
     26                var skinDefinition = CKEDITOR.skins[ skinName ] = loaded[ skinName ];
    2727
    2828                if ( !editor.skin )
    2929                {
  • _source/plugins/dialog/plugin.js

     
    118118                definition = new definitionObject( this, definition );
    119119
    120120
    121                 var doc = CKEDITOR.document;
     121                //var doc = CKEDITOR.document;
    122122
    123123                var themeBuilt = editor.theme.buildDialog( editor );
    124124
     
    126126                this._ =
    127127                {
    128128                        editor : editor,
     129                        document : new CKEDITOR.dom.document( top.document ),
    129130                        element : themeBuilt.element,
    130131                        name : dialogName,
    131132                        contentSize : { width : 0, height : 0 },
     
    401402                        processed && evt.data.preventDefault();
    402403                }
    403404
    404                 var dialogElement = this._.element;
     405                var dialogElement = this._.document;//this._.element;
    405406                // Add the dialog keyboard handlers.
    406407                this.on( 'show', function()
    407408                        {
     
    493494                initResizeHandles( this );
    494495
    495496                // Insert the title.
    496                 ( new CKEDITOR.dom.text( definition.title, CKEDITOR.document ) ).appendTo( this.parts.title );
     497                ( new CKEDITOR.dom.text( definition.title, this._.document ) ).appendTo( this.parts.title );
    497498
    498499                // Insert the tabs and contents.
    499500                for ( var i = 0 ; i < definition.contents.length ; i++ )
     
    535536
    536537                for ( i = 0 ; i < buttons.length ; i++ )
    537538                        this._.buttons[ buttons[i].id ] = buttons[i];
     539                       
     540                editor.fire( 'dialogReady', this );
    538541        };
    539542
    540543        // Focusable interface. Use it via dialog.addFocusable.
     
    652655                                // If not fixed positioned, add scroll position to the coordinates.
    653656                                if ( !isFixed )
    654657                                {
    655                                         var scrollPosition = CKEDITOR.document.getWindow().getScrollPosition();
     658                                        var scrollPosition = this._.document.getWindow().getScrollPosition();
    656659                                        x += scrollPosition.x;
    657660                                        y += scrollPosition.y;
    658661                                }
     
    688691                        }
    689692
    690693                        // Insert the dialog's element to the root document.
    691                         var element = this._.element;
     694                        var element = this._.element,
     695                                doc = this._.document,
     696                                dialogParentElement = doc.getBody();
     697
    692698                        var definition = this.definition;
    693                         if ( !( element.getParent() && element.getParent().equals( CKEDITOR.document.getBody() ) ) )
    694                                 element.appendTo( CKEDITOR.document.getBody() );
     699                        if ( !dialogParentElement.equals( element.getParent() ) )
     700                                element.appendTo( dialogParentElement );
    695701                        else
    696702                                element.setStyle( 'display', 'block' );
    697703
     
    756762                        // Rearrange the dialog to the middle of the window.
    757763                        CKEDITOR.tools.setTimeout( function()
    758764                                {
    759                                         var viewSize = CKEDITOR.document.getWindow().getViewPaneSize();
     765                                        var viewSize = this._.document.getWindow().getViewPaneSize();
    760766                                        var dialogSize = this.getSize();
    761767
    762768                                        // We're using definition size for initial position because of
     
    15991605                function mouseMoveHandler( evt )
    16001606                {
    16011607                        var dialogSize = dialog.getSize(),
    1602                                 viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(),
     1608                                viewPaneSize = dialog._.document.getWindow().getViewPaneSize(),
    16031609                                x = evt.data.$.screenX,
    16041610                                y = evt.data.$.screenY,
    16051611                                dx = x - lastCoords.x,
     
    16311637
    16321638                function mouseUpHandler( evt )
    16331639                {
    1634                         CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler );
    1635                         CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler );
     1640                        this.removeListener( 'mousemove', mouseMoveHandler );
     1641                        this.removeListener( 'mouseup', mouseUpHandler );
    16361642
    16371643                        if ( CKEDITOR.env.ie6Compat )
    16381644                        {
     
    16481654
    16491655                                lastCoords = { x : evt.data.$.screenX, y : evt.data.$.screenY };
    16501656
    1651                                 CKEDITOR.document.on( 'mousemove', mouseMoveHandler );
    1652                                 CKEDITOR.document.on( 'mouseup', mouseUpHandler );
     1657                                this._.document.on( 'mousemove', mouseMoveHandler );
     1658                                this._.document.on( 'mouseup', mouseUpHandler );
    16531659                                abstractDialogCoords = dialog.getPosition();
    16541660
    16551661                                if ( CKEDITOR.env.ie6Compat )
     
    17261732                                y = evt.data.$.screenY,
    17271733                                dx = x - lastCoords.x,
    17281734                                dy = y - lastCoords.y,
    1729                                 viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(),
     1735                                viewPaneSize = dialog._.document.getWindow().getViewPaneSize(),
    17301736                                partName = evt.listenerData.part;
    17311737
    17321738                        if ( partName.search( 't' ) != -1 )
     
    17781784
    17791785                function mouseUpHandler( evt )
    17801786                {
    1781                         CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler );
    1782                         CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler );
     1787                        this._.document.removeListener( 'mouseup', mouseUpHandler );
     1788                        this._.document.removeListener( 'mousemove', mouseMoveHandler );
    17831789
    17841790                        if ( CKEDITOR.env.ie6Compat )
    17851791                        {
     
    18111817        // on screen.
    18121818        var covers = {},
    18131819                currentCover;
     1820               
     1821        var win = new CKEDITOR.dom.window( top );
    18141822
    18151823        function showCover( editor )
    18161824        {
    1817                 var win = CKEDITOR.document.getWindow();
     1825
    18181826                var config = editor.config,
    18191827                        backgroundColorStyle = config.dialog_backgroundCoverColor || 'white',
    18201828                        backgroundCoverOpacity = config.dialog_backgroundCoverOpacity,
     
    18721880                        coverElement = CKEDITOR.dom.element.createFromHtml( html.join( '' ) );
    18731881                        coverElement.setOpacity( backgroundCoverOpacity != undefined ? backgroundCoverOpacity : 0.5 );
    18741882
    1875                         coverElement.appendTo( CKEDITOR.document.getBody() );
     1883                        coverElement.appendTo( new CKEDITOR.dom.element( win.$.document.body ) );
    18761884                        covers[ coverKey ] = coverElement;
    18771885                }
    18781886                else
     
    19321940                if ( !currentCover )
    19331941                        return;
    19341942
    1935                 var win = CKEDITOR.document.getWindow();
     1943
    19361944                currentCover.hide();
    19371945                win.removeListener( 'resize', resizeCover );
    19381946
     
    23642372                 */
    23652373                getElement : function()
    23662374                {
    2367                         return CKEDITOR.document.getById( this.domId );
     2375                        return this._.dialog._.document.getById( this.domId );
    23682376                },
    23692377
    23702378                /**
     
    29102918                                throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' );
    29112919
    29122920                        // Not loaded? Load the .js file first.
    2913                         var body = CKEDITOR.document.getBody(),
     2921                        var body = new CKEDITOR.dom.element( top.document.body ),
    29142922                                cursor = body.$.style.cursor,
    29152923                                me = this;
    29162924
  • _source/plugins/menu/plugin.js

     
    150150                                // Create the floating panel for this menu.
    151151                                if ( !panel )
    152152                                {
     153                                        // Calculate whether we are using shared spaces
     154                                        var targetDoc, sharedConfig = editor.config.sharedSpaces;
     155                                        sharedConfig = sharedConfig && sharedConfig[ 'top' ];
     156                                       
     157                                        if ( sharedConfig )
     158                                        {
     159                                                // Retrieve the element id/location from the setting.
     160                                                var element = sharedConfig.match( /^(?:(?:(.+?)\((\w+)\))|(.+))$/ );
     161                                       
     162                                                // If the group 2 is defined, we have the target syntax.
     163                                                if ( element[ 2 ] )     
     164                                                {
     165                                                        var targetWindow = window,
     166                                                                targetWindowParts = element[ 1 ].split( '.' ) ;
     167                       
     168                                                        while ( targetWindowParts.length )
     169                                                        {
     170                                                                var part = targetWindowParts.shift() ;
     171                                                                if ( part.length > 0 )
     172                                                                        targetWindow = targetWindow[ part ] ;
     173                                                        }
     174                                                       
     175                                                        if ( targetWindow )
     176                                                        {
     177                                                                targetDoc = new CKEDITOR.dom.document( targetWindow.document );
     178                                                        }
     179                                                }
     180                                        }
     181                                        if(!targetDoc)
     182                                                targetDoc = CKEDITOR.document;
     183                                        //doc = new CKEDITOR.dom.document( top.document );
     184
    153185                                        panel = this._.panel = new CKEDITOR.ui.floatPanel( this.editor,
    154                                                 CKEDITOR.document.getBody(),
     186                                                targetDoc.getBody(),
    155187                                                this._.panelDefinition,
    156188                                                this._.level );
    157189
  • _source/plugins/panelbutton/plugin.js

     
    9494
    9595                                var panelDefinition = this._.panelDefinition || {},
    9696                                        panelBlockDefinition = this._.panelDefinition.block,
    97                                         panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
     97                                        panelParentElement = panelDefinition.parent || this.getElement().getDocument().getBody(),
    9898                                        panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),
    9999                                        block = panel.addBlock( _.id, panelBlockDefinition ),
    100100                                        me = this;
     
    139139                                                _.on = 0;
    140140                                                me.setState( CKEDITOR.TRISTATE_OFF );
    141141                                        };
     142                        },
     143
     144                        getElement : function()
     145                        {
     146                                return this.document.getById( this._.id );
    142147                        }
    143148                }
    144149        });
  • _source/plugins/richcombo/plugin.js

     
    219219
    220220                        var panelDefinition = this._.panelDefinition,
    221221                                panelBlockDefinition = this._.panelDefinition.block,
    222                                 panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
     222                                panelParentElement = panelDefinition.parent || this.getElement().getDocument().getBody();
    223223                                panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),
    224224                                list = panel.addListBlock( this.id, panelBlockDefinition ),
    225225                                me = this;
     
    289289                                this.init();
    290290                },
    291291
     292                getElement : function()
     293                {
     294                        return this.document.getById( 'cke_' + this.id );
     295                },
     296               
    292297                setValue : function( value, text )
    293298                {
    294299                        this._.value = value;
  • _source/themes/default/theme.js

     
    1313        function checkSharedSpace( editor, spaceName )
    1414        {
    1515                var container,
    16                         element;
     16                        sharedConfig = editor.config.sharedSpaces;
    1717
    18                 // Try to retrieve the target element from the sharedSpaces settings.
    19                 element = editor.config.sharedSpaces;
    20                 element = element && element[ spaceName ];
    21                 element = element && CKEDITOR.document.getById( element );
    22 
    23                 // If the element is available, we'll then create the container for
    24                 // the space.
    25                 if ( element )
     18                sharedConfig = sharedConfig && sharedConfig[ spaceName ];
     19               
     20                if ( sharedConfig )
    2621                {
    27                         // Creates an HTML structure that reproduces the editor class hierarchy.
    28                         var html =
    29                                 '<span class="cke_shared">' +
    30                                 '<span class="' + editor.skinClass + ' ' + editor.id + ' cke_editor_' + editor.name + '">' +
    31                                 '<span class="' + CKEDITOR.env.cssClass + '">' +
    32                                 '<span class="cke_wrapper cke_' + editor.lang.dir + '">' +
    33                                 '<span class="cke_editor">' +
    34                                 '<div class="cke_' + spaceName + '">' +
    35                                 '</div></span></span></span></span></span>';
     22                        // Retrieve the element id/location from the setting.
     23                        var element = sharedConfig.match( /^(?:(?:(.+?)\((\w+)\))|(.+))$/ );
    3624
    37                         var mainContainer = element.append( CKEDITOR.dom.element.createFromHtml( html, element.getDocument() ) );
     25                        // If the group 3 is defined, we have the "elementId" syntax.
     26                        if ( element[ 3 ] )     
     27                                element = CKEDITOR.document.getById( element[ 3 ] );
     28                        // Otherwise we have "windowName(elementId)".
     29                        else                                   
     30                        {
     31                                var targetWindow = window,
     32                                        targetDoc,
     33                                        targetWindowParts = element[ 1 ].split( '.' ) ;
    3834
    39                         // Only the first container starts visible. Others get hidden.
    40                         if ( element.getCustomData( 'cke_hasshared' ) )
    41                                 mainContainer.hide();
    42                         else
    43                                 element.setCustomData( 'cke_hasshared', 1 );
     35                                while ( targetWindowParts.length )
     36                                {
     37                                        var part = targetWindowParts.shift() ;
     38                                        if ( part.length > 0 )
     39                                                targetWindow = targetWindow[ part ] ;
     40                                }
     41                               
     42                                if ( targetWindow )
     43                                {
     44                                        targetDoc = new CKEDITOR.dom.document( targetWindow.document );
     45                                        targetWindow = new CKEDITOR.dom.window( targetWindow );
    4446
    45                         // Get the deeper inner <div>.
    46                         container = mainContainer.getChild( [0,0,0,0] );
     47                                        // Get the element in the target.
     48                                        element = targetDoc.getById( element[ 2 ] );
     49                                       
     50                                        if ( element )
     51                                        {
     52                                                // Bridge the CKEDITOR object.
     53                                                targetWindow.$.CKEDITOR = CKEDITOR;
    4754
    48                         // When the editor gets focus, we show the space container, hiding others.
    49                         editor.on( 'focus', function()
    50                                 {
    51                                         for ( var i = 0, sibling, children = element.getChildren() ; ( sibling = children.getItem( i ) ) ; i++ )
    52                                         {
    53                                                 if ( sibling.type == CKEDITOR.NODE_ELEMENT
    54                                                         && !sibling.equals( mainContainer )
    55                                                         && sibling.hasClass( 'cke_shared' ) )
     55                                                if ( !targetWindow.getCustomData( 'cke_getById' ) )
    5656                                                {
    57                                                         sibling.hide();
     57                                                        // Expand element finding scope to include target document.
     58                                                        CKEDITOR.document.getById = CKEDITOR.tools.override( CKEDITOR.document.getById,
     59                                                                function( originalGetById )
     60                                                                {
     61                                                                        return function( id )
     62                                                                        {
     63                                                                                return originalGetById.call( this, id ) || targetDoc.getById( id );
     64                                                                        }
     65                                                                });
     66                                                       
     67                                                        targetWindow.setCustomData( 'cke_getById', 1 );
    5868                                                }
     69                                               
     70                                                var skinName = editor.skinName ;
     71                                                if ( !targetWindow.getCustomData( 'cke_skin' + skinName + '_editor' ) )
     72                                                {
     73                                                        // Loads editor skin part into target window.
     74                                                        var part = CKEDITOR.skins[ skinName ].editor;
     75                                                        for ( var c = 0 ; c < part.css.length ; c++ )
     76                                                                targetDoc.appendStyleSheet( part.css[ c ] );
     77                                                       
     78                                                        targetWindow.setCustomData( 'cke_skin' + skinName, 1 );
     79                                                }
    5980                                        }
     81                                }
     82                        }
     83               
     84               
     85       
     86                        // If the element is available, we'll then create the container for
     87                        // the space.                   
     88                        if ( element )
     89                        {       
     90                                // On first editor make sure space is empty. If using an IFrame there may be left over toolbars
     91                                // TODO: This could probably be done better elsewhere.
     92                                if(!CKEDITOR.loading){
     93                                        element.$.innerHTML = "";
     94                                        CKEDITOR.loading = true;
     95                                }
     96                       
     97                                // Creates an HTML structure that reproduces the editor class hierarchy.
     98                                var html =
     99                                        '<span class="cke_shared">' +
     100                                        '<span class="' + editor.skinClass + ' cke_editor_' + editor.name + '">' +
     101                                        '<span class="' + CKEDITOR.env.cssClass + '">' +
     102                                        '<span class="cke_wrapper cke_' + editor.lang.dir + '">' +
     103                                        '<span class="cke_editor">' +
     104                                        '<div class="cke_' + spaceName + '">' +
     105                                        '</div></span></span></span></span></span>';
    60106
    61                                         mainContainer.show();
    62                                 });
     107                                var mainContainer = element.append( CKEDITOR.dom.element.createFromHtml( html, element.getDocument() ) );
    63108
    64                         editor.on( 'destroy', function()
    65                                 {
    66                                         mainContainer.remove();
    67                                 });
     109                                // Only the first container starts visible. Others get hidden.
     110                                if ( element.getCustomData( 'cke_hasshared' ) )
     111                                        mainContainer.hide( );
     112                                else
     113                                        element.setCustomData( 'cke_hasshared', 1 );
     114
     115                               
     116
     117                                // Get the deeper inner <div>.
     118                                container = mainContainer.getChild( [0,0,0,0] );
     119
     120                                // When the editor gets focus, we show the space container, hiding others.
     121                                editor.on( 'focus', function()
     122                                        {
     123                                                for ( var i = 0, sibling, children = element.getChildren() ; ( sibling = children.getItem( i ) ) ; i++ )
     124                                                {
     125                                                        if ( sibling.type == CKEDITOR.NODE_ELEMENT
     126                                                                && !sibling.equals( mainContainer )
     127                                                                && sibling.hasClass( 'cke_shared' ) )
     128                                                        {
     129                                                                sibling.hide();
     130                                                        }
     131                                                }
     132
     133                                                mainContainer.show();
     134                                        });
     135
     136                                editor.on( 'destroy', function()
     137                                        {
     138                                                mainContainer.remove();
     139                                        });
     140                        }
    68141                }
    69142
    70143                return container;
     
    168241
    169242                buildDialog : function( editor )
    170243                {
     244                        var skinName = editor.skinName;
     245
     246                        editor.on( 'dialogReady', function( evt )
     247                        {
     248                                var dialog = evt.data,
     249                                        dialogDoc = dialog._.document,
     250                                        targetWin = dialogDoc.getWindow();
     251
     252                                if( !( targetWin.equals( CKEDITOR.document.getWindow() )
     253                                           || targetWin.getCustomData( 'cke_skin' + skinName + '_dialog') ) )
     254                                {
     255                                        // Loads dialog skin part into dialog living window.
     256                                        var part = CKEDITOR.skins[ skinName ].dialog;
     257                                        for ( var c = 0 ; c < part.css.length ; c++ )
     258                                                dialogDoc.appendStyleSheet( part.css[ c ] );
     259                                }
     260                        } );
     261
     262                       
    171263                        var baseIdNumber = CKEDITOR.tools.getNextNumber();
    172264
    173265                        var element = CKEDITOR.dom.element.createFromHtml( [
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy