JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0.1
[ckeditor.git] / _source / plugins / wysiwygarea / plugin.js
1 /*\r
2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license\r
4 */\r
5 \r
6 /**\r
7  * @fileOverview The "wysiwygarea" plugin. It registers the "wysiwyg" editing\r
8  *              mode, which handles the main editing area space.\r
9  */\r
10 \r
11 (function()\r
12 {\r
13         /**\r
14          * List of elements in which has no way to move editing focus outside.\r
15          */\r
16         var nonExitableElementNames = { table:1,pre:1 };\r
17         // Matching an empty paragraph at the end of document.\r
18         var emptyParagraphRegexp = /\s*<(p|div|address|h\d|center)[^>]*>\s*(?:<br[^>]*>|&nbsp;|&#160;)\s*(:?<\/\1>)?\s*$/gi;\r
19 \r
20         function onInsertHtml( evt )\r
21         {\r
22                 if ( this.mode == 'wysiwyg' )\r
23                 {\r
24                         this.focus();\r
25 \r
26                         var selection = this.getSelection(),\r
27                                 data = evt.data;\r
28 \r
29                         if ( this.dataProcessor )\r
30                                 data = this.dataProcessor.toHtml( data );\r
31 \r
32                         if ( CKEDITOR.env.ie )\r
33                         {\r
34                                 var selIsLocked = selection.isLocked;\r
35 \r
36                                 if ( selIsLocked )\r
37                                         selection.unlock();\r
38 \r
39                                 var $sel = selection.getNative();\r
40                                 if ( $sel.type == 'Control' )\r
41                                         $sel.clear();\r
42                                 $sel.createRange().pasteHTML( data );\r
43 \r
44                                 if ( selIsLocked )\r
45                                         this.getSelection().lock();\r
46                         }\r
47                         else\r
48                                 this.document.$.execCommand( 'inserthtml', false, data );\r
49                 }\r
50         }\r
51 \r
52         function onInsertElement( evt )\r
53         {\r
54                 if ( this.mode == 'wysiwyg' )\r
55                 {\r
56                         this.focus();\r
57                         this.fire( 'saveSnapshot' );\r
58 \r
59                         var element = evt.data,\r
60                                 elementName = element.getName(),\r
61                                 isBlock = CKEDITOR.dtd.$block[ elementName ];\r
62 \r
63                         var selection = this.getSelection(),\r
64                                 ranges = selection.getRanges();\r
65 \r
66                         var selIsLocked = selection.isLocked;\r
67 \r
68                         if ( selIsLocked )\r
69                                 selection.unlock();\r
70 \r
71                         var range, clone, lastElement, bookmark;\r
72 \r
73                         for ( var i = ranges.length - 1 ; i >= 0 ; i-- )\r
74                         {\r
75                                 range = ranges[ i ];\r
76 \r
77                                 // Remove the original contents.\r
78                                 range.deleteContents();\r
79 \r
80                                 clone = !i && element || element.clone( true );\r
81 \r
82                                 // If we're inserting a block at dtd-violated position, split\r
83                                 // the parent blocks until we reach blockLimit.\r
84                                 var current, dtd;\r
85                                 if ( isBlock )\r
86                                 {\r
87                                         while( ( current = range.getCommonAncestor( false, true ) )\r
88                                                         && ( dtd = CKEDITOR.dtd[ current.getName() ] )\r
89                                                         && !( dtd && dtd [ elementName ] ) )\r
90                                         {\r
91                                                 // If we're in an empty block which indicate a new paragraph,\r
92                                                 // simply replace it with the inserting block.(#3664)\r
93                                                 if ( range.checkStartOfBlock()\r
94                                                          && range.checkEndOfBlock() )\r
95                                                 {\r
96                                                         range.setStartBefore( current );\r
97                                                         range.collapse( true );\r
98                                                         current.remove();\r
99                                                 }\r
100                                                 else\r
101                                                         range.splitBlock();\r
102                                         }\r
103                                 }\r
104 \r
105                                 // Insert the new node.\r
106                                 range.insertNode( clone );\r
107 \r
108                                 // Save the last element reference so we can make the\r
109                                 // selection later.\r
110                                 if ( !lastElement )\r
111                                         lastElement = clone;\r
112                         }\r
113 \r
114                         range.moveToPosition( lastElement, CKEDITOR.POSITION_AFTER_END );\r
115 \r
116                         var next = lastElement.getNextSourceNode( true );\r
117                         if ( next && next.type == CKEDITOR.NODE_ELEMENT )\r
118                                 range.moveToElementEditStart( next );\r
119 \r
120                         selection.selectRanges( [ range ] );\r
121 \r
122                         if ( selIsLocked )\r
123                                 this.getSelection().lock();\r
124 \r
125                         // Save snaps after the whole execution completed.\r
126                         // This's a workaround for make DOM modification's happened after\r
127                         // 'insertElement' to be included either, e.g. Form-based dialogs' 'commitContents'\r
128                         // call.\r
129                         CKEDITOR.tools.setTimeout( function(){\r
130                                 this.fire( 'saveSnapshot' );\r
131                         }, 0, this );\r
132                 }\r
133         }\r
134 \r
135         // DOM modification here should not bother dirty flag.(#4385)\r
136         function restoreDirty( editor )\r
137         {\r
138                 if( !editor.checkDirty() )\r
139                         setTimeout( function(){ editor.resetDirty(); } );\r
140         }\r
141 \r
142         /**\r
143          *  Auto-fixing block-less content by wrapping paragraph (#3190), prevent\r
144          *  non-exitable-block by padding extra br.(#3189)\r
145          */\r
146         function onSelectionChangeFixBody( evt )\r
147         {\r
148                 var editor = evt.editor,\r
149                         path = evt.data.path,\r
150                         blockLimit = path.blockLimit,\r
151                         selection = evt.data.selection,\r
152                         range = selection.getRanges()[0],\r
153                         body = editor.document.getBody(),\r
154                         enterMode = editor.config.enterMode;\r
155 \r
156                 // When enterMode set to block, we'll establing new paragraph only if we're\r
157                 // selecting inline contents right under body. (#3657)\r
158                 if ( enterMode != CKEDITOR.ENTER_BR\r
159                      && range.collapsed\r
160                          && blockLimit.getName() == 'body'\r
161                          && !path.block )\r
162                 {\r
163                         restoreDirty( editor );\r
164                         var bms = selection.createBookmarks(),\r
165                                 fixedBlock = range.fixBlock( true,\r
166                                         editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p'  );\r
167 \r
168                         // For IE, we'll be removing any bogus br ( introduce by fixing body )\r
169                         // right now to prevent it introducing visual line break.\r
170                         if ( CKEDITOR.env.ie )\r
171                         {\r
172                                 var brNodeList = fixedBlock.getElementsByTag( 'br' ), brNode;\r
173                                 for ( var i = 0 ; i < brNodeList.count() ; i++ )\r
174                                 {\r
175                                         if( ( brNode = brNodeList.getItem( i ) ) && brNode.hasAttribute( '_cke_bogus' ) )\r
176                                                 brNode.remove();\r
177                                 }\r
178                         }\r
179 \r
180                         selection.selectBookmarks( bms );\r
181 \r
182                         // If the fixed block is blank and is already followed by a exitable\r
183                         // block, we should drop it and move to the exist block(#3684).\r
184                         var children = fixedBlock.getChildren(),\r
185                                 count = children.count(),\r
186                                 firstChild,\r
187                                 whitespaceGuard = CKEDITOR.dom.walker.whitespaces( true ),\r
188                                 previousElement = fixedBlock.getPrevious( whitespaceGuard ),\r
189                                 nextElement = fixedBlock.getNext( whitespaceGuard ),\r
190                                 enterBlock;\r
191                         if ( previousElement && previousElement.getName\r
192                                  && !( previousElement.getName() in nonExitableElementNames ) )\r
193                                 enterBlock = previousElement;\r
194                         else if ( nextElement && nextElement.getName\r
195                                           && !( nextElement.getName() in nonExitableElementNames ) )\r
196                                 enterBlock = nextElement;\r
197 \r
198                         // Not all blocks are editable, e.g. <hr />, further checking it.(#3994)\r
199                         if( ( !count\r
200                                   || ( firstChild = children.getItem( 0 ) ) && firstChild.is && firstChild.is( 'br' ) )\r
201                                 && enterBlock\r
202                                 && range.moveToElementEditStart( enterBlock ) )\r
203                         {\r
204                                 fixedBlock.remove();\r
205                                 range.select();\r
206                         }\r
207                 }\r
208 \r
209                 // Inserting the padding-br before body if it's preceded by an\r
210                 // unexitable block.\r
211                 var lastNode = body.getLast( CKEDITOR.dom.walker.whitespaces( true ) );\r
212                 if ( lastNode && lastNode.getName && ( lastNode.getName() in nonExitableElementNames ) )\r
213                 {\r
214                         restoreDirty( editor );\r
215                         var paddingBlock = editor.document.createElement(\r
216                                         ( CKEDITOR.env.ie && enterMode != CKEDITOR.ENTER_BR ) ?\r
217                                                 '<br _cke_bogus="true" />' : 'br' );\r
218                         body.append( paddingBlock );\r
219                 }\r
220         }\r
221 \r
222         CKEDITOR.plugins.add( 'wysiwygarea',\r
223         {\r
224                 requires : [ 'editingblock' ],\r
225 \r
226                 init : function( editor )\r
227                 {\r
228                         var fixForBody = ( editor.config.enterMode != CKEDITOR.ENTER_BR )\r
229                                 ? editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' : false;\r
230 \r
231                         editor.on( 'editingBlockReady', function()\r
232                                 {\r
233                                         var mainElement,\r
234                                                 fieldset,\r
235                                                 iframe,\r
236                                                 isLoadingData,\r
237                                                 isPendingFocus,\r
238                                                 frameLoaded,\r
239                                                 fireMode;\r
240 \r
241                                         // Support for custom document.domain in IE.\r
242                                         var isCustomDomain = CKEDITOR.env.isCustomDomain();\r
243 \r
244                                         // Creates the iframe that holds the editable document.\r
245                                         var createIFrame = function()\r
246                                         {\r
247                                                 if ( iframe )\r
248                                                         iframe.remove();\r
249                                                 if ( fieldset )\r
250                                                         fieldset.remove();\r
251 \r
252                                                 frameLoaded = 0;\r
253                                                 // The document domain must be set within the src\r
254                                                 // attribute;\r
255                                                 // Defer the script execution until iframe\r
256                                                 // has been added to main window, this is needed for some\r
257                                                 // browsers which will begin to load the frame content\r
258                                                 // prior to it's presentation in DOM.(#3894)\r
259                                                 var src = 'void( '\r
260                                                                 + ( CKEDITOR.env.gecko ? 'setTimeout' : '' ) + '( function(){' +\r
261                                                                 'document.open();' +\r
262                                                                 ( CKEDITOR.env.ie && isCustomDomain ? 'document.domain="' + document.domain + '";' : '' ) +\r
263                                                                 'document.write( window.parent[ "_cke_htmlToLoad_' + editor.name + '" ] );' +\r
264                                                                 'document.close();' +\r
265                                                                 'window.parent[ "_cke_htmlToLoad_' + editor.name + '" ] = null;' +\r
266                                                                 '}'\r
267                                                                 + ( CKEDITOR.env.gecko ? ', 0 )' : ')()' )\r
268                                                                 + ' )';\r
269 \r
270                                                 // Loading via src attribute does not work in Opera.\r
271                                                 if ( CKEDITOR.env.opera )\r
272                                                         src = 'void(0);';\r
273 \r
274                                                 iframe = CKEDITOR.dom.element.createFromHtml( '<iframe' +\r
275                                                                 ' style="width:100%;height:100%"' +\r
276                                                                 ' frameBorder="0"' +\r
277                                                                 ' tabIndex="-1"' +\r
278                                                                 ' allowTransparency="true"' +\r
279                                                                 ' src="javascript:' + encodeURIComponent( src ) + '"' +\r
280                                                                 '></iframe>' );\r
281 \r
282                                                 var accTitle = editor.lang.editorTitle.replace( '%1', editor.name );\r
283 \r
284                                                 if ( CKEDITOR.env.gecko )\r
285                                                 {\r
286                                                         // Double checking the iframe will be loaded properly(#4058).\r
287                                                         iframe.on( 'load', function( ev )\r
288                                                         {\r
289                                                                 ev.removeListener();\r
290                                                                 contentDomReady( iframe.$.contentWindow );\r
291                                                         } );\r
292 \r
293                                                         // Accessibility attributes for Firefox.\r
294                                                         mainElement.setAttributes(\r
295                                                                 {\r
296                                                                         role : 'region',\r
297                                                                         title : accTitle\r
298                                                                 } );\r
299                                                         iframe.setAttributes(\r
300                                                                 {\r
301                                                                         role : 'region',\r
302                                                                         title : ' '\r
303                                                                 } );\r
304                                                 }\r
305                                                 else if ( CKEDITOR.env.webkit )\r
306                                                 {\r
307                                                         iframe.setAttribute( 'title', accTitle );       // Safari 4\r
308                                                         iframe.setAttribute( 'name', accTitle );        // Safari 3\r
309                                                 }\r
310                                                 else if ( CKEDITOR.env.ie )\r
311                                                 {\r
312                                                         // Accessibility label for IE.\r
313                                                         fieldset = CKEDITOR.dom.element.createFromHtml(\r
314                                                                 '<fieldset style="height:100%' +\r
315                                                                 ( CKEDITOR.env.ie && CKEDITOR.env.quirks ? ';position:relative' : '' ) +\r
316                                                                 '">' +\r
317                                                                         '<legend style="display:block;width:0;height:0;overflow:hidden;' +\r
318                                                                         ( CKEDITOR.env.ie && CKEDITOR.env.quirks ? 'position:absolute' : '' ) +\r
319                                                                         '">' +\r
320                                                                                 CKEDITOR.tools.htmlEncode( accTitle ) +\r
321                                                                         '</legend>' +\r
322                                                                 '</fieldset>'\r
323                                                                 , CKEDITOR.document );\r
324                                                         iframe.appendTo( fieldset );\r
325                                                         fieldset.appendTo( mainElement );\r
326                                                 }\r
327 \r
328                                                 if ( !CKEDITOR.env.ie )\r
329                                                         mainElement.append( iframe );\r
330                                         };\r
331 \r
332                                         // The script that is appended to the data being loaded. It\r
333                                         // enables editing, and makes some\r
334                                         var activationScript =\r
335                                                 '<script id="cke_actscrpt" type="text/javascript">' +\r
336                                                         'window.onload = function()' +\r
337                                                         '{' +\r
338                                                                 // Call the temporary function for the editing\r
339                                                                 // boostrap.\r
340                                                                 'window.parent.CKEDITOR._["contentDomReady' + editor.name + '"]( window );' +\r
341                                                         '}' +\r
342                                                 '</script>';\r
343 \r
344                                         // Editing area bootstrap code.\r
345                                         var contentDomReady = function( domWindow )\r
346                                         {\r
347                                                 if ( frameLoaded )\r
348                                                         return;\r
349 \r
350                                                 frameLoaded = 1;\r
351 \r
352                                                 var domDocument = domWindow.document,\r
353                                                         body = domDocument.body;\r
354 \r
355                                                 // Remove this script from the DOM.\r
356                                                 var script = domDocument.getElementById( "cke_actscrpt" );\r
357                                                 script.parentNode.removeChild( script );\r
358 \r
359                                                 delete CKEDITOR._[ 'contentDomReady' + editor.name ];\r
360 \r
361                                                 body.spellcheck = !editor.config.disableNativeSpellChecker;\r
362 \r
363                                                 if ( CKEDITOR.env.ie )\r
364                                                 {\r
365                                                         // Don't display the focus border.\r
366                                                         body.hideFocus = true;\r
367 \r
368                                                         // Disable and re-enable the body to avoid IE from\r
369                                                         // taking the editing focus at startup. (#141 / #523)\r
370                                                         body.disabled = true;\r
371                                                         body.contentEditable = true;\r
372                                                         body.removeAttribute( 'disabled' );\r
373                                                 }\r
374                                                 else\r
375                                                         domDocument.designMode = 'on';\r
376 \r
377                                                 // IE, Opera and Safari may not support it and throw\r
378                                                 // errors.\r
379                                                 try { domDocument.execCommand( 'enableObjectResizing', false, !editor.config.disableObjectResizing ) ; } catch(e) {}\r
380                                                 try { domDocument.execCommand( 'enableInlineTableEditing', false, !editor.config.disableNativeTableHandles ) ; } catch(e) {}\r
381 \r
382                                                 domWindow       = editor.window         = new CKEDITOR.dom.window( domWindow );\r
383                                                 domDocument     = editor.document       = new CKEDITOR.dom.document( domDocument );\r
384 \r
385                                                 // Gecko/Webkit need some help when selecting control type elements. (#3448)\r
386                                                 if ( !( CKEDITOR.env.ie || CKEDITOR.env.opera) )\r
387                                                 {\r
388                                                         domDocument.on( 'mousedown', function( ev )\r
389                                                         {\r
390                                                                 var control = ev.data.getTarget();\r
391                                                                 if ( control.is( 'img', 'hr', 'input', 'textarea', 'select' ) )\r
392                                                                         editor.getSelection().selectElement( control );\r
393                                                         } );\r
394                                                 }\r
395 \r
396                                                 // Webkit: avoid from editing form control elements content.\r
397                                                 if ( CKEDITOR.env.webkit )\r
398                                                 {\r
399                                                         // Prevent from tick checkbox/radiobox/select\r
400                                                         domDocument.on( 'click', function( ev )\r
401                                                         {\r
402                                                                 if ( ev.data.getTarget().is( 'input', 'select' ) )\r
403                                                                         ev.data.preventDefault();\r
404                                                         } );\r
405 \r
406                                                         // Prevent from editig textfield/textarea value.\r
407                                                         domDocument.on( 'mouseup', function( ev )\r
408                                                         {\r
409                                                                 if ( ev.data.getTarget().is( 'input', 'textarea' ) )\r
410                                                                         ev.data.preventDefault();\r
411                                                         } );\r
412                                                 }\r
413 \r
414                                                 var focusTarget = ( CKEDITOR.env.ie || CKEDITOR.env.webkit ) ?\r
415                                                                 domWindow : domDocument;\r
416 \r
417                                                 focusTarget.on( 'blur', function()\r
418                                                         {\r
419                                                                 editor.focusManager.blur();\r
420                                                         });\r
421 \r
422                                                 focusTarget.on( 'focus', function()\r
423                                                         {\r
424                                                                 // Gecko need a key event to 'wake up' the editing\r
425                                                                 // ability when document is empty.(#3864)\r
426                                                                 if ( CKEDITOR.env.gecko )\r
427                                                                 {\r
428                                                                         var first = body;\r
429                                                                         while( first.firstChild )\r
430                                                                                 first = first.firstChild;\r
431 \r
432                                                                         if( !first.nextSibling\r
433                                                                                 && ( 'BR' == first.tagName )\r
434                                                                                 && first.hasAttribute( '_moz_editor_bogus_node' ) )\r
435                                                                         {\r
436                                                                                 var keyEventSimulate = domDocument.$.createEvent( "KeyEvents" );\r
437                                                                                 keyEventSimulate.initKeyEvent( 'keypress', true, true, domWindow.$, false,\r
438                                                                                         false, false, false, 0, 32 );\r
439                                                                                 domDocument.$.dispatchEvent( keyEventSimulate );\r
440                                                                                 var bogusText = domDocument.getBody().getFirst() ;\r
441                                                                                 // Compensate the line maintaining <br> if enterMode is not block.\r
442                                                                                 if ( editor.config.enterMode == CKEDITOR.ENTER_BR )\r
443                                                                                         domDocument.createElement( 'br', { attributes: { '_moz_dirty' : "" } } )\r
444                                                                                                 .replace( bogusText );\r
445                                                                                 else\r
446                                                                                         bogusText.remove();\r
447                                                                         }\r
448                                                                 }\r
449 \r
450                                                                 editor.focusManager.focus();\r
451                                                         });\r
452 \r
453                                                 var keystrokeHandler = editor.keystrokeHandler;\r
454                                                 if ( keystrokeHandler )\r
455                                                         keystrokeHandler.attach( domDocument );\r
456 \r
457                                                 // Cancel default action for backspace in IE on control types. (#4047)\r
458                                                 if ( CKEDITOR.env.ie )\r
459                                                 {\r
460                                                         editor.on( 'key', function( event )\r
461                                                         {\r
462                                                                 // Backspace.\r
463                                                                 var control = event.data.keyCode == 8\r
464                                                                                           && editor.getSelection().getSelectedElement();\r
465                                                                 if ( control )\r
466                                                                 {\r
467                                                                         // Make undo snapshot.\r
468                                                                         editor.fire( 'saveSnapshot' );\r
469                                                                         // Remove manually.\r
470                                                                         control.remove();\r
471                                                                         editor.fire( 'saveSnapshot' );\r
472                                                                         event.cancel();\r
473                                                                 }\r
474                                                         } );\r
475                                                 }\r
476 \r
477                                                 // Adds the document body as a context menu target.\r
478                                                 if ( editor.contextMenu )\r
479                                                         editor.contextMenu.addTarget( domDocument );\r
480 \r
481                                                 setTimeout( function()\r
482                                                         {\r
483                                                                 editor.fire( 'contentDom' );\r
484 \r
485                                                                 if ( fireMode )\r
486                                                                 {\r
487                                                                         editor.mode = 'wysiwyg';\r
488                                                                         editor.fire( 'mode' );\r
489                                                                         fireMode = false;\r
490                                                                 }\r
491 \r
492                                                                 isLoadingData = false;\r
493 \r
494                                                                 if ( isPendingFocus )\r
495                                                                 {\r
496                                                                         editor.focus();\r
497                                                                         isPendingFocus = false;\r
498                                                                 }\r
499                                                                 setTimeout( function()\r
500                                                                 {\r
501                                                                         editor.fire( 'dataReady' );\r
502                                                                 }, 0 );\r
503 \r
504                                                                 /*\r
505                                                                  * IE BUG: IE might have rendered the iframe with invisible contents.\r
506                                                                  * (#3623). Push some inconsequential CSS style changes to force IE to\r
507                                                                  * refresh it.\r
508                                                                  *\r
509                                                                  * Also, for some unknown reasons, short timeouts (e.g. 100ms) do not\r
510                                                                  * fix the problem. :(\r
511                                                                  */\r
512                                                                 if ( CKEDITOR.env.ie )\r
513                                                                 {\r
514                                                                         setTimeout( function()\r
515                                                                                 {\r
516                                                                                         if ( editor.document )\r
517                                                                                         {\r
518                                                                                                 var $body = editor.document.$.body;\r
519                                                                                                 $body.runtimeStyle.marginBottom = '0px';\r
520                                                                                                 $body.runtimeStyle.marginBottom = '';\r
521                                                                                         }\r
522                                                                                 }, 1000 );\r
523                                                                 }\r
524                                                         },\r
525                                                         0 );\r
526                                         };\r
527 \r
528                                         editor.addMode( 'wysiwyg',\r
529                                                 {\r
530                                                         load : function( holderElement, data, isSnapshot )\r
531                                                         {\r
532                                                                 mainElement = holderElement;\r
533 \r
534                                                                 if ( CKEDITOR.env.ie && CKEDITOR.env.quirks )\r
535                                                                         holderElement.setStyle( 'position', 'relative' );\r
536 \r
537                                                                 // The editor data "may be dirty" after this\r
538                                                                 // point.\r
539                                                                 editor.mayBeDirty = true;\r
540 \r
541                                                                 fireMode = true;\r
542 \r
543                                                                 if ( isSnapshot )\r
544                                                                         this.loadSnapshotData( data );\r
545                                                                 else\r
546                                                                         this.loadData( data );\r
547                                                         },\r
548 \r
549                                                         loadData : function( data )\r
550                                                         {\r
551                                                                 isLoadingData = true;\r
552 \r
553                                                                 // Get the HTML version of the data.\r
554                                                                 if ( editor.dataProcessor )\r
555                                                                 {\r
556                                                                         data = editor.dataProcessor.toHtml( data, fixForBody );\r
557                                                                 }\r
558 \r
559                                                                 data =\r
560                                                                         editor.config.docType +\r
561                                                                         '<html dir="' + editor.config.contentsLangDirection + '">' +\r
562                                                                         '<head>' +\r
563                                                                                 '<link type="text/css" rel="stylesheet" href="' +\r
564                                                                                 [].concat( editor.config.contentsCss ).join( '"><link type="text/css" rel="stylesheet" href="' ) +\r
565                                                                                 '">' +\r
566                                                                                 '<style type="text/css" _fcktemp="true">' +\r
567                                                                                         editor._.styles.join( '\n' ) +\r
568                                                                                 '</style>'+\r
569                                                                         '</head>' +\r
570                                                                         '<body>' +\r
571                                                                                 data +\r
572                                                                         '</body>' +\r
573                                                                         '</html>' +\r
574                                                                         activationScript;\r
575 \r
576                                                                 window[ '_cke_htmlToLoad_' + editor.name ] = data;\r
577                                                                 CKEDITOR._[ 'contentDomReady' + editor.name ] = contentDomReady;\r
578                                                                 createIFrame();\r
579 \r
580                                                                 // Opera must use the old method for loading contents.\r
581                                                                 if ( CKEDITOR.env.opera )\r
582                                                                 {\r
583                                                                         var doc = iframe.$.contentWindow.document;\r
584                                                                         doc.open();\r
585                                                                         doc.write( data );\r
586                                                                         doc.close();\r
587                                                                 }\r
588                                                         },\r
589 \r
590                                                         getData : function()\r
591                                                         {\r
592                                                                 var data = iframe.getFrameDocument().getBody().getHtml();\r
593 \r
594                                                                 if ( editor.dataProcessor )\r
595                                                                         data = editor.dataProcessor.toDataFormat( data, fixForBody );\r
596 \r
597                                                                 // Strip the last blank paragraph within document.\r
598                                                                 if ( editor.config.ignoreEmptyParagraph )\r
599                                                                         data = data.replace( emptyParagraphRegexp, '' );\r
600 \r
601                                                                 return data;\r
602                                                         },\r
603 \r
604                                                         getSnapshotData : function()\r
605                                                         {\r
606                                                                 return iframe.getFrameDocument().getBody().getHtml();\r
607                                                         },\r
608 \r
609                                                         loadSnapshotData : function( data )\r
610                                                         {\r
611                                                                 iframe.getFrameDocument().getBody().setHtml( data );\r
612                                                         },\r
613 \r
614                                                         unload : function( holderElement )\r
615                                                         {\r
616                                                                 editor.window = editor.document = iframe = mainElement = isPendingFocus = null;\r
617 \r
618                                                                 editor.fire( 'contentDomUnload' );\r
619                                                         },\r
620 \r
621                                                         focus : function()\r
622                                                         {\r
623                                                                 if ( isLoadingData )\r
624                                                                         isPendingFocus = true;\r
625                                                                 else if ( editor.window )\r
626                                                                 {\r
627                                                                         editor.window.focus();\r
628                                                                         editor.selectionChange();\r
629                                                                 }\r
630                                                         }\r
631                                                 });\r
632 \r
633                                         editor.on( 'insertHtml', onInsertHtml, null, null, 20 );\r
634                                         editor.on( 'insertElement', onInsertElement, null, null, 20 );\r
635                                         // Auto fixing on some document structure weakness to enhance usabilities. (#3190 and #3189)\r
636                                         editor.on( 'selectionChange', onSelectionChangeFixBody, null, null, 1 );\r
637                                 });\r
638                 }\r
639         });\r
640 })();\r
641 \r
642 /**\r
643  * Disables the ability of resize objects (image and tables) in the editing\r
644  * area.\r
645  * @type Boolean\r
646  * @default false\r
647  * @example\r
648  * config.disableObjectResizing = true;\r
649  */\r
650 CKEDITOR.config.disableObjectResizing = false;\r
651 \r
652 /**\r
653  * Disables the "table tools" offered natively by the browser (currently\r
654  * Firefox only) to make quick table editing operations, like adding or\r
655  * deleting rows and columns.\r
656  * @type Boolean\r
657  * @default true\r
658  * @example\r
659  * config.disableNativeTableHandles = false;\r
660  */\r
661 CKEDITOR.config.disableNativeTableHandles = true;\r
662 \r
663 /**\r
664  * Disables the built-in spell checker while typing natively available in the\r
665  * browser (currently Firefox and Safari only).<br /><br />\r
666  *\r
667  * Even if word suggestions will not appear in the CKEditor context menu, this\r
668  * feature is useful to help quickly identifying misspelled words.<br /><br />\r
669  *\r
670  * This setting is currently compatible with Firefox only due to limitations in\r
671  * other browsers.\r
672  * @type Boolean\r
673  * @default true\r
674  * @example\r
675  * config.disableNativeSpellChecker = false;\r
676  */\r
677 CKEDITOR.config.disableNativeSpellChecker = true;\r
678 \r
679 /**\r
680  * Whether the editor must output an empty value ("") if it's contents is made\r
681  * by an empty paragraph only.\r
682  * @type Boolean\r
683  * @default true\r
684  * @example\r
685  * config.ignoreEmptyParagraph = false;\r
686  */\r
687 CKEDITOR.config.ignoreEmptyParagraph = true;\r