Ticket #243: block_split.patch

File block_split.patch, 32.9 KB (added by Frederico Caldeira Knabben, 17 years ago)

Proposal patch

  • editor/_source/classes/fckdomrange.js

     
    180180                oTestRange.SetEnd( oTestRange.EndBlock || oTestRange.EndBlockLimit, 2 ) ;
    181181
    182182                var bIsEndOfBlock = oTestRange.CheckIsCollapsed() ;
    183                
     183
    184184                if ( !bIsEndOfBlock )
    185185                {
    186186                        // Inserts the contents of the range in a div tag.
    187187                        var eToolDiv = this.Window.document.createElement( 'div' ) ;
    188188                        oTestRange._Range.cloneContents().AppendTo( eToolDiv ) ;
    189189                        FCKDomTools.TrimNode( eToolDiv, true ) ;
    190                        
     190
    191191                        // Find out if we are in an empty tree of inline elements, like <b><i><span></span></i></b>
    192192                        bIsEndOfBlock = true ;
    193193                        var eLastChild = eToolDiv ;
     
    205205                                }
    206206                        }
    207207                }
    208                
     208
    209209                oTestRange.Release() ;
    210210
    211211                if ( refreshSelection )
     
    272272                }
    273273                else
    274274                        this.Collapse( true ) ;
     275
     276                this._UpdateElementInfo() ;
    275277        },
    276278
     279        MoveToPosition : function( targetElement, position )
     280        {
     281                this.SetStart( targetElement, position ) ;
     282                this.Collapse( true ) ;
     283        },
     284
    277285        /*
    278286         * Moves the position of the start boundary of the range to a specific position
    279287         * relatively to a element.
     
    441449                }
    442450        },
    443451
     452        SplitBlock : function()
     453        {
     454                if ( !this._Range )
     455                        this.MoveToSelection() ;
     456
     457                // The selection boundaries must be in the same "block limit" element.
     458                if ( this.StartBlockLimit == this.EndBlockLimit )
     459                {
     460                        // Get the current blocks.
     461                        var eStartBlock         = this.StartBlock ;
     462                        var eEndBlock           = this.EndBlock ;
     463
     464                        if ( FCKConfig.EnterMode != 'br' )
     465                        {
     466                                if ( !eStartBlock )
     467                                {
     468                                        eStartBlock = this._FixBlock( true ) ;
     469                                        eEndBlock       = this.EndBlock ;       // _FixBlock may have fixed the EndBlock too.
     470                                }
     471
     472                                if ( !eEndBlock )
     473                                        eEndBlock = this._FixBlock( false ) ;
     474                        }
     475
     476                        var bIsStartOfBlock     = ( eStartBlock != null && this.CheckStartOfBlock() ) ;
     477                        var bIsEndOfBlock       = ( eEndBlock != null && this.CheckEndOfBlock() ) ;
     478
     479                        // Delete the current selection.
     480                        if ( !this.CheckIsEmpty() )
     481                                this.DeleteContents() ;
     482
     483                        if ( eStartBlock && eEndBlock &&  eStartBlock == eEndBlock )
     484                        {
     485                                if ( bIsStartOfBlock )
     486                                {
     487                                        this.MoveToPosition( eStartBlock, 3 ) ;
     488                                        eStartBlock = null ;
     489                                }
     490                                else if ( bIsEndOfBlock )
     491                                {
     492                                        this.MoveToPosition( eEndBlock, 4 ) ;
     493                                        eEndBlock = null ;
     494                                }
     495                                else
     496                                {
     497                                        // Extract the contents of the block from the selection point to the end of its contents.
     498                                        this.SetEnd( eStartBlock, 2 ) ;
     499                                        var eDocFrag = this.ExtractContents() ;
     500                                        FCKDomTools.TrimNode( eDocFrag.RootNode ) ;
     501
     502                                        // Duplicate the block element after it.
     503                                        eEndBlock = eStartBlock.cloneNode( false ) ;
     504
     505                                        // Place the extracted contents in the duplicated block.
     506                                        eDocFrag.AppendTo( eEndBlock ) ;
     507
     508                                        FCKDomTools.InsertAfterNode( eStartBlock, eEndBlock ) ;
     509
     510                                        this.MoveToPosition( eStartBlock, 4 ) ;
     511                                }
     512                        }
     513
     514                        if ( FCKBrowserInfo.IsGecko )
     515                        {
     516                                // In Gecko, the last child node must be a bogus <br>.
     517                                FCKTools.AppendBogusBr( eStartBlock ) ;
     518                                FCKTools.AppendBogusBr( eEndBlock ) ;
     519                        }
     520
     521                        return {
     522                                PreviousBlock   : eStartBlock,
     523                                NextBlock               : eEndBlock,
     524                                WasStartOfBlock : bIsStartOfBlock,
     525                                WasEndOfBlock   : bIsEndOfBlock
     526                        } ;
     527                }
     528
     529                return null ;
     530        },
     531
     532                // Transform a block without a block tag in a valid block (orphan text in the body or td, usually).
     533        _FixBlock : function( isStart )
     534        {
     535                // Bookmark the range so we can restore it later.
     536                var oBookmark = this.CreateBookmark() ;
     537
     538                // Collapse the range to the requested ending boundary.
     539                this.Collapse( isStart ) ;
     540
     541                // Expands it to the block contents.
     542                this.Expand( 'block_contents' ) ;
     543
     544                // Create the fixed block.
     545                var oFixedBlock = this.Window.document.createElement( FCKConfig.EnterMode ) ;
     546
     547                // Move the contents of the temporary range to the fixed block.
     548                this.ExtractContents().AppendTo( oFixedBlock ) ;
     549                FCKDomTools.TrimNode( oFixedBlock ) ;
     550
     551                // Insert the fixed block into the DOM.
     552                this.InsertNode( oFixedBlock ) ;
     553
     554                // Move the range back to the bookmarked place.
     555                this.MoveToBookmark( oBookmark ) ;
     556
     557                return oFixedBlock ;
     558        },
     559
    444560        Release : function( preserveWindow )
    445561        {
    446562                if ( !preserveWindow )
  • editor/_source/classes/fckenterkey.js

     
    202202                        this._OutdentWithSelection( currentBlock, range ) ;
    203203                        return true ;
    204204                }
    205                
     205
    206206                // Take a reference to the parent for post processing cleanup.
    207207                var oCurrentParent = currentBlock.parentNode ;
    208208
     
    284284        // Get the current selection.
    285285        var oRange = range || new FCKDomRange( this.Window ) ;
    286286
    287         // If we don't have a range, move it to the selection.
    288         if ( !range )
    289                 oRange.MoveToSelection() ;
     287        var oSplitInfo = oRange.SplitBlock() ;
    290288
    291         // The selection boundaries must be in the same "block limit" element.
    292         if ( oRange.StartBlockLimit == oRange.EndBlockLimit )
     289        if ( oSplitInfo )
    293290        {
    294                 // If the StartBlock or EndBlock are not available (for text without a
    295                 // block tag), we must fix them, by moving the text to a block.
    296                 if ( !oRange.StartBlock )
    297                         this._FixBlock( oRange, true, blockTag ) ;
    298 
    299                 if ( !oRange.EndBlock )
    300                         this._FixBlock( oRange, false, blockTag ) ;
    301 
    302291                // Get the current blocks.
    303                 var eStartBlock = oRange.StartBlock ;
    304                 var eEndBlock   = oRange.EndBlock ;
     292                var ePreviousBlock      = oSplitInfo.PreviousBlock ;
     293                var eNextBlock          = oSplitInfo.NextBlock ;
    305294
    306                 // Delete the current selection.
    307                 if ( !oRange.CheckIsEmpty() )
    308                         oRange.DeleteContents() ;
     295                var bIsStartOfBlock     = oSplitInfo.WasStartOfBlock ;
     296                var bIsEndOfBlock       = oSplitInfo.WasEndOfBlock ;
    309297
    310                 // If the selection boundaries are in the same block element
    311                 if ( eStartBlock == eEndBlock )
     298                // If we have both the previous and next blocks, it means that the
     299                // boundaries were on separated blocks, or none of them where on the
     300                // block limits (start/end).
     301                if ( !oSplitInfo.WasStartOfBlock && !oSplitInfo.WasEndOfBlock )
    312302                {
     303                        // Move the selection to the end block.
     304                        if ( eNextBlock )
     305                                oRange.MoveToElementEditStart( eNextBlock ) ;
     306                }
     307                else
     308                {
     309                        if ( bIsStartOfBlock && bIsEndOfBlock && eNextBlock.tagName.toUpperCase() == 'LI' )
     310                        {
     311                                oRange.MoveToElementStart( eNextBlock ) ;
     312                                this._OutdentWithSelection( eNextBlock, oRange ) ;
     313                                oRange.Release() ;
     314                                return true ;
     315                        }
     316
    313317                        var eNewBlock ;
    314318
    315                         var bIsStartOfBlock     = oRange.CheckStartOfBlock() ;
    316                         var bIsEndOfBlock       = oRange.CheckEndOfBlock() ;
    317 
    318                         if ( bIsStartOfBlock && !bIsEndOfBlock )
     319                        if ( ePreviousBlock )
    319320                        {
    320                                 eNewBlock = eStartBlock.cloneNode(false) ;
     321                                var sPreviousBlockTag = ePreviousBlock.tagName.toUpperCase() ;
    321322
    322                                 if ( FCKBrowserInfo.IsGeckoLike )
    323                                         eNewBlock.innerHTML = GECKO_BOGUS ;
    324 
    325                                 // Place the new block before the current block element.
    326                                 eStartBlock.parentNode.insertBefore( eNewBlock, eStartBlock ) ;
    327 
    328                                 // This is tricky, but to make the new block visible correctly
    329                                 // we must select it.
    330                                 if ( FCKBrowserInfo.IsIE )
     323                                // If is a header tag, or we are in a Shift+Enter (#77),
     324                                // create a new block element.
     325                                if ( this._HasShift || (/^H[1-6]$/).test( sPreviousBlockTag ) )
     326                                        eNewBlock = this.Window.document.createElement( blockTag ) ;
     327                                else
    331328                                {
    332                                         // Move the selection to the new block.
    333                                         oRange.MoveToNodeContents( eNewBlock ) ;
    334 
    335                                         oRange.Select() ;
     329                                        // Otherwise, duplicate the previous block.
     330                                        eNewBlock = ePreviousBlock.cloneNode( false ) ;
     331                                        this._RecreateEndingTree( ePreviousBlock, eNewBlock ) ;
    336332                                }
    337 
    338                                 // Move the selection to the new block.
    339                                 oRange.MoveToElementEditStart( eStartBlock ) ;
    340333                        }
    341                         else
     334                        else if ( eNextBlock )
    342335                        {
    343                                 // Check if the selection is at the end of the block.
    344                                 if ( bIsEndOfBlock )
    345                                 {
    346                                         var sStartBlockTag = eStartBlock.tagName.toUpperCase() ;
     336                                eNewBlock = eNextBlock.cloneNode( false ) ;
     337                        }
     338                        else
     339                                eNewBlock = this.Window.document.createElement( blockTag ) ;
    347340
    348                                         // If the entire block is selected, and we are in a LI, let's decrease its indentation.
    349                                         if ( bIsStartOfBlock && sStartBlockTag == 'LI' )
    350                                         {
    351                                                 this._OutdentWithSelection( eStartBlock, oRange ) ;
    352                                                 oRange.Release() ;
    353                                                 return true ;
    354                                         }
    355                                         else
    356                                         {
    357                                                 // If is a header tag, or we are in a Shift+Enter (#77),
    358                                                 // create a new block element.
    359                                                 if ( (/^H[1-6]$/).test( sStartBlockTag ) || this._HasShift )
    360                                                         eNewBlock = this.Window.document.createElement( blockTag ) ;
    361                                                 // Otherwise, duplicate the current block.
    362                                                 else
    363                                                 {
    364                                                         eNewBlock = eStartBlock.cloneNode(false) ;
    365                                                         this._RecreateEndingTree( eStartBlock, eNewBlock ) ;
    366                                                 }
     341                        if ( FCKBrowserInfo.IsGeckoLike )
     342                                eNewBlock.innerHTML = GECKO_BOGUS ;
    367343
    368                                                 if ( FCKBrowserInfo.IsGeckoLike )
    369                                                 {
    370                                                         eNewBlock.innerHTML = GECKO_BOGUS ;
     344                        oRange.InsertNode( eNewBlock ) ;
    371345
    372                                                         // If the entire block is selected, let's add a bogus in the start block.
    373                                                         if ( bIsStartOfBlock )
    374                                                                 eStartBlock.innerHTML = GECKO_BOGUS ;
    375                                                 }
    376                                         }
    377                                 }
    378                                 else
    379                                 {
    380                                         // Extract the contents of the block from the selection point to the end of its contents.
    381                                         oRange.SetEnd( eStartBlock, 2 ) ;
    382                                         var eDocFrag = oRange.ExtractContents() ;
     346                        // This is tricky, but to make the new block visible correctly
     347                        // we must select it.
     348                        if ( FCKBrowserInfo.IsIE )
     349                        {
     350                                // Move the selection to the new block.
     351                                oRange.MoveToNodeContents( eNewBlock ) ;
     352                                oRange.Select() ;
     353                        }
    383354
    384                                         // Duplicate the block element after it.
    385                                         eNewBlock = eStartBlock.cloneNode(false) ;
     355                        oRange.MoveToElementEditStart( bIsStartOfBlock ? eNextBlock : eNewBlock ) ;
    386356
    387                                         // It could be that we are in a LI with a child UL/OL. Insert a bogus to give us space to type.
    388                                         FCKDomTools.TrimNode( eDocFrag.RootNode ) ;
    389                                         if ( eDocFrag.RootNode.firstChild.nodeType == 1 && eDocFrag.RootNode.firstChild.tagName.toUpperCase().Equals( 'UL', 'OL' ) )
    390                                                 eNewBlock.innerHTML = GECKO_BOGUS ;
    391 
    392                                         // Place the extracted contents in the duplicated block.
    393                                         eDocFrag.AppendTo( eNewBlock ) ;
    394 
    395                                         if ( FCKBrowserInfo.IsGecko )
    396                                         {
    397                                                 // In Gecko, the last child node must be a bogus <br>.
    398                                                 this._AppendBogusBr( eStartBlock ) ;
    399                                                 this._AppendBogusBr( eNewBlock ) ;
    400                                         }
    401                                 }
    402 
    403                                 if ( eNewBlock )
    404                                 {
    405                                         FCKDomTools.InsertAfterNode( eStartBlock, eNewBlock ) ;
    406 
    407                                         // Move the selection to the new block.
    408                                         oRange.MoveToElementEditStart( eNewBlock ) ;
    409 
    410                                         if ( FCKBrowserInfo.IsGecko )
    411                                                 eNewBlock.scrollIntoView( false ) ;
    412                                 }
    413                         }
     357                        if ( FCKBrowserInfo.IsGecko )
     358                                eNewBlock.scrollIntoView( false ) ;
    414359                }
    415                 else
    416                 {
    417                         // Move the selection to the end block.
    418                         oRange.MoveToElementEditStart( eEndBlock ) ;
    419                 }
    420360
    421361                oRange.Select() ;
    422362        }
     
    454394                // If we are at the end of a header block.
    455395                if ( !bHasShift && bIsEndOfBlock && (/^H[1-6]$/).test( sStartBlockTag ) )
    456396                {
    457                         FCKDebug.Output( 'BR - Header' ) ;
    458 
    459397                        // Insert a BR after the current paragraph.
    460398                        FCKDomTools.InsertAfterNode( oRange.StartBlock, this.Window.document.createElement( 'br' ) ) ;
    461399
     
    468406                }
    469407                else
    470408                {
    471                         FCKDebug.Output( 'BR - No Header' ) ;
    472 
    473409                        var eBr = this.Window.document.createElement( 'br' ) ;
    474410
    475411                        oRange.InsertNode( eBr ) ;
     
    480416
    481417                        // If we are at the end of a block, we must be sure the bogus node is available in that block.
    482418                        if ( bIsEndOfBlock && FCKBrowserInfo.IsGecko )
    483                                 this._AppendBogusBr( eBr.parentNode ) ;
     419                                FCKTools.AppendBogusBr( eBr.parentNode ) ;
    484420
    485421                        if ( FCKBrowserInfo.IsIE )
    486422                                oRange.SetStart( eBr, 4 ) ;
     
    501437        return true ;
    502438}
    503439
    504 // Transform a block without a block tag in a valid block (orphan text in the body or td, usually).
    505 FCKEnterKey.prototype._FixBlock = function( range, isStart, blockTag )
    506 {
    507         // Bookmark the range so we can restore it later.
    508         var oBookmark = range.CreateBookmark() ;
    509 
    510         // Collapse the range to the requested ending boundary.
    511         range.Collapse( isStart ) ;
    512 
    513         // Expands it to the block contents.
    514         range.Expand( 'block_contents' ) ;
    515 
    516         // Create the fixed block.
    517         var oFixedBlock = this.Window.document.createElement( blockTag ) ;
    518 
    519         // Move the contents of the temporary range to the fixed block.
    520         range.ExtractContents().AppendTo( oFixedBlock ) ;
    521         FCKDomTools.TrimNode( oFixedBlock ) ;
    522 
    523         // Insert the fixed block into the DOM.
    524         range.InsertNode( oFixedBlock ) ;
    525 
    526         // Move the range back to the bookmarked place.
    527         range.MoveToBookmark( oBookmark ) ;
    528 }
    529 
    530 // Appends a bogus <br> at the end of the element, if not yet available.
    531 FCKEnterKey.prototype._AppendBogusBr = function( element )
    532 {
    533         var eLastChild = element.getElementsByTagName('br') ;
    534 
    535         if ( eLastChild )
    536                 eLastChild = eLastChild[ eLastChild.legth - 1 ] ;
    537 
    538         if ( !eLastChild || eLastChild.getAttribute( 'type', 2 ) != '_moz' )
    539                 element.appendChild( FCKTools.CreateBogusBR( this.Window.document ) ) ;
    540 }
    541 
    542440// Recreate the elements tree at the end of the source block, at the beginning
    543 // of the target block. Eg.: 
     441// of the target block. Eg.:
    544442//      If source = <p><u>Some</u> sample <b><i>text</i></b></p> then target = <p><b><i></i></b></p>
    545443//      If source = <p><u>Some</u> sample text</p> then target = <p></p>
    546444FCKEnterKey.prototype._RecreateEndingTree = function( source, target )
     
    555453        var oBookmark = range.CreateBookmark() ;
    556454
    557455        FCKListHandler.OutdentListItem( li ) ;
    558        
     456
    559457        range.MoveToBookmark( oBookmark ) ;
    560458        range.Select() ;
    561459}
     460 No newline at end of file
  • editor/_source/commandclasses/fck_othercommands.js

     
    279279        e.innerHTML = '<span style="DISPLAY:none">&nbsp;</span>' ;
    280280
    281281        var oFakeImage = FCKDocumentProcessor_CreateFakeImage( 'FCK__PageBreak', e ) ;
    282         oFakeImage      = FCK.InsertElement( oFakeImage ) ;
     282        FCK.InsertElement( oFakeImage ) ;
    283283}
    284284
    285285FCKPageBreakCommand.prototype.GetState = function()
     
    378378        {
    379379                return FCK.GetNamedCommandState( 'Paste' ) ;
    380380        }
     381} ;
     382
     383// FCKRuleCommand
     384var FCKRuleCommand = function()
     385{
     386        this.Name = 'Paste' ;
     387}
     388
     389FCKRuleCommand.prototype =
     390{
     391        Execute : function()
     392        {
     393                FCK.InsertElement( 'hr' ) ;
     394        },
     395
     396        GetState : function()
     397        {
     398                return FCK.GetNamedCommandState( 'InsertHorizotalRule' ) ;
     399        }
    381400} ;
     401 No newline at end of file
  • editor/_source/internals/fck.js

     
    8888
    8989                this.EditingArea = new FCKEditingArea( document.getElementById( 'xEditingArea' ) ) ;
    9090                this.EditingArea.FFSpellChecker = false ;
    91                
     91
    9292                // Final setup of the lists lib.
    9393                FCKListsLib.Setup() ;
    9494
     
    314314                if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG )
    315315                {
    316316                        html = FCKConfig.ProtectedSource.Protect( html ) ;
    317                        
     317
    318318                        // Fix for invalid self-closing tags (see #152).
    319319                        html = html.replace( FCKRegexLib.InvalidSelfCloseTags, '$1></$2>' ) ;
    320                        
     320
    321321                        html = FCK.ProtectEvents( html ) ;
    322322                        html = FCK.ProtectUrls( html ) ;
    323323                        html = FCK.ProtectTags( html ) ;
     
    331331                                html = html.replace( FCKRegexLib.EmOpener, '<i$1' ) ;
    332332                                html = html.replace( FCKRegexLib.EmCloser, '<\/i>' ) ;
    333333                        }
    334                        
     334
    335335                        this._ForceResetIsDirty = ( resetIsDirty === true ) ;
    336336
    337337                        var sHtml = '' ;
     
    429429
    430430                        // Removes the enter key handler.
    431431                        FCK.EnterKeyHandler = null ;
    432                        
     432
    433433                        if ( resetIsDirty )
    434434                                this.ResetIsDirty() ;
    435435
     
    569569                FCK.EditMode = bIsWysiwyg ? FCK_EDITMODE_SOURCE : FCK_EDITMODE_WYSIWYG ;
    570570
    571571                FCK.SetHTML( sHtml, !bIsDirty ) ;
    572                
     572
    573573                // Set the Focus.
    574574                FCK.Focus() ;
    575575
     
    579579                return true ;
    580580        },
    581581
    582         CreateElement : function( tag )
     582        InsertElement : function( element )
    583583        {
    584                 var e = FCK.EditorDocument.createElement( tag ) ;
    585                 return FCK.InsertElementAndGetIt( e ) ;
    586         },
     584                // The parameter may be a string (element name), so transform it in an element.
     585                if ( typeof element == 'string' )
     586                        element = this.EditorDocument.createElement( element ) ;
     587               
     588                var elementName = element.nodeName.toLowerCase() ;
    587589
    588         InsertElementAndGetIt : function( e )
    589         {
    590                 e.setAttribute( 'FCKTempLabel', 'true' ) ;
     590                // Create a range for the selection. V3 will have a new selection
     591                // object that may internaly supply this feature.
     592                var range = new FCKDomRange( this.EditorWindow ) ;
    591593
    592                 this.InsertElement( e ) ;
     594                if ( FCKListsLib.BlockElements[ elementName ] != null )
     595                {
     596                        range.SplitBlock() ;
     597                        range.InsertNode( element ) ;
     598                       
     599                        var next = FCKDomTools.GetNextSourceElement( element, false, null, [ 'hr','br','param','img','area','input' ] )
    593600
    594                 var aEls = FCK.EditorDocument.getElementsByTagName( e.tagName ) ;
     601                        // Be sure that we have something after the new element, so we can move the cursor there.
     602                        if ( !next && FCKConfig.EnterMode != 'br')
     603                        {
     604                                next = this.EditorDocument.body.appendChild( this.EditorDocument.createElement( FCKConfig.EnterMode ) ) ;
     605                               
     606                                if ( FCKBrowserInfo.IsGecko )
     607                                        next.innerHTML = GECKO_BOGUS ;
     608                        }
     609                       
     610                        if ( FCKListsLib.EmptyElements[ elementName ] == null )
     611                                range.MoveToElementEditStart( element ) ;
     612                        else if ( next )
     613                                range.MoveToElementEditStart( next ) ;
     614                        else
     615                                range.MoveToPosition( element, 4 ) ;
    595616
    596                 for ( var i = 0 ; i < aEls.length ; i++ )
    597                 {
    598                         if ( aEls[i].getAttribute( 'FCKTempLabel' ) )
     617                        if ( FCKBrowserInfo.IsGecko )
    599618                        {
    600                                 aEls[i].removeAttribute( 'FCKTempLabel' ) ;
    601                                 return aEls[i] ;
     619                                if ( next )
     620                                        next.scrollIntoView( false ) ;
     621                                element.scrollIntoView( false ) ;
    602622                        }
    603623                }
    604                 return null ;
     624                else
     625                {
     626                        // Delete the current selection and insert the node.
     627                        range.MoveToSelection() ;
     628                        range.DeleteContents() ;
     629                        range.InsertNode( element ) ;
     630
     631                        // Move the selection right after the new element.
     632                        // DISCUSSION: Should we select the element instead?
     633                        range.SetStart( element, 4 ) ;
     634                        range.SetEnd( element, 4 ) ;
     635                }
     636
     637                range.Select() ;
     638                range.Release() ;
     639
     640                // REMOVE IT: The focus should not really be set here. It is up to the
     641                // calling code to reset the focus if needed.
     642                this.Focus() ;
     643
     644                return element ;
     645        },
     646
     647        _InsertBlockElement : function( blockElement )
     648        {
    605649        }
    606 
    607650} ;
    608651
    609652FCK.Events      = new FCKEvents( FCK ) ;
     653
    610654// GetHTML is Deprecated : returns the same value as GetXHTML.
    611655FCK.GetHTML     = FCK.GetXHTML ;
    612656
     657// InsertElementAndGetIt and CreateElement are Deprecated : returns the same value as InsertElement.
     658FCK.InsertElementAndGetIt = FCK.CreateElement = FCK.InsertElement ;
     659
    613660// Replace all events attributes (like onclick).
    614661function _FCK_ProtectEvents_ReplaceTags( tagMatch )
    615662{
     
    643690
    644691        // Listen for keystroke events.
    645692        FCK.KeystrokeHandler.AttachToElement( FCK.EditorDocument ) ;
    646        
     693
    647694        if ( FCK._ForceResetIsDirty )
    648695                FCK.ResetIsDirty() ;
    649        
     696
    650697        // This is a tricky thing for IE. In some cases, even if the cursor is
    651698        // blinking in the editing, the keystroke handler doesn't catch keyboard
    652699        // events. We must activate the editing area to make it work. (#142).
  • editor/_source/internals/fck_gecko.js

     
    181181        this.Focus() ;
    182182}
    183183
    184 FCK.InsertElement = function( element )
    185 {
    186         // Deletes the actual selection.
    187         var oSel = FCKSelection.Delete() ;
    188 
    189         // Gets the first available range.
    190         var oRange = oSel.getRangeAt(0) ;
    191 
    192         // Inserts the element in the range.
    193         oRange.insertNode( element ) ;
    194 
    195         // Set the cursor after the inserted fragment.
    196         FCKSelection.SelectNode( element ) ;
    197         FCKSelection.Collapse( false ) ;
    198 
    199         this.Focus() ;
    200 }
    201 
    202184FCK.PasteAsPlainText = function()
    203185{
    204186        // TODO: Implement the "Paste as Plain Text" code.
  • editor/_source/internals/fck_ie.js

     
    310310        FCK._PasteIsEnabled = true ;
    311311}
    312312
    313 FCK.InsertElement = function( element )
    314 {
    315         FCK.InsertHtml( element.outerHTML ) ;
    316 }
    317 
    318313FCK.GetClipboardHTML = function()
    319314{
    320315        var oDiv = document.getElementById( '___FCKHiddenDiv' ) ;
  • editor/_source/internals/fckcommands.js

     
    6969                case 'Save'                     : oCommand = new FCKSaveCommand() ; break ;
    7070                case 'NewPage'          : oCommand = new FCKNewPageCommand() ; break ;
    7171                case 'PageBreak'        : oCommand = new FCKPageBreakCommand() ; break ;
     72                case 'Rule'                     : oCommand = new FCKRuleCommand() ; break ;
    7273
    7374                case 'TextColor'        : oCommand = new FCKTextColorCommand('ForeColor') ; break ;
    7475                case 'BGColor'          : oCommand = new FCKTextColorCommand('BackColor') ; break ;
  • editor/_source/internals/fcklistslib.js

     
    3131        BlockElements : { address:1,blockquote:1,center:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,noscript:1,ol:1,p:1,pre:1,script:1,table:1,ul:1 },
    3232
    3333        // Block elements that may be filled with &nbsp; if empty.
    34         NonEmptyBlockElements : { p:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,address:1,pre:1,ol:1,ul:1,li:1,td:1,th:1 },
     34        NonEmptyBlockElements : { p:1,div:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,address:1,pre:1,ol:1,ul:1,li:1,td:1,th:1 },
    3535
    3636        // Inline elements which MUST have child nodes.
    3737        InlineChildReqElements : { abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1 },
  • editor/_source/internals/fcktoolbaritems.js

     
    8282                case 'Smiley'                   : oItem = new FCKToolbarButton( 'Smiley'                , FCKLang.InsertSmileyLbl, FCKLang.InsertSmiley, null, false, true, 41 ) ; break ;
    8383                case 'PageBreak'                : oItem = new FCKToolbarButton( 'PageBreak'             , FCKLang.PageBreakLbl, FCKLang.PageBreak, null, false, true, 43 ) ; break ;
    8484
    85                 case 'Rule'                             : oItem = new FCKToolbarButton( 'InsertHorizontalRule', FCKLang.InsertLineLbl, FCKLang.InsertLine, null, false, true, 40 ) ; break ;
     85                case 'Rule'                             : oItem = new FCKToolbarButton( 'Rule'                  , FCKLang.InsertLineLbl, FCKLang.InsertLine, null, false, true, 40 ) ; break ;
    8686
    8787                case 'JustifyLeft'              : oItem = new FCKToolbarButton( 'JustifyLeft'   , FCKLang.LeftJustify, null, null, false, true, 30 ) ; break ;
    8888                case 'JustifyCenter'    : oItem = new FCKToolbarButton( 'JustifyCenter' , FCKLang.CenterJustify, null, null, false, true, 31 ) ; break ;
  • editor/_source/internals/fcktools.js

     
    223223        fCloneCreator.prototype = sourceObject ;
    224224        return new fCloneCreator ;
    225225}
     226
     227// Appends a bogus <br> at the end of the element, if not yet available.
     228FCKTools.AppendBogusBr = function( element )
     229{
     230        if ( !element )
     231                return ;
     232
     233        var eLastChild = element.getElementsByTagName('br') ;
     234
     235        if ( eLastChild )
     236                eLastChild = eLastChild[ eLastChild.legth - 1 ] ;
     237
     238        if ( !eLastChild || eLastChild.getAttribute( 'type', 2 ) != '_moz' )
     239                element.appendChild( this.CreateBogusBR( this.GetElementDocument( element ) ) ) ;
     240}
     241 No newline at end of file
  • editor/_source/internals/fckxhtml_ie.js

     
    166166        if ( htmlNode.name )
    167167                FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ;
    168168
    169         node = FCKXHtml._AppendChildNodes( node, htmlNode ) ;
     169        node = FCKXHtml._AppendChildNodes( node, htmlNode, true ) ;
    170170
    171171        return node ;
    172172}
  • editor/dialog/fck_anchor.html

     
    114114        if ( !oAnchor )
    115115        {
    116116                // Nothing was selected, so now just create a normal A
    117                 oAnchor = oEditor.FCK.CreateElement( 'a' ) ;
     117                oAnchor = oEditor.FCK.InsertElement( 'a' ) ;
    118118        }
    119119        else
    120120        {
  • editor/dialog/fck_button.html

     
    6161        {
    6262                oActiveEl = oEditor.FCK.EditorDocument.createElement( 'INPUT' ) ;
    6363                oActiveEl.type = GetE('txtType').value ;
    64                 oActiveEl = oEditor.FCK.InsertElementAndGetIt( oActiveEl ) ;
     64                oActiveEl = oEditor.FCK.InsertElement( oActiveEl ) ;
    6565        }
    6666
    6767        oActiveEl.name = GetE('txtName').value ;
  • editor/dialog/fck_checkbox.html

     
    5959        {
    6060                oActiveEl = oEditor.FCK.EditorDocument.createElement( 'INPUT' ) ;
    6161                oActiveEl.type = 'checkbox' ;
    62                 oActiveEl = oEditor.FCK.InsertElementAndGetIt( oActiveEl ) ;
     62                oActiveEl = oEditor.FCK.InsertElement( oActiveEl ) ;
    6363        }
    6464
    6565        if ( GetE('txtName').value.length > 0 )
  • editor/dialog/fck_flash/fck_flash.js

     
    135135        {
    136136                oFakeImage      = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ;
    137137                oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ;
    138                 oFakeImage      = FCK.InsertElementAndGetIt( oFakeImage ) ;
     138                oFakeImage      = FCK.InsertElement( oFakeImage ) ;
    139139        }
    140140        else
    141141                oEditor.FCKUndo.SaveUndoStep() ;
  • editor/dialog/fck_form.html

     
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
     1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    22<!--
    33 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
    44 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
     
    5757{
    5858        if ( !oActiveEl )
    5959        {
    60                 oActiveEl = oEditor.FCK.EditorDocument.createElement( 'FORM' ) ;
    61                 oActiveEl = oEditor.FCK.InsertElementAndGetIt( oActiveEl ) ;
    62                 oActiveEl.innerHTML = '&nbsp;' ;
     60                oActiveEl = oEditor.FCK.InsertElement( 'form' ) ;
     61
     62                if ( oEditor.FCKBrowserInfo.IsGeckoLike )
     63                        oActiveEl.innerHTML = GECKO_BOGUS ;
    6364        }
    6465
    6566        oActiveEl.name = GetE('txtName').value ;
    66         SetAttribute( oActiveEl, 'action'       , GetE('txtAction').value ) ;
     67        SetAttribute( oActiveEl, 'action', GetE('txtAction').value ) ;
    6768        oActiveEl.method = GetE('txtMethod').value ;
    6869
    6970        return true ;
  • editor/dialog/fck_hiddenfield.html

     
    7979        {
    8080                oFakeImage      = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__InputHidden', oActiveEl ) ;
    8181                oFakeImage.setAttribute( '_fckinputhidden', 'true', 0 ) ;
    82                 oFakeImage      = FCK.InsertElementAndGetIt( oFakeImage ) ;
     82                oFakeImage      = FCK.InsertElement( oFakeImage ) ;
    8383        }
    8484        else
    8585                oEditor.FCKUndo.SaveUndoStep() ;
  • editor/dialog/fck_image/fck_image.js

     
    220220        {
    221221                if ( bImageButton )
    222222                {
    223                         oImage = FCK.EditorDocument.createElement( 'INPUT' ) ;
     223                        oImage = FCK.EditorDocument.createElement( 'input' ) ;
    224224                        oImage.type = 'image' ;
    225                         oImage = FCK.InsertElementAndGetIt( oImage ) ;
     225                        oImage = FCK.InsertElement( oImage ) ;
    226226                }
    227227                else
    228                         oImage = FCK.CreateElement( 'IMG' ) ;
     228                        oImage = FCK.InsertElement( 'img' ) ;
    229229        }
    230230        else
    231231                oEditor.FCKUndo.SaveUndoStep() ;
  • editor/dialog/fck_link/fck_link.js

     
    534534                }
    535535
    536536                // Create a new (empty) anchor.
    537                 oLink = oEditor.FCK.CreateElement( 'a' ) ;
     537                oLink = oEditor.FCK.InsertElement( 'a' ) ;
    538538        }
    539539
    540540        oEditor.FCKUndo.SaveUndoStep() ;
  • editor/dialog/fck_radiobutton.html

     
    5959        {
    6060                oActiveEl = oEditor.FCK.EditorDocument.createElement( 'INPUT' ) ;
    6161                oActiveEl.type = 'radio' ;
    62                 oActiveEl = oEditor.FCK.InsertElementAndGetIt( oActiveEl ) ;
     62                oActiveEl = oEditor.FCK.InsertElement( oActiveEl ) ;
    6363        }
    6464
    6565        if ( GetE('txtName').value.length > 0 )
  • editor/dialog/fck_select.html

     
    7878                sSize = '' ;
    7979
    8080        if ( !oActiveEl )
    81         {
    82                 oActiveEl = oEditor.FCK.EditorDocument.createElement( 'SELECT' ) ;
    83                 oActiveEl = oEditor.FCK.InsertElementAndGetIt( oActiveEl ) ;
    84         }
     81                oActiveEl = oEditor.FCK.InsertElement( 'select' ) ;
    8582
    8683        SetAttribute( oActiveEl, 'name' , GetE('txtName').value ) ;
    8784        SetAttribute( oActiveEl, 'size' , sSize ) ;
  • editor/dialog/fck_smiley.html

     
    4545
    4646function InsertSmiley( url )
    4747{
    48         var oImg = oEditor.FCK.CreateElement( 'IMG' ) ;
     48        var oImg = oEditor.FCK.InsertElement( 'img' ) ;
    4949        oImg.src = url ;
    5050        oImg.setAttribute( '_fcksavedurl', url ) ;
    5151
  • editor/dialog/fck_textarea.html

     
    5656function Ok()
    5757{
    5858        if ( !oActiveEl )
    59         {
    60                 oActiveEl = oEditor.FCK.EditorDocument.createElement( 'TEXTAREA' ) ;
    61                 oActiveEl = oEditor.FCK.InsertElementAndGetIt( oActiveEl ) ;
    62         }
     59                oActiveEl = oEditor.FCK.InsertElement( 'textarea' ) ;
    6360
    6461        oActiveEl.name = GetE('txtName').value ;
    6562        SetAttribute( oActiveEl, 'cols', GetE('txtCols').value ) ;
  • editor/dialog/fck_textfield.html

     
    7676        {
    7777                oActiveEl = oEditor.FCK.EditorDocument.createElement( 'INPUT' ) ;
    7878                oActiveEl.type = GetE('txtType').value ;
    79                 oActiveEl = oEditor.FCK.InsertElementAndGetIt( oActiveEl ) ;
     79                oActiveEl = oEditor.FCK.InsertElement( oActiveEl ) ;
    8080        }
    8181
    8282        oActiveEl.name = GetE('txtName').value ;
  • editor/plugins/placeholder/fckplugin.js

     
    3737// Add a new placeholder at the actual selection.
    3838FCKPlaceholders.Add = function( name )
    3939{
    40         var oSpan = FCK.CreateElement( 'SPAN' ) ;
     40        var oSpan = FCK.InsertElement( 'span' ) ;
    4141        this.SetupSpan( oSpan, name ) ;
    4242}
    4343
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy