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