Changeset 2209

Show
Ignore:
Timestamp:
2008-07-11 13:37:09 (20 months ago)
Author:
martinkou
Message:

Fixed #2234 : Added the ability to create, modify and remove Div containers.

Location:
FCKeditor/trunk
Files:
18 modified
2 copied

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/lang/en-au.js

    r2143 r2209  
    7474IncreaseIndent          : "Increase Indent", 
    7575Blockquote                      : "Blockquote", 
     76CreateDiv                       : "Create Div Container", 
     77EditDiv                         : "Edit Div Container", 
     78DeleteDiv                       : "Remove Div Container", 
    7679Undo                            : "Undo", 
    7780Redo                            : "Redo", 
  • FCKeditor/trunk/editor/lang/en-ca.js

    r2143 r2209  
    7474IncreaseIndent          : "Increase Indent", 
    7575Blockquote                      : "Blockquote", 
     76CreateDiv                       : "Create Div Container", 
     77EditDiv                         : "Edit Div Container", 
     78DeleteDiv                       : "Remove Div Container", 
    7679Undo                            : "Undo", 
    7780Redo                            : "Redo", 
  • FCKeditor/trunk/editor/lang/en.js

    r2143 r2209  
    7474IncreaseIndent          : "Increase Indent", 
    7575Blockquote                      : "Blockquote", 
     76CreateDiv                       : "Create Div Container", 
     77EditDiv                         : "Edit Div Container", 
     78DeleteDiv                       : "Remove Div Container", 
    7679Undo                            : "Undo", 
    7780Redo                            : "Redo", 
     
    514517DlgAboutLicenseTab      : "License", 
    515518DlgAboutVersion         : "version", 
    516 DlgAboutInfo            : "For further information go to" 
     519DlgAboutInfo            : "For further information go to", 
     520 
     521// Div Dialog 
     522DlgDivGeneralTab        : "General", 
     523DlgDivAdvancedTab       : "Advanced", 
     524DlgDivStyle             : "Style", 
     525DlgDivInlineStyle       : "Inline Style" 
    517526}; 
  • FCKeditor/trunk/editor/lang/en-uk.js

    r2143 r2209  
    7474IncreaseIndent          : "Increase Indent", 
    7575Blockquote                      : "Blockquote", 
     76CreateDiv                       : "Create Div Container", 
     77EditDiv                         : "Edit Div Container", 
     78DeleteDiv                       : "Remove Div Container", 
    7679Undo                            : "Undo", 
    7780Redo                            : "Redo", 
  • FCKeditor/trunk/editor/lang/zh-cn.js

    r2143 r2209  
    7474IncreaseIndent          : "增加缩进量", 
    7575Blockquote                      : "块引用", 
     76CreateDiv                       : "新增 Div 标籤", 
     77EditDiv                         : "更改 Div 标籤", 
     78DeleteDiv                       : "删除 Div 标籤", 
    7679Undo                            : "撤消", 
    7780Redo                            : "重做", 
  • FCKeditor/trunk/editor/lang/zh.js

    r2143 r2209  
    7474IncreaseIndent          : "增加縮排", 
    7575Blockquote                      : "引用文字", 
     76CreateDiv                       : "新增 Div 標籤", 
     77EditDiv                         : "變更 Div 標籤", 
     78DeleteDiv                       : "移除 Div 標籤", 
    7679Undo                            : "復原", 
    7780Redo                            : "重複", 
  • FCKeditor/trunk/editor/_source/classes/fckdomrange.js

    r2106 r2209  
    4343                        // For text nodes, the node itself is the StartNode. 
    4444                        var eStart      = innerRange.startContainer ; 
    45                         var eEnd        = innerRange.endContainer ; 
    4645 
    4746                        var oElementPath = new FCKElementPath( eStart ) ; 
     
    5150                        this.StartBlockLimit    = oElementPath.BlockLimit ; 
    5251 
    53                         if ( eStart != eEnd ) 
    54                                 oElementPath = new FCKElementPath( eEnd ) ; 
    55  
    56                         // The innerRange.endContainer[ innerRange.endOffset ] is not 
    57                         // usually part of the range, but the marker for the range end. So, 
    58                         // let's get the previous available node as the real end. 
    59                         var eEndNode = eEnd ; 
    60                         if ( innerRange.endOffset == 0 ) 
     52                        if ( innerRange.collapsed ) 
    6153                        { 
    62                                 while ( eEndNode && !eEndNode.previousSibling ) 
    63                                         eEndNode = eEndNode.parentNode ; 
    64  
    65                                 if ( eEndNode ) 
    66                                         eEndNode = eEndNode.previousSibling ; 
     54                                this.EndNode            = this.StartNode ; 
     55                                this.EndContainer       = this.StartContainer ; 
     56                                this.EndBlock           = this.StartBlock ; 
     57                                this.EndBlockLimit      = this.StartBlockLimit ; 
    6758                        } 
    68                         else if ( eEndNode.nodeType == 1 ) 
    69                                 eEndNode = eEndNode.childNodes[ innerRange.endOffset - 1 ] ; 
    70  
    71                         this.EndNode                    = eEndNode ; 
    72                         this.EndContainer               = eEnd ; 
    73                         this.EndBlock                   = oElementPath.Block ; 
    74                         this.EndBlockLimit              = oElementPath.BlockLimit ; 
     59                        else 
     60                        { 
     61                                var eEnd        = innerRange.endContainer ; 
     62 
     63                                if ( eStart != eEnd ) 
     64                                        oElementPath = new FCKElementPath( eEnd ) ; 
     65 
     66                                // The innerRange.endContainer[ innerRange.endOffset ] is not 
     67                                // usually part of the range, but the marker for the range end. So, 
     68                                // let's get the previous available node as the real end. 
     69                                var eEndNode = eEnd ; 
     70                                if ( innerRange.endOffset == 0 ) 
     71                                { 
     72                                        while ( eEndNode && !eEndNode.previousSibling ) 
     73                                                eEndNode = eEndNode.parentNode ; 
     74 
     75                                        if ( eEndNode ) 
     76                                                eEndNode = eEndNode.previousSibling ; 
     77                                } 
     78                                else if ( eEndNode.nodeType == 1 ) 
     79                                        eEndNode = eEndNode.childNodes[ innerRange.endOffset - 1 ] ; 
     80 
     81                                this.EndNode                    = eEndNode ; 
     82                                this.EndContainer               = eEnd ; 
     83                                this.EndBlock                   = oElementPath.Block ; 
     84                                this.EndBlockLimit              = oElementPath.BlockLimit ; 
     85                        } 
    7586                } 
    7687 
  • FCKeditor/trunk/editor/_source/commandclasses/fck_othercommands.js

    r2143 r2209  
    576576        } 
    577577}; 
     578 
     579var FCKDeleteDivCommand = function() 
     580{ 
     581} 
     582FCKDeleteDivCommand.prototype =  
     583{ 
     584        GetState : function() 
     585        { 
     586                if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) 
     587                        return FCK_TRISTATE_DISABLED ; 
     588 
     589                var node = FCKSelection.GetParentElement() ; 
     590                var path = new FCKElementPath( node ) ; 
     591                return path.BlockLimit && path.BlockLimit.nodeName.IEquals( 'div' ) ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; 
     592        }, 
     593 
     594        Execute : function() 
     595        { 
     596                // Create an undo snapshot before doing anything. 
     597                FCKUndo.SaveUndoStep() ; 
     598 
     599                // Find out the nodes to delete. 
     600                var nodes = FCKDomTools.GetSelectedDivContainers() ; 
     601                 
     602                // Remember the current selection position. 
     603                var range = new FCKDomRange( FCK.EditorWindow ) ; 
     604                range.MoveToSelection() ; 
     605                var bookmark = range.CreateBookmark() ; 
     606 
     607                // Delete the container DIV node. 
     608                for ( var i = 0 ; i < nodes.length ; i++) 
     609                        FCKDomTools.RemoveNode( nodes[i], true ) ; 
     610 
     611                // Restore selection. 
     612                range.MoveToBookmark( bookmark ) ; 
     613                range.Select() ; 
     614        } 
     615} ; 
  • FCKeditor/trunk/editor/_source/internals/fckcommands.js

    r2143 r2209  
    9696                case 'Outdent'  : oCommand = new FCKIndentCommand( 'outdent', FCKConfig.IndentLength * -1 ) ; break ; 
    9797                case 'Blockquote'       : oCommand = new FCKBlockQuoteCommand() ; break ; 
     98                case 'CreateDiv'        : oCommand = new FCKDialogCommand( 'CreateDiv', FCKLang.CreateDiv, 'dialog/fck_div.html', 380, 210, null, null, true ) ; break ; 
     99                case 'EditDiv'          : oCommand = new FCKDialogCommand( 'EditDiv', FCKLang.EditDiv, 'dialog/fck_div.html', 380, 210, null, null, false ) ; break ; 
     100                case 'DeleteDiv'        : oCommand = new FCKDeleteDivCommand() ; break ; 
    98101 
    99102                case 'TableInsertRowAfter'              : oCommand = new FCKTableCommand('TableInsertRowAfter') ; break ; 
  • FCKeditor/trunk/editor/_source/internals/fck_contextmenu.js

    r2143 r2209  
    295295                                } 
    296296                        }} ; 
     297 
     298                case 'DivContainer': 
     299                        return { 
     300                        AddItems : function( menu, tag, tagName ) 
     301                        { 
     302                                var currentBlocks = FCKDomTools.GetSelectedDivContainers() ; 
     303 
     304                                if ( currentBlocks.length > 0 ) 
     305                                { 
     306                                        menu.AddSeparator() ; 
     307                                        menu.AddItem( 'EditDiv', FCKLang.EditDiv, 75 ) ; 
     308                                        menu.AddItem( 'DeleteDiv', FCKLang.DeleteDiv, 76 ) ; 
     309                                } 
     310                        }} ; 
     311                         
    297312                // @Packager.Remove.Start 
    298313                default : 
  • FCKeditor/trunk/editor/_source/internals/fckdomtools.js

    r2159 r2209  
    697697        SetElementMarker : function ( markerObj, element, attrName, value) 
    698698        { 
    699                 var id = String( parseInt( Math.random() * 0xfffffff, 10 ) ) ; 
     699                var id = String( parseInt( Math.random() * 0xffffffff, 10 ) ) ; 
    700700                element._FCKMarkerId = id ; 
    701701                element[attrName] = value ; 
     
    10211021                // In the DTD # == text node. 
    10221022                return ( childDTD['#'] && !FCKListsLib.NonEditableElements[ nodeName ] ) ; 
     1023        }, 
     1024 
     1025        GetSelectedDivContainers : function() 
     1026        { 
     1027                var currentBlocks = [] ; 
     1028                var range = new FCKDomRange( FCK.EditorWindow ) ; 
     1029                range.MoveToSelection() ; 
     1030 
     1031                var startNode = range.GetTouchedStartNode() ; 
     1032                var endNode = range.GetTouchedEndNode() ; 
     1033                var currentNode = startNode ; 
     1034 
     1035                if ( startNode == endNode ) 
     1036                { 
     1037                        while ( endNode.nodeType == 1 && endNode.lastChild ) 
     1038                                endNode = endNode.lastChild ; 
     1039                        endNode = FCKDomTools.GetNextSourceNode( endNode ) ; 
     1040                } 
     1041 
     1042                while ( currentNode && currentNode != endNode ) 
     1043                { 
     1044                        if ( currentNode.nodeType != 3 || !/^[ \t\n]*$/.test( currentNode.nodeValue ) ) 
     1045                        { 
     1046                                var path = new FCKElementPath( currentNode ) ; 
     1047                                var blockLimit = path.BlockLimit ; 
     1048                                if ( blockLimit && blockLimit.nodeName.IEquals( 'div' ) && currentBlocks.IndexOf( blockLimit ) == -1 ) 
     1049                                        currentBlocks.push( blockLimit ) ; 
     1050                        } 
     1051 
     1052                        currentNode = FCKDomTools.GetNextSourceNode( currentNode ) ; 
     1053                } 
     1054 
     1055                return currentBlocks ; 
    10231056        } 
    10241057} ; 
  • FCKeditor/trunk/editor/_source/internals/fckselection_gecko.js

    r2072 r2209  
    7676                if ( oSel ) 
    7777                { 
    78                         // make the common case fast - for collapsed/nearly collapsed selections just return anchor.parent. 
     78                        // if anchorNode == focusNode, see if the selection is text only or including nodes. 
     79                        // if text only, return the parent node. 
     80                        // if the selection includes DOM nodes, then the anchorNode is the nearest container. 
    7981                        if ( oSel.anchorNode && oSel.anchorNode == oSel.focusNode ) 
    80                                 return oSel.anchorNode.parentNode ; 
     82                        { 
     83                                var oRange = oSel.getRangeAt( 0 ) ; 
     84                                if ( oRange.collapsed || oRange.startContainer.nodeType == 3 ) 
     85                                        return oSel.anchorNode.parentNode ; 
     86                                else 
     87                                        return oSel.anchorNode ; 
     88                        } 
    8189 
    8290                        // looks like we're having a large selection here. To make the behavior same as IE's TextRange.parentElement(), 
  • FCKeditor/trunk/editor/_source/internals/fcktoolbaritems.js

    r1565 r2209  
    7272                case 'Indent'                   : oItem = new FCKToolbarButton( 'Indent'        , FCKLang.IncreaseIndent, null, null, false, true, 29 ) ; break ; 
    7373                case 'Blockquote'                       : oItem = new FCKToolbarButton( 'Blockquote'    , FCKLang.Blockquote, null, null, false, true, 73 ) ; break ; 
     74                case 'CreateDiv'                        : oItem = new FCKToolbarButton( 'CreateDiv'     , FCKLang.CreateDiv, null, null, false, true, 74 ) ; break ; 
    7475 
    7576                case 'Link'                             : oItem = new FCKToolbarButton( 'Link'          , FCKLang.InsertLinkLbl, FCKLang.InsertLink, null, false, true, 34 ) ; break ; 
  • FCKeditor/trunk/fckconfig.js

    r2157 r2209  
    106106        '/', 
    107107        ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'], 
    108         ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'], 
     108        ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote','CreateDiv'], 
    109109        ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'], 
    110110        ['Link','Unlink','Anchor'], 
     
    146146] ; 
    147147 
    148 FCKConfig.ContextMenu = ['Generic','Link','Anchor','Image','Flash','Select','Textarea','Checkbox','Radio','TextField','HiddenField','ImageButton','Button','BulletedList','NumberedList','Table','Form'] ; 
     148FCKConfig.ContextMenu = ['Generic','Link','Anchor','Image','Flash','Select','Textarea','Checkbox','Radio','TextField','HiddenField','ImageButton','Button','BulletedList','NumberedList','Table','Form','DivContainer'] ; 
    149149FCKConfig.BrowserContextMenuOnCtrl = false ; 
    150150 
  • FCKeditor/trunk/_whatsnew.html

    r2188 r2209  
    4343                        from the Link dialog are now encoded by default to prevent being harvested by spammers. 
    4444                        (Kudos to asuter for proposing the patch) </li> 
     45                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2234">#2234</a>] Added the 
     46                        ability to create, modify and remove Div containers.</li> 
    4547        </ul> 
    4648        <p>