Ticket #2763: 2763.2.patch

File 2763.2.patch, 12.2 KB (added by Garry Yao, 15 years ago)

code style revised

  • _source/plugins/editingblock/plugin.js

    ### Eclipse Workspace Patch 1.0
    #P ckeditor3.0
     
    190190                modeEditor.load( holderElement, data || this.getData() );
    191191
    192192                this.mode = mode;
    193                 this.fire( 'mode' );
     193                this.fire( 'mode' , mode);
    194194        };
    195195
    196196        /**
  • _source/core/dom/range.js

     
    424424                        return docFrag;
    425425                },
    426426
    427                 // This is an "intrusive" way to create a bookmark. It includes <span> tags
    428                 // in the range boundaries. The advantage of it is that it is possible to
    429                 // handle DOM mutations when moving back to the bookmark.
    430                 // Attention: the inclusion of nodes in the DOM is a design choice and
    431                 // should not be changed as there are other points in the code that may be
    432                 // using those nodes to perform operations. See GetBookmarkNode.
    433                 createBookmark : function()
     427                /**
     428                 * This is an "intrusive" way to create a bookmark. It includes <span>
     429                 * tags in the range boundaries. The advantage of it is that it is
     430                 * possible to handle DOM mutations when moving back to the bookmark.
     431                 * Attention: the inclusion of nodes in the DOM is a design choice.
     432                 *
     433                 * @param serializeable {Boolean} If set to true will record the bookmark with startNode/endNode IDs for serializing purpose.
     434                 */
     435                createBookmark : function(serializeable)
    434436                {
    435                         var startNode, endNode;
     437                        var startNode , endNode;
    436438                        var clone;
    437439
    438440                        startNode = this.document.createElement( 'span' );
    439                         startNode.setAttribute( '_fck_bookmark', 1 );
    440                         startNode.setStyle( 'display', 'none' );
     441                        startNode.setAttribute( '_fck_bookmark' , 1 );
     442                        startNode.setStyle( 'display' , 'none' );
    441443
    442444                        // For IE, it must have something inside, otherwise it may be
    443445                        // removed during DOM operations.
     
    451453
    452454                                clone = this.clone();
    453455                                clone.collapse();
    454                                 clone.insertNode( endNode );
     456                                clone.insertNode( endNode ); // CONFUSE: This insert will not influence current selection.
    455457                        }
    456458
    457459                        clone = this.clone();
    458460                        clone.collapse( true );
    459                         clone.insertNode( startNode );
     461                        clone.insertNode( startNode ); // CONFUSE: This insert will fade current selection out.
    460462
    461463                        // Update the range position.
    462464                        if ( endNode )
     
    465467                                this.setEndBefore( endNode );
    466468                        }
    467469                        else
    468                                 this.moveToPosition( startNode, CKEDITOR.POSITION_AFTER_END );
     470                                this.moveToPosition( startNode , CKEDITOR.POSITION_AFTER_END );
    469471
     472                        if ( serializeable )
     473                        {
     474                                startNode.setAttribute( 'id' , ( new Date() ).valueOf()
     475                                                + Math.floor( Math.random() * 1000 ) + 'S' );
     476                                if ( endNode )
     477                                        endNode.setAttribute( 'id' , ( new Date() ).valueOf()
     478                                                        + Math.floor( Math.random() * 1000 ) + 'E' );
     479                        }
    470480                        return {
    471                                 startNode : startNode,
    472                                 endNode : endNode
     481                                startNode :serializeable ? startNode.getAttribute( 'id' )
     482                                                : startNode,
     483                                endNode :endNode ? ( serializeable ? endNode
     484                                                .getAttribute( 'id' ) : endNode ) : null
    473485                        };
    474486                },
    475 
     487       
     488        /**
     489                 * Move the range boundaries to where the bookmarks indicated.
     490                 *
     491                 * @see CKEDITOR.dom.range::createBookmark
     492                 * @param bookmark
     493                 *            {Object}
     494                 */
    476495                moveToBookmark : function( bookmark )
    477496                {
     497                        var st = bookmark.startNode , ed = bookmark.endNode;
     498
    478499                        // Set the range start at the bookmark start node position.
    479                         this.setStartBefore( bookmark.startNode );
     500                        this.setStartBefore( typeof st === 'string' ? ( st = this.document
     501                                        .getById( st ) ) : st );
    480502
    481503                        // Remove it, because it may interfere in the setEndBefore call.
    482                         bookmark.startNode.remove();
     504                        st.remove();
    483505
    484506                        // Set the range end at the bookmark end node position, or simply
    485507                        // collapse it if it is not available.
    486                         var endNode = bookmark.endNode;
    487                         if ( endNode )
     508                        if ( ed )
    488509                        {
    489                                 this.setEndBefore( endNode );
    490                                 endNode.remove();
     510                                this.setEndBefore( typeof ed === 'string' ?
     511                                                ( ed = this.document.getById( ed ) )
     512                                                : ed );
     513                                ed.remove();
    491514                        }
    492515                        else
    493516                                this.collapse( true );
  • _source/core/editor.js

     
    361361                execCommand : function( commandName, data )
    362362                {
    363363                        var command = this.getCommand( commandName );
     364                        var cp =
     365                        /**
     366                         * Name-command pair to trace commands behavious
     367                         *
     368                         * @type FCKEDITOR.command.Pair
     369                         */
     370                        {
     371                                name :commandName,
     372                                command :command
     373                        };
    364374                        if ( command && command.state != CKEDITOR.TRISTATE_DISABLED )
    365                                 return command.exec( this, data );
    366 
     375                        {
     376                                this.fire( 'beforeCommandExec' , cp );
     377                                command.exec( this , data );
     378                                this.fire( 'afterCommandExec' , cp );
     379                        }
     380       
    367381                        // throw 'Unknown command name "' + commandName + '"';
    368382                        return false;
    369                 },
     383        },
    370384               
    371385                /**
    372                  * Gets one of the registered commands. Note that, after registering a
    373                  * command definition with addCommand, it is transformed internally
    374                  * into an instance of {@link CKEDITOR.command}, which will be then
    375                  * returned by this function.
    376                  * @param {String} commandName The name of the command to be returned.
    377                  * This is the same used to register the command with addCommand.
    378                  * @returns {CKEDITOR.command} The command object identified by the
    379                  * provided name.
     386                 * Gets one of the registered commands. Note that, after registering a command definition with addCommand, it is
     387                 * transformed internally into an instance of {@link CKEDITOR.command}, which will be then returned by this
     388                 * function.
     389                 *
     390                 * @param {String}
     391                 *            commandName The name of the command to be returned. This is the same used to register the command
     392                 *            with addCommand.
     393                 * @returns {CKEDITOR.command} The command object identified by the provided name.
    380394                 */
    381395                getCommand : function( commandName )
    382396                {
  • _source/plugins/selection/plugin.js

     
    630630                                                sel.addRange( nativeRange );
    631631                                        }
    632632                                },
    633 
    634                 createBookmarks : function()
     633        /**
     634                 * This method is a delegate to ceate bookmark for every ranges in this selection.
     635                 *
     636                 * @see CKEDITOR.dom.range::createBookmark
     637                 */
     638                createBookmarks : function ( serializable )
    635639                {
    636                         var retval = [],
    637                                 ranges = this.getRanges();
     640                        var retval = [] , ranges = this.getRanges();
    638641                        for ( var i = 0 ; i < ranges.length ; i++ )
    639                                 retval.push( ranges[i].createBookmark() );
     642                                retval.push( ranges[ i ].createBookmark( serializable ) );
    640643                        return retval;
    641644                },
    642645
  • _source/core/commanddefinition.js

     
    3434 * @example
    3535 */
    3636
    37  /**
     37/**
    3838 * Executes the command.
    3939 * @name CKEDITOR.commandDefinition.prototype.exec
    4040 * @function
     
    4949 *     }
    5050 * });
    5151 */
     52
     53/**
     54 * Whether the command need to be hooked into the redo/undo system.
     55 * @name  CKEDITOR.commandDefinition.supportUndoRedo
     56 * @type {Boolean} If not defined or 'true' both hook into undo system, set it to 'false' explicitly  keep it out. 
     57 * @field
     58 * @example
     59 *  editorInstance.addCommand( 'sample',
     60 * {
     61 *     CKEDITOR.commandDefinition.supportUndoRedo : false    //declare this command does not support undo/redo 
     62 * });
     63 */
     64
  • _source/tests/core/dom/range.html

     
    15071507                        assert.areSame( 3, range.endOffset, 'range.endOffset' );
    15081508                        assert.isFalse( range.collapsed, 'range.collapsed' );
    15091509                },
     1510               
     1511               
     1512        //Test serializable bookmark create and apply
     1513                                test_bookmark_single_1 : function ( )
     1514                                {
    15101515
    1511                 /////////////
     1516                                        var range = new CKEDITOR.dom.range( doc );
     1517                                        range.setStartBefore( doc.getById( '_Span' ) );
     1518                                        range.setEndAfter( doc.getById( '_P' ) );
     1519                                        bm = range.createBookmark( true );
     1520                                        range.setStartBefore( doc.getById( '_P2' ) );
     1521                                        range.setEndAfter( doc.getById( '_P2' ) );
     1522                                        range.moveToBookmark( bm );
    15121523
    1513                 setUp : function()
    1514                 {
    1515                          document.getElementById( 'playground' ).innerHTML = html1;
    1516                          document.getElementById( 'playground2' ).innerHTML = html2;
    1517                 },
     1524                                        assert.areSame( document.getElementById( '_P' ) ,
     1525                                                        range.startContainer.$ , 'range.startContainer' );
     1526                                        assert  .areSame( 1 , range.startOffset,'range.startOffset' );
     1527                                        assert.areSame( document.getElementById( 'playground2' ) ,
     1528                                                        range.endContainer.$ , 'range.endContainer' );
     1529                                        assert.areSame( 4 , range.endOffset , 'range.endOffset' );
     1530                                        assert.isNull( document.getElementById( bm.startNode ) ,
     1531                                                        'bookmark.startNode' );
     1532                                        assert.isNull( document.getElementById( bm.endNode ) ,
     1533                                                        'bookmark.endNode' );
    15181534
    1519                 name : document.title
    1520         };
    1521 })() );
     1535                                },
    15221536
    1523 //window.onload = function()
    1524 //{
    1525 //      // Local references.
    1526 //      var assert                      = CKEDITOR.test.assert;
    1527 //      var getInnerHtml        = CKEDITOR.test.getInnerHtml;
     1537                                /////////////
    15281538
    1529 //      var doc = new CKEDITOR.dom.document( document );
     1539                                setUp : function ( )
     1540                                {
     1541                                        document.getElementById( 'playground' ).innerHTML = html1;
     1542                                        document.getElementById( 'playground2' ).innerHTML = html2;
     1543                                },
    15301544
    1531 //                      doc.getById( '_EnlargeP' ).setHtml( 'this <i>is some </i>sample text' );
     1545                                name :document.title
     1546                        };
     1547                } )() );
    15321548
    1533 //                      var range = new CKEDITOR.dom.range( doc );
    1534 //                      range.setStart( doc.getById( '_EnlargeP' ), 0 );
    1535 //                      range.setEnd( doc.getById( '_EnlargeP' ).getChild( 1 ), 0 );
     1549        //window.onload = function()
     1550        //{
     1551        //      // Local references.
     1552        //      var assert                      = CKEDITOR.test.assert;
     1553        //      var getInnerHtml        = CKEDITOR.test.getInnerHtml;
    15361554
    1537 //                      range.enlarge( CKEDITOR.ENLARGE_ELEMENT );
    1538 //}
     1555        //      var doc = new CKEDITOR.dom.document( document );
    15391556
     1557        //                      doc.getById( '_EnlargeP' ).setHtml( 'this <i>is some </i>sample text' );
     1558
     1559        //                      var range = new CKEDITOR.dom.range( doc );
     1560        //                      range.setStart( doc.getById( '_EnlargeP' ), 0 );
     1561        //                      range.setEnd( doc.getById( '_EnlargeP' ).getChild( 1 ), 0 );
     1562
     1563        //                      range.enlarge( CKEDITOR.ENLARGE_ELEMENT );
     1564        //}
     1565
    15401566        //]]>
    1541         </script>
     1567</script>
    15421568</head>
    15431569<body>
    15441570        <div id="playground" style="visibility:hidden"><h1 id="_H1">FCKW3CRange Test</h1><p id="_Para">This is <b id="_B">some</b> text.</p><p>Another paragraph.</p></div>
  • _source/core/config.js

     
    1 /*
     1/*
    22 * CKEditor - The text editor for Internet - http://ckeditor.com
    33 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
    44 *
     
    161161         * @example
    162162         * config.plugins = 'elementspath,toolbar,wysiwygarea';
    163163         */
    164         plugins : 'basicstyles,button,dialog,elementspath,horizontalrule,htmldataprocessor,keystrokes,removeformat,smiley,link,sourcearea,tab,toolbar,wysiwygarea,forms,image,find,table,specialchar,flash,print,pagebreak,newpage',
     164        plugins : 'basicstyles,button,dialog,elementspath,horizontalrule,htmldataprocessor,keystrokes,removeformat,smiley,link,sourcearea,tab,toolbar,wysiwygarea,forms,image,find,table,specialchar,flash,print,pagebreak,undoredo,newpage',
    165165
    166166        /**
    167167         * The theme to be used to build the UI.
     
    350350                        descriptions : [ ':)', ':(', ';)', ':D', ':/', ':P',
    351351                        '', '', '', '', '', '',
    352352                        '', ';(', '', '', '', '',
    353                         ':kiss', '', ],
     353                        ':kiss', '' ],
    354354
    355355                        //TODO: update path
    356356                        path : CKEDITOR.basePath +  '_source/plugins/smiley/images/',
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy