Ticket #4341: 4341_2.patch

File 4341_2.patch, 6.1 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/showborders/assets/showtableborders.htc

     
     1<public:component lightweight="true">
     2
     3<public:attach event="oncontentready" onevent="ShowBorders()" />
     4<public:attach event="onpropertychange" onevent="OnPropertyChange()" />
     5
     6<script language="javascript">
     7
     8var oClassRegex = /\s*cke_no_border/ ;
     9
     10function ShowBorders()
     11{
     12        if ( this.border == 0 )
     13        {
     14                if ( !oClassRegex.test( this.className ) )
     15                        this.className += ' cke_no_border' ;
     16        }
     17        else
     18        {
     19                if ( oClassRegex.test( this.className ) )
     20                {
     21                        this.className = this.className.replace( oClassRegex, '' ) ;
     22                        if ( this.className.length == 0 )
     23                                this.removeAttribute( 'className', 0 ) ;
     24                }
     25        }
     26}
     27
     28function OnPropertyChange()
     29{
     30        if ( event.propertyName == 'border' || event.propertyName == 'className' )
     31                ShowBorders.call(this) ;
     32}
     33
     34</script>
     35
     36</public:component>
  • _source/core/config.js

     
    198198         * @type String
    199199         * @example
    200200         */
    201         plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
     201        plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,showborders,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    202202
    203203        /**
    204204         * List of additional plugins to be loaded. This is a tool setting which
     
    282282         * @example
    283283         * config.baseFloatZIndex = 2000
    284284         */
    285         baseFloatZIndex : 10000
     285        baseFloatZIndex : 10000,
    286286
     287        /**
     288         * Whether to automaticaly enable the "show borders" command when the editor
     289         * loads.
     290         * @type Boolean
     291         * @default false
     292         * @example
     293         * config.startupShowBorders = false;
     294         */
     295        startupShowBorders : true
    287296};
    288297
    289298// PACKAGER_RENAME( CKEDITOR.config )
  • _source/plugins/showborders/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6/**
     7 * @fileOverview The "show border" plugin. The command display visible outline
     8 * border line around all table elements if table doesn't have a none-zero 'border' attribute specified.
     9 */
     10
     11(function()
     12{
     13        var cssStyleText,
     14                cssTemplate =
     15                // TODO: For IE6, we don't have child selector support, where nested table style could be incorrect.
     16                ( CKEDITOR.env.ie6Compat ?
     17                  [
     18                        '.%1 table%2,',
     19                         '.%1 table%2 td, .%1 table%2 th,',
     20                         '{',
     21                                'border : #d3d3d3 1px dotted',
     22                         '}'
     23                  ] :
     24                  [
     25                         '.%1 table%2,',
     26                         '.%1 table%2 > tr > td, .%1 table%2 > tr > th,',
     27                         '.%1 table%2 > tbody > tr > td, .%1 table%2 > tbody > tr > th,',
     28                         '.%1 table%2 > thead > tr > td, .%1 table%2 > thead > tr > th,',
     29                         '.%1 table%2 > tfoot > tr > td, .%1 table%2 > tfoot > tr > th',
     30                         '{',
     31                                'border : #d3d3d3 1px dotted',
     32                         '}'
     33                  ] ).join( '' );
     34
     35        if( CKEDITOR.env.ie )
     36        {
     37                // For IE we use a HTC behavior on table to mimic the desired selector.
     38                cssStyleText =
     39                [
     40                        cssTemplate.replace( /%2/g, '.cke_no_border' )
     41                ];
     42        }
     43        else
     44        {
     45                cssStyleText =
     46                [
     47                        // For tables with the "border" attribute set to "0" , IE7 doesn't support
     48                        // attribute selector on 'border' particularly (weirld).
     49                        cssTemplate.replace( /%2/g, '[border="0"]' ),
     50                        // For tables with no "border" attribute set, IE8 doesn't support CSS3
     51                        // pseudo selector: not(...)
     52                        cssTemplate.replace( /%2/g, ':not([border])' )
     53                ];
     54        }
     55
     56        var commandDefinition =
     57        {
     58                preserveState : true,
     59                editorFocus : false,
     60
     61                exec : function ( editor )
     62                {
     63                        this.toggleState();
     64                        this.refresh( editor );
     65                },
     66
     67                refresh : function( editor )
     68                {
     69                        var funcName = ( this.state == CKEDITOR.TRISTATE_ON ) ? 'addClass' : 'removeClass';
     70                        editor.document.getBody()[ funcName ]( 'cke_show_borders' );
     71                }
     72        };
     73
     74        CKEDITOR.plugins.add( 'showborders',
     75        {
     76                requires : [ 'wysiwygarea' ],
     77                modes : { 'wysiwyg' : 1 },
     78
     79                init : function( editor )
     80                {
     81                        if( CKEDITOR.env.ie )
     82                                cssStyleText.push( 'table', '{ behavior: ' + 'url(' + this.path + 'assets/showtableborders.htc)' + '; }' );
     83
     84                        var command = editor.addCommand( 'showborders', commandDefinition );
     85                        command.canUndo = false;
     86
     87                        if ( editor.config.startupShowBorders )
     88                                command.setState( CKEDITOR.TRISTATE_ON );
     89
     90                        editor.addCss( cssStyleText.join( '\n' ).
     91                                                        replace( /%1/g, 'cke_show_borders ' ) );
     92                       
     93                        // Refresh the command on setData.
     94                        editor.on( 'mode', function()
     95                                {
     96                                        if ( command.state != CKEDITOR.TRISTATE_DISABLED )
     97                                                command.refresh( editor );
     98                                }, null, null, 100 );
     99
     100                        // Refresh the command on wysiwyg frame reloads.
     101                        editor.on( 'contentDom', function()
     102                                {
     103                                        if ( command.state != CKEDITOR.TRISTATE_DISABLED )
     104                                                command.refresh( editor );
     105                                });
     106                }
     107        });
     108} )();
     109
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy