Ticket #2247: 2247_3.patch

File 2247_3.patch, 5.2 KB (added by Martin Kou, 16 years ago)
  • _whatsnew.html

     
    4646                        ability to create, modify and remove Div containers.</li>
    4747                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2252">#2252</a>] It's now possible to enable the
    4848                        browsers default menu using the configuration file (FCKConfig.BrowserContextMenu option).</li>
     49                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2247">#2247</a>] The SHIFT+SPACE
     50                        keystroke will now produce a &amp;nbsp; character.</li>
    4951        </ul>
    5052        <p>
    5153                Fixed Bugs:</p>
  • editor/_source/commandclasses/fck_othercommands.js

     
    613613                range.Select() ;
    614614        }
    615615} ;
     616
     617// FCKRuleCommand
     618var FCKNbsp = function()
     619{
     620        this.Name = 'Non Breaking Space' ;
     621}
     622
     623FCKNbsp.prototype =
     624{
     625        Execute : function()
     626        {
     627                FCK.InsertHtml( '&nbsp;' ) ;
     628        },
     629
     630        GetState : function()
     631        {
     632                return ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ? FCK_TRISTATE_DISABLED : FCK_TRISTATE_OFF ) ;
     633        }
     634} ;
  • editor/_source/internals/fck_gecko.js

     
    359359        // Save an undo snapshot first.
    360360        FCKUndo.SaveUndoStep() ;
    361361
    362         if ( FCKBrowserInfo.IsGecko )
     362        var fakeNodes = false ;
     363        var prevCharNodeValue ;
     364        if ( FCKBrowserInfo.IsGecko && /^(?:&nbsp;|&#160;)+$/.test( html ) )
    363365        {
     366                // Get the previous character's text node value, if any.
     367                var selection = FCK.EditorWindow.getSelection() ;
     368                var range = selection && selection.rangeCount > 0 && selection.getRangeAt( 0 ) ;
     369                var startNode, prevCharNode ;
     370                if ( range )
     371                {
     372                        if ( range.startContainer.nodeType == 1 )
     373                                startNode = range.startContainer.childNodes[ range.startOffset ] ;
     374                        else if ( range.startContainer.nodeType == 3 )
     375                                startNode = range.startContainer ;
     376                }
     377                if ( startNode )
     378                {
     379                        if ( range.startContainer.nodeType == 1 )
     380                        {
     381                                var node = startNode.previousSibling ;
     382                                while ( node && node.nodeType == 3 && node.length < 1 )
     383                                        node = node.previousSibling ;
     384                                if ( node && node.nodeType == 3 )
     385                                        prevCharNode = node ;
     386                        }
     387                        else
     388                                prevCharNode = startNode ;
     389                }
     390                if ( prevCharNode )
     391                {
     392                        prevCharNodeValue = prevCharNode.nodeValue ;
     393                        if ( range.startContainer.nodeType == 3 )
     394                                prevCharNodeValue = prevCharNodeValue.substr( 0, range.startOffset ) ;
     395                }
     396
    364397                // Using the following trick, &nbsp; present at the beginning and at
    365398                // the end of the HTML are preserved (#2248).
    366399                html = '<span id="__fakeFCKRemove1__" style="display:none;">fakeFCKRemove</span>' + html + '<span id="__fakeFCKRemove2__" style="display:none;">fakeFCKRemove</span>' ;
     400                fakeNodes = true ;
    367401        }
    368402
    369403        // Insert the HTML code.
    370404        doc.execCommand( 'inserthtml', false, html ) ;
    371405
    372         if ( FCKBrowserInfo.IsGecko )
     406        if ( fakeNodes )
    373407        {
     408                // Retrieve the text node before the newly inserted text node.
     409                // Note that this is a different node to the prevCharNode earlier.
     410                var firstNode = doc.getElementById( '__fakeFCKRemove1__' ) ;
     411                var textNode = firstNode.previousSibling ;
     412
    374413                // Remove the fake nodes.
    375                 FCKDomTools.RemoveNode( doc.getElementById('__fakeFCKRemove1__') ) ;
     414                FCKDomTools.RemoveNode( firstNode ) ;
    376415                FCKDomTools.RemoveNode( doc.getElementById('__fakeFCKRemove2__') ) ;
     416
     417                // Restore the previous character's text node value, if any.
     418                if ( prevCharNodeValue && textNode && textNode.nodeType == 3 )
     419                        textNode.nodeValue = prevCharNodeValue ;
    377420        }
    378421
    379422        this.Focus() ;
  • editor/_source/internals/fckcommands.js

     
    8080                case 'NewPage'          : oCommand = new FCKNewPageCommand() ; break ;
    8181                case 'PageBreak'        : oCommand = new FCKPageBreakCommand() ; break ;
    8282                case 'Rule'                     : oCommand = new FCKRuleCommand() ; break ;
     83                case 'Nbsp'                     : oCommand = new FCKNbsp() ; break ;
    8384
    8485                case 'TextColor'        : oCommand = new FCKTextColorCommand('ForeColor') ; break ;
    8586                case 'BGColor'          : oCommand = new FCKTextColorCommand('BackColor') ; break ;
  • fckconfig.js

     
    142142        [ CTRL + 73 /*I*/, 'Italic' ],
    143143        [ CTRL + 85 /*U*/, 'Underline' ],
    144144        [ CTRL + SHIFT + 83 /*S*/, 'Save' ],
    145         [ CTRL + ALT + 13 /*ENTER*/, 'FitWindow' ]
     145        [ CTRL + ALT + 13 /*ENTER*/, 'FitWindow' ],
     146        [ SHIFT + 32 /*SPACE*/, 'Nbsp' ]
    146147] ;
    147148
    148149FCKConfig.ContextMenu = ['Generic','Link','Anchor','Image','Flash','Select','Textarea','Checkbox','Radio','TextField','HiddenField','ImageButton','Button','BulletedList','NumberedList','Table','Form','DivContainer'] ;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy