Ticket #6663: 6663_2.patch

File 6663_2.patch, 2.1 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/table/dialogs/table.js

     
    116116                        },
    117117                        onOk : function()
    118118                        {
    119                                 if ( this._.selectedElement )
    120                                 {
    121                                         var selection = editor.getSelection(),
    122                                                 bms = selection.createBookmarks();
    123                                 }
     119                                var selection = editor.getSelection(),
     120                                        bms = selection.createBookmarks();
    124121
    125122                                var table = this._.selectedElement || makeElement( 'table' ),
    126123                                        me = this,
     
    248245                                // Insert the table element if we're creating one.
    249246                                if ( !this._.selectedElement )
    250247                                        editor.insertElement( table );
    251                                 // Properly restore the selection inside table. (#4822)
    252                                 else
    253                                         selection.selectBookmarks( bms );
    254248
     249                                // Properly restore the selection, (#4822) but don't break
     250                                // because of this, e.g. updated table caption.
     251                                try { selection.selectBookmarks( bms ); } catch( er ){}
     252
    255253                                return true;
    256254                        },
    257255                        contents : [
     
    600598                                                                        label : editor.lang.table.caption,
    601599                                                                        setup : function( selectedTable )
    602600                                                                        {
     601                                                                                this.enable();
     602
    603603                                                                                var nodeList = selectedTable.getElementsByTag( 'caption' );
    604604                                                                                if ( nodeList.count() > 0 )
    605605                                                                                {
    606606                                                                                        var caption = nodeList.getItem( 0 );
     607
     608                                                                                        var innerHtml = caption.getHtml().replace(/<br>\s*$/i, ''),
     609                                                                                                innerText = caption.getText();
     610
     611                                                                                        if ( innerHtml != innerText )
     612                                                                                        {
     613                                                                                                this.disable();
     614                                                                                                this.setValue( innerText );
     615                                                                                                return;
     616                                                                                        }
     617
    607618                                                                                        caption = CKEDITOR.tools.trim( caption.getText() );
    608619                                                                                        this.setValue( caption );
    609620                                                                                }
    610621                                                                        },
    611622                                                                        commit : function( data, table )
    612623                                                                        {
     624                                                                                if ( !this.isEnabled() )
     625                                                                                        return;
     626
    613627                                                                                var caption = this.getValue(),
    614628                                                                                        captionElement = table.getElementsByTag( 'caption' );
    615629                                                                                if ( caption )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy