Changeset 2334

Show
Ignore:
Timestamp:
2008-08-05 18:25:41 (5 months ago)
Author:
fredck
Message:

Introduced the HTML parser and formatter (writer). The HTML outputted by the editor is not processed based on the innerHTML of the document body.

Location:
CKEditor/branches/prototype
Files:
11 added
9 modified

Legend:

Unmodified
Added
Removed
  • CKEditor/branches/prototype/_dev/docs_build/docs_build.bat

    r2131 r2334  
    2929java -jar ../_thirdparty/jsdoc-toolkit/jsrun.jar ../_thirdparty/jsdoc-toolkit/app/run.js -c=docs_build.conf 
    3030 
    31 php ../fixlineends/fixlineends.php --eolstripwhite --eofnewline --eofstripwhite --nohidden --nosystem ../../_docs/api/ 
     31:: php ../fixlineends/fixlineends.php --eolstripwhite --eofnewline --eofstripwhite --nohidden --nosystem ../../_docs/api/ 
    3232 
    3333ECHO Finished! 
  • CKEditor/branches/prototype/_dev/docs_build/docs_build.conf

    r2180 r2334  
    1717                '../../_source/core/', 
    1818                '../../_source/plugins/', 
     19                '../../_source/dtd/xhtml1-transitional.js', 
    1920                '../../_source/lang/en.js' 
    2021        ], 
  • CKEditor/branches/prototype/_dev/packager/fckpackager.php

    r2278 r2334  
    234234                        { 
    235235                                $varsMatch = $varsMatches[1][$i]; 
    236                                  
     236 
    237237                                // Removed all (...), [...] and {...} blocks from the var 
    238238                                // statement to avoid problems with commas inside them. 
     
    240240                                $varsMatch = preg_replace( '/(\[(?:(?>[^\[\]]*)|(?1))*\])+/', '', $varsMatch ) ; 
    241241                                $varsMatch = preg_replace( '/({(?:(?>[^{}]*)|(?1))*})+/', '', $varsMatch ) ; 
    242                                  
     242 
    243243                                $numVarNameMatches = preg_match_all( '/(?:^|,)\s*([^\s=,]+)/', $varsMatch, $varNameMatches ) ; 
    244                                  
     244 
    245245                                for ( $j = 0 ; $j < $numVarNameMatches ; $j++ ) 
    246246                                { 
     
    260260                { 
    261261                        if ( strlen( $var) > 1 ) 
    262                                 $source = preg_replace( '/(?<!\w|\d|\.)' . preg_quote( $var ) . '(?!\w|\d)/', $this->_GetVarName(), $source ) ; 
     262                        { 
     263                                $varName = $this->_GetVarName(); 
     264                                $source = preg_replace( '/(?<!\w|\d|\.)' . preg_quote( $var ) . '(?!\w|\d|:)/', $varName, $source ) ; 
     265 
     266                                // The above regex exclude names placed before ":", but it is not true for ternary operators. 
     267                                $source = preg_replace( '/(?<=\?)' . preg_quote( $var ) . '(?=:)/', $varName, $source ) ; 
     268                        } 
    263269                } 
    264270 
     
    331337                                '/\/\/.*$/m', 
    332338                                '', $script ) ; 
    333                  
     339 
    334340                // Remove spaces before the ";" at the end of the lines 
    335341                $script = preg_replace( 
     
    431437 
    432438                $processed = $GLOBALS['funcProcessor']->Process() ; 
    433                  
     439 
    434440                $processed = substr_replace( $processed, '', 0, 8 ) ; 
    435441 
     
    438444                if ( $hasfuncProcessor != TRUE ) 
    439445                        unset( $GLOBALS['funcProcessor'] ) ; 
    440                  
     446 
    441447                return 'function'. $processed ; 
    442448        } 
  • CKEditor/branches/prototype/fckpackager.xml

    r2278 r2334  
    4545 
    4646        <Constants removeDeclaration="false"> 
     47                <Constant name="CKEDITOR.NODE_ELEMENT" value="1" /> 
     48                <Constant name="CKEDITOR.NODE_TEXT" value="3" /> 
     49                <Constant name="CKEDITOR.NODE_COMMENT" value="8" /> 
    4750                <Constant name="CKEDITOR.UI_BUTTON" value="1" /> 
    4851                <Constant name="CKEDITOR.SELECTION_NONE" value="1" /> 
     
    8285                <File path="_source/core/ui.js" /> 
    8386                <File path="_source/core/editor.js" /> 
     87                <File path="_source/core/htmlparser.js" /> 
     88                <File path="_source/core/htmlparser/comment.js" /> 
     89                <File path="_source/core/htmlparser/text.js" /> 
     90                <File path="_source/core/htmlparser/fragment.js" /> 
     91                <File path="_source/core/htmlparser/element.js" /> 
     92                <File path="_source/dtd/xhtml1-transitional.js" /> 
    8493                <File path="_source/core/ckeditor.js" /> 
    8594                <File path="_source/core/dom/text.js" /> 
     
    9099                <File path="_source/plugins/elementspath/plugin.js" /> 
    91100                <File path="_source/plugins/htmldataprocessor/plugin.js" /> 
     101                <File path="_source/plugins/htmlwriter/plugin.js" /> 
    92102                <File path="_source/plugins/selection/plugin.js" /> 
    93103                <File path="_source/plugins/sourcearea/plugin.js" /> 
  • CKEditor/branches/prototype/_source/core/config.js

    r2278 r2334  
    136136         * config.plugins = 'editingblock,toolbar,wysiwygarea'; 
    137137         */ 
    138         plugins : 'basicstyles,button,editingblock,elementspath,htmldataprocessor,selection,sourcearea,toolbar,wysiwygarea', 
     138        plugins : 'basicstyles,button,editingblock,elementspath,htmldataprocessor,htmlwriter,selection,sourcearea,toolbar,wysiwygarea', 
    139139 
    140140        /** 
  • CKEditor/branches/prototype/_source/core/dom/node.js

    r2262 r2334  
    4242                switch ( domNode.nodeType ) 
    4343                { 
    44                         case 1 :        // ELEMENT_NODE 
     44                        case CKEDITOR.NODE_ELEMENT : 
    4545                                return new CKEDITOR.dom.element( domNode ); 
    4646 
    47                         case 3 :        // TEXT_NODE 
     47                        case CKEDITOR.NODE_TEXT : 
    4848                                return new CKEDITOR.dom.text( domNode ); 
    4949                } 
     
    6363 
    6464CKEDITOR.dom.node.prototype = new CKEDITOR.dom.domObject(); 
     65 
     66/** 
     67 * Element node type. 
     68 * @constant 
     69 * @example 
     70 */ 
     71CKEDITOR.NODE_ELEMENT   = 1; 
     72 
     73/** 
     74 * Text node type. 
     75 * @constant 
     76 * @example 
     77 */ 
     78CKEDITOR.NODE_TEXT              = 3; 
     79 
     80/** 
     81 * Comment node type. 
     82 * @constant 
     83 * @example 
     84 */ 
     85CKEDITOR.NODE_COMMENT   = 8; 
    6586 
    6687CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, 
  • CKEditor/branches/prototype/_source/core/loader.js

    r2278 r2334  
    3838        var scripts = 
    3939        { 
    40                 'lang/en'                               : [],   // TODO: Remove me 
     40                'lang/en'                               : [],   // TODO: Remove me. This should be handled by the localization code. 
    4141 
    4242                'core/_bootstrap'               : [ 'core/config', 'core/ckeditor', 'core/plugins', 'core/scriptLoader', 'core/tools', /* The following are entries that we wnat to force loading to at the end to avoid dependence recursion */ 'core/dom/text' ], 
    4343                'core/ajax'                             : [ 'core/xml' ], 
    44                 'core/ckeditor'                 : [ 'core/ajax', 'core/ckeditor_basic', 'core/dom', 'core/dom/document', 'core/dom/element', 'core/editor', 'core/event', 'core/tools' ], 
     44                'core/ckeditor'                 : [ 'core/ajax', 'core/ckeditor_basic', 'core/dom', 'core/dom/document', 'core/dom/element', 'core/editor', 'core/event', 'core/htmlparser', 'core/htmlparser/element', 'core/htmlparser/fragment', 'core/tools', 'dtd/xhtml1-transitional' ], 
    4545                'core/ckeditor_base'    : [], 
    4646                'core/ckeditor_basic'   : [ 'core/env', 'core/event' ], 
     
    5757                'core/env'                              : [], 
    5858                'core/event'                    : [], 
     59                'core/htmlparser'               : [], 
     60                'core/htmlparser/comment'       : [ 'core/htmlparser' ], 
     61                'core/htmlparser/element'       : [ 'core/htmlparser', 'core/htmlparser/fragment' ], 
     62                'core/htmlparser/fragment'      : [ 'core/htmlparser', 'core/htmlparser/comment', 'core/htmlparser/text' ], 
     63                'core/htmlparser/text'          : [ 'core/htmlparser' ], 
    5964                'core/plugins'                  : [ 'core/resourceManager' ], 
    6065                'core/resourceManager'  : [ 'core/scriptLoader', 'core/tools' ], 
     
    6469                'core/tools'                    : [ 'core/env' ], 
    6570                'core/ui'                               : [], 
    66                 'core/xml'                              : [ 'core/env' ] 
     71                'core/xml'                              : [ 'core/env' ], 
     72 
     73                'dtd/xhtml1-transitional' : [] 
    6774        }; 
    6875 
  • CKEditor/branches/prototype/_source/core/tools.js

    r2262 r2334  
    7373         * already present in the target object <strong>are not</strong> overwritten. 
    7474         * @param {Object} target The object to be extended. 
    75          * @param {Object} source The object from which copy properties. 
     75         * @param {Object} source[,souce(n)] The objects from which copy 
     76         *              properties. Any number of objects can be passed to this function. 
    7677         * @param {Boolean} [overwrite] Indicates that properties already present 
    77          *              in the target object must be overwritten. 
     78         *              in the target object must be overwritten. This must be the last 
     79         *              parameter in the function call. 
    7880         * @returns {Object} the extended object (target). 
    7981         * @example 
     
    9597         *     alert( p ); 
    9698         */ 
    97         extend : function( target, source, overwrite ) 
    98         { 
    99                 for ( var propertyName in source ) 
    100                 { 
    101                         if ( overwrite || target[ propertyName ] == undefined ) 
    102                                 target[ propertyName ] = source[ propertyName ]; 
     99        extend : function( target ) 
     100        { 
     101                var argsLength = arguments.length, 
     102                        overwrite = arguments[ argsLength - 1 ]; 
     103 
     104                if ( typeof overwrite == 'boolean' ) 
     105                        argsLength--; 
     106                else 
     107                        overwrite = false; 
     108 
     109                for ( var i = 1 ; i < argsLength ; i++ ) 
     110                { 
     111                        var source = arguments[ i ]; 
     112 
     113                        for ( var propertyName in source ) 
     114                        { 
     115                                if ( overwrite || target[ propertyName ] == undefined ) 
     116                                        target[ propertyName ] = source[ propertyName ]; 
     117                        } 
    103118                } 
     119 
    104120                return target; 
    105121        }, 
     
    223239                        }, 
    224240                        milliseconds || 0 ); 
    225         } 
     241        }, 
     242 
     243        /** 
     244         * Remove spaces from the start and the end of a string. The following 
     245         * characters are removed: space, tab, line break, line feed. 
     246         * @param {String} str The text from which remove the spaces. 
     247         * @returns {String} The modified string without the boundary spaces. 
     248         * @example 
     249         * alert( CKEDITOR.tools.trim( '  example ' );  // "example" 
     250         */ 
     251        trim : (function() 
     252        { 
     253                // We are not using \s because we don't want "non-breaking spaces" to be caught. 
     254                var trimRegex = /(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g; 
     255                return function( str ) 
     256                { 
     257                        return str.replace( trimRegex, '' ) ; 
     258                }; 
     259        })(), 
     260 
     261        /** 
     262         * Remove spaces from the start (left) of a string. The following 
     263         * characters are removed: space, tab, line break, line feed. 
     264         * @param {String} str The text from which remove the spaces. 
     265         * @returns {String} The modified string excluding the removed spaces. 
     266         * @example 
     267         * alert( CKEDITOR.tools.ltrim( '  example ' );  // "example " 
     268         */ 
     269        ltrim : (function() 
     270        { 
     271                // We are not using \s because we don't want "non-breaking spaces" to be caught. 
     272                var trimRegex = /(?:^[ \t\n\r]+)/g; 
     273                return function( str ) 
     274                { 
     275                        return str.replace( trimRegex, '' ) ; 
     276                }; 
     277        })(), 
     278 
     279        /** 
     280         * Remove spaces from the end (right) of a string. The following 
     281         * characters are removed: space, tab, line break, line feed. 
     282         * @param {String} str The text from which remove the spaces. 
     283         * @returns {String} The modified string excluding the removed spaces. 
     284         * @example 
     285         * alert( CKEDITOR.tools.ltrim( '  example ' );  // "  example" 
     286         */ 
     287        rtrim : (function() 
     288        { 
     289                // We are not using \s because we don't want "non-breaking spaces" to be caught. 
     290                var trimRegex = /(?:[ \t\n\r]+$)/g; 
     291                return function( str ) 
     292                { 
     293                        return str.replace( trimRegex, '' ) ; 
     294                }; 
     295        })() 
    226296}; 
  • CKEditor/branches/prototype/_source/plugins/htmldataprocessor/plugin.js

    r2180 r2334  
    3232                        }, 
    3333 
    34                         toDataFormat : function( node ) 
     34                        toDataFormat : function( element ) 
    3535                        { 
    36                                 // For now, there is no processing of the HTML. 
    37                                 return node.getHtml(); 
    38                         } 
     36                                var writer = this.writer, 
     37                                        fragment = CKEDITOR.htmlParser.fragment.fromHtml( element.getHtml() ); 
     38 
     39                                writer.reset(); 
     40 
     41                                fragment.writeHtml( writer ); 
     42 
     43                                return writer.getHtml( true ); 
     44                        }, 
     45 
     46                        writer : new CKEDITOR.htmlWriter() 
    3947                }; 
    4048        }