Ticket #4228: shared_spaces_iframe 3.4.3.patch
File shared_spaces_iframe 3.4.3.patch, 17.8 KB (added by , 13 years ago) |
---|
-
_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 <!-- 3 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 4 For 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 12 iframe 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
23 23 var loadPart = function( editor, skinName, part, callback ) 24 24 { 25 25 // Get the skin definition. 26 var skinDefinition = loaded[ skinName ];26 var skinDefinition = CKEDITOR.skins[ skinName ] = loaded[ skinName ]; 27 27 28 28 if ( !editor.skin ) 29 29 { -
_source/plugins/dialog/plugin.js
118 118 definition = new definitionObject( this, definition ); 119 119 120 120 121 var doc = CKEDITOR.document;121 //var doc = CKEDITOR.document; 122 122 123 123 var themeBuilt = editor.theme.buildDialog( editor ); 124 124 … … 126 126 this._ = 127 127 { 128 128 editor : editor, 129 document : new CKEDITOR.dom.document( top.document ), 129 130 element : themeBuilt.element, 130 131 name : dialogName, 131 132 contentSize : { width : 0, height : 0 }, … … 401 402 processed && evt.data.preventDefault(); 402 403 } 403 404 404 var dialogElement = this._. element;405 var dialogElement = this._.document;//this._.element; 405 406 // Add the dialog keyboard handlers. 406 407 this.on( 'show', function() 407 408 { … … 493 494 initResizeHandles( this ); 494 495 495 496 // 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 ); 497 498 498 499 // Insert the tabs and contents. 499 500 for ( var i = 0 ; i < definition.contents.length ; i++ ) … … 535 536 536 537 for ( i = 0 ; i < buttons.length ; i++ ) 537 538 this._.buttons[ buttons[i].id ] = buttons[i]; 539 540 editor.fire( 'dialogReady', this ); 538 541 }; 539 542 540 543 // Focusable interface. Use it via dialog.addFocusable. … … 652 655 // If not fixed positioned, add scroll position to the coordinates. 653 656 if ( !isFixed ) 654 657 { 655 var scrollPosition = CKEDITOR.document.getWindow().getScrollPosition();658 var scrollPosition = this._.document.getWindow().getScrollPosition(); 656 659 x += scrollPosition.x; 657 660 y += scrollPosition.y; 658 661 } … … 688 691 } 689 692 690 693 // 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 692 698 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 ); 695 701 else 696 702 element.setStyle( 'display', 'block' ); 697 703 … … 756 762 // Rearrange the dialog to the middle of the window. 757 763 CKEDITOR.tools.setTimeout( function() 758 764 { 759 var viewSize = CKEDITOR.document.getWindow().getViewPaneSize();765 var viewSize = this._.document.getWindow().getViewPaneSize(); 760 766 var dialogSize = this.getSize(); 761 767 762 768 // We're using definition size for initial position because of … … 1599 1605 function mouseMoveHandler( evt ) 1600 1606 { 1601 1607 var dialogSize = dialog.getSize(), 1602 viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(),1608 viewPaneSize = dialog._.document.getWindow().getViewPaneSize(), 1603 1609 x = evt.data.$.screenX, 1604 1610 y = evt.data.$.screenY, 1605 1611 dx = x - lastCoords.x, … … 1631 1637 1632 1638 function mouseUpHandler( evt ) 1633 1639 { 1634 CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler );1635 CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler );1640 this.removeListener( 'mousemove', mouseMoveHandler ); 1641 this.removeListener( 'mouseup', mouseUpHandler ); 1636 1642 1637 1643 if ( CKEDITOR.env.ie6Compat ) 1638 1644 { … … 1648 1654 1649 1655 lastCoords = { x : evt.data.$.screenX, y : evt.data.$.screenY }; 1650 1656 1651 CKEDITOR.document.on( 'mousemove', mouseMoveHandler );1652 CKEDITOR.document.on( 'mouseup', mouseUpHandler );1657 this._.document.on( 'mousemove', mouseMoveHandler ); 1658 this._.document.on( 'mouseup', mouseUpHandler ); 1653 1659 abstractDialogCoords = dialog.getPosition(); 1654 1660 1655 1661 if ( CKEDITOR.env.ie6Compat ) … … 1726 1732 y = evt.data.$.screenY, 1727 1733 dx = x - lastCoords.x, 1728 1734 dy = y - lastCoords.y, 1729 viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(),1735 viewPaneSize = dialog._.document.getWindow().getViewPaneSize(), 1730 1736 partName = evt.listenerData.part; 1731 1737 1732 1738 if ( partName.search( 't' ) != -1 ) … … 1778 1784 1779 1785 function mouseUpHandler( evt ) 1780 1786 { 1781 CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler );1782 CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler );1787 this._.document.removeListener( 'mouseup', mouseUpHandler ); 1788 this._.document.removeListener( 'mousemove', mouseMoveHandler ); 1783 1789 1784 1790 if ( CKEDITOR.env.ie6Compat ) 1785 1791 { … … 1811 1817 // on screen. 1812 1818 var covers = {}, 1813 1819 currentCover; 1820 1821 var win = new CKEDITOR.dom.window( top ); 1814 1822 1815 1823 function showCover( editor ) 1816 1824 { 1817 var win = CKEDITOR.document.getWindow(); 1825 1818 1826 var config = editor.config, 1819 1827 backgroundColorStyle = config.dialog_backgroundCoverColor || 'white', 1820 1828 backgroundCoverOpacity = config.dialog_backgroundCoverOpacity, … … 1872 1880 coverElement = CKEDITOR.dom.element.createFromHtml( html.join( '' ) ); 1873 1881 coverElement.setOpacity( backgroundCoverOpacity != undefined ? backgroundCoverOpacity : 0.5 ); 1874 1882 1875 coverElement.appendTo( CKEDITOR.document.getBody() );1883 coverElement.appendTo( new CKEDITOR.dom.element( win.$.document.body ) ); 1876 1884 covers[ coverKey ] = coverElement; 1877 1885 } 1878 1886 else … … 1932 1940 if ( !currentCover ) 1933 1941 return; 1934 1942 1935 var win = CKEDITOR.document.getWindow(); 1943 1936 1944 currentCover.hide(); 1937 1945 win.removeListener( 'resize', resizeCover ); 1938 1946 … … 2364 2372 */ 2365 2373 getElement : function() 2366 2374 { 2367 return CKEDITOR.document.getById( this.domId );2375 return this._.dialog._.document.getById( this.domId ); 2368 2376 }, 2369 2377 2370 2378 /** … … 2910 2918 throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' ); 2911 2919 2912 2920 // Not loaded? Load the .js file first. 2913 var body = CKEDITOR.document.getBody(),2921 var body = new CKEDITOR.dom.element( top.document.body ), 2914 2922 cursor = body.$.style.cursor, 2915 2923 me = this; 2916 2924 -
_source/plugins/menu/plugin.js
150 150 // Create the floating panel for this menu. 151 151 if ( !panel ) 152 152 { 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 153 185 panel = this._.panel = new CKEDITOR.ui.floatPanel( this.editor, 154 CKEDITOR.document.getBody(),186 targetDoc.getBody(), 155 187 this._.panelDefinition, 156 188 this._.level ); 157 189 -
_source/plugins/panelbutton/plugin.js
94 94 95 95 var panelDefinition = this._.panelDefinition || {}, 96 96 panelBlockDefinition = this._.panelDefinition.block, 97 panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),97 panelParentElement = panelDefinition.parent || this.getElement().getDocument().getBody(), 98 98 panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ), 99 99 block = panel.addBlock( _.id, panelBlockDefinition ), 100 100 me = this; … … 139 139 _.on = 0; 140 140 me.setState( CKEDITOR.TRISTATE_OFF ); 141 141 }; 142 }, 143 144 getElement : function() 145 { 146 return this.document.getById( this._.id ); 142 147 } 143 148 } 144 149 }); -
_source/plugins/richcombo/plugin.js
219 219 220 220 var panelDefinition = this._.panelDefinition, 221 221 panelBlockDefinition = this._.panelDefinition.block, 222 panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),222 panelParentElement = panelDefinition.parent || this.getElement().getDocument().getBody(); 223 223 panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ), 224 224 list = panel.addListBlock( this.id, panelBlockDefinition ), 225 225 me = this; … … 289 289 this.init(); 290 290 }, 291 291 292 getElement : function() 293 { 294 return this.document.getById( 'cke_' + this.id ); 295 }, 296 292 297 setValue : function( value, text ) 293 298 { 294 299 this._.value = value; -
_source/themes/default/theme.js
13 13 function checkSharedSpace( editor, spaceName ) 14 14 { 15 15 var container, 16 element;16 sharedConfig = editor.config.sharedSpaces; 17 17 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 ) 26 21 { 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+)\))|(.+))$/ ); 36 24 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( '.' ) ; 38 34 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 ); 44 46 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; 47 54 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' ) ) 56 56 { 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 ); 58 68 } 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 } 59 80 } 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>'; 60 106 61 mainContainer.show(); 62 }); 107 var mainContainer = element.append( CKEDITOR.dom.element.createFromHtml( html, element.getDocument() ) ); 63 108 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 } 68 141 } 69 142 70 143 return container; … … 168 241 169 242 buildDialog : function( editor ) 170 243 { 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 171 263 var baseIdNumber = CKEDITOR.tools.getNextNumber(); 172 264 173 265 var element = CKEDITOR.dom.element.createFromHtml( [