Ticket #3415: 3415.patch

File 3415.patch, 8.8 KB (added by Martin Kou, 15 years ago)
  • _source/plugins/pastetext/dialogs/pastetext.js

     
    77{
    88        CKEDITOR.dialog.add( 'pastetext', function( editor )
    99                {
    10                         var textareaId = 'cke_' + CKEDITOR.tools.getNextNumber();
    11 
    1210                        return {
    1311                                title : editor.lang.pasteText.title,
    1412
     
    1816                                onShow : function()
    1917                                {
    2018                                        // Reset the textarea value.
    21                                         CKEDITOR.document.getById( textareaId ).setValue( '' );
     19                                        this.getContentElement( 'general', 'content' ).getInputElement().setValue( '' );
    2220                                },
    2321
    2422                                onOk : function()
    2523                                {
    2624                                        // Get the textarea value.
    27                                         var text = CKEDITOR.document.getById( textareaId ).getValue();
     25                                        var text = this.getContentElement( 'general', 'content' ).getInputElement().getValue();
    2826
    2927                                        // Inserts the text.
    3028                                        this.getParentEditor().insertText( text );
     
    3432                                [
    3533                                        {
    3634                                                label : editor.lang.common.generalTab,
     35                                                id : 'general',
    3736                                                elements :
    3837                                                [
    3938                                                        {
     
    4645                                                                id : 'content',
    4746                                                                style : 'width:340px;height:170px',
    4847                                                                html :
    49                                                                         '<textarea id="' + textareaId + '" style="' +
     48                                                                        '<textarea style="' +
    5049                                                                                'width:346px;' +
    5150                                                                                'height:170px;' +
    5251                                                                                'resize: none;' +
    5352                                                                                'border:1px solid black;' +
    5453                                                                                'background-color:white">' +
    55                                                                         '</textarea>'
     54                                                                        '</textarea>',
     55                                                                focus : function()
     56                                                                {
     57                                                                        this.getElement().focus();
     58                                                                }
    5659                                                        }
    5760                                                ]
    5861                                        }
  • _source/plugins/clipboard/dialogs/paste.js

     
    77{
    88        var isCustomDomain = CKEDITOR.env.ie && document.domain != window.location.hostname;
    99
    10         var iframeId = 'cke_' + CKEDITOR.tools.getNextNumber();
    11 
    12         // For document.domain compatibility (#123) we must do all the magic in
    13         // the URL for IE.
    14         var src =
    15                 isCustomDomain ?
    16                         'javascript:void((function(){' +
    17                                 'document.open();' +
    18                                 'document.domain=\'' + document.domain + '\';' +
    19                                 'document.write( window.parent.CKEDITOR._htmlToLoad );' +
    20                                 'document.close();' +
    21                                 'document.body.contentEditable = true;' +
    22                                 'delete window.parent.CKEDITOR._htmlToLoad;' +
    23                                 'window.focus();' +
    24                         '})())'
    25                 :
    26                         'javascript:void(0)';
    27 
    28         var iframeHtml =
    29                 '<iframe' +
    30                         ' src="' + src + '"' +
    31                         ' id="' + iframeId + '"' +
    32                         ' style="width:346px;background-color:white;height:130px;border:1px solid black"' +
    33                         ' frameborder="0"' +
    34                         ' allowtransparency="1">' +
    35                 '</iframe>';
    36 
    37         var htmlToLoad =
    38                 '<!doctype html>' +
    39                 '<script type="text/javascript">' +
    40                         'window.onload = function()' +
    41                         '{' +
    42                                 ( CKEDITOR.env.ie ?
    43                                         'document.body.contentEditable = "true";' :
    44                                         'document.designMode = "on";' ) +
    45                                 'window.focus();' +
    46                         '};' +
    47                         // Avoid errors if the pasted content has any script that
    48                         // fails. (#389)
    49                         'window.onerror = function()' +
    50                         '{' +
    51                                 'return true;' +
    52                         '};' +
    53                 '</script><body style="margin:3px"></body>';
    54 
    5510        return {
    5611                title : editor.lang.clipboard.title,
    5712
    5813                minWidth : 350,
    5914                minHeight : 240,
     15                htmlToLoad : '<!doctype html><script type="text/javascript">'
     16                                + 'window.onload = function()'
     17                                + '{'
     18                                        + 'if ( ' + CKEDITOR.env.ie + ' ) '
     19                                                + 'document.body.contentEditable = "true";'
     20                                        + 'else '
     21                                                + 'document.designMode = "on";'
     22                                        + 'var iframe = new window.parent.CKEDITOR.dom.element( frameElement );'
     23                                        + 'var dialog = iframe.getCustomData( "dialog" );'
     24                                        + 'dialog.fire( "iframeAdded", { iframe : iframe } );'
     25                                + '};'
     26                                + '</script><style>body { margin: 3px; height: 95%; } </style><body></body>',
    6027
    6128                onShow : function()
    6229                {
    63                         if ( isCustomDomain )
    64                                 CKEDITOR._htmlToLoad = htmlToLoad;
     30                        if ( CKEDITOR.env.ie )
     31                                this.getParentEditor().document.getBody().$.contentEditable = 'false';
     32
     33                        // FIREFOX BUG: Force the browser to render the dialog to make the to-be-
     34                        // inserted iframe editable. (#3366)
     35                        this.parts.dialog.$.offsetHeight;
     36                       
     37                        var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
     38                                iframe = CKEDITOR.dom.element.createFromHtml( '<iframe src="javascript:void(0)" frameborder="0" allowtransparency="1"></iframe>' );
     39
     40                        var lang = this.getParentEditor().lang;
     41
     42                        iframe.setStyles(
     43                                {
     44                                        width : '346px',
     45                                        height : '130px',
     46                                        'background-color' : 'white',
     47                                        border : '1px solid black'
     48                                } );
     49                        iframe.setCustomData( 'dialog', this );
     50
     51                        var accTitle = lang.editorTitle.replace( '%1', lang.clipboard.title );
     52
     53                        if ( CKEDITOR.env.ie )
     54                                container.setHtml( '<legend style="position:absolute;top:-1000000px;left:-1000000px;">'
     55                                                + CKEDITOR.tools.htmlEncode( accTitle )
     56                                                + '</legend>' );
    6557                        else
    6658                        {
    67                                 var iframe = CKEDITOR.document.getById( iframeId );
     59                                container.setHtml( '' );
     60                                container.setAttributes(
     61                                        {
     62                                                role : 'region',
     63                                                title : accTitle
     64                                        } );
     65                                iframe.setAttributes(
     66                                        {
     67                                                role : 'region',
     68                                                title : ' '
     69                                        } );
     70                        }
     71                        container.append( iframe );
     72                        if ( CKEDITOR.env.ie )
     73                                container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' );
    6874
    69                                 var $doc = iframe.$.contentWindow.document;
    70                                 $doc.open();
    71                                 $doc.write( htmlToLoad );
    72                                 $doc.close();
    73 
    74                                 iframe.$.contentWindow.focus();
     75                        if ( isCustomDomain )
     76                        {
     77                                CKEDITOR._cke_htmlToLoad = this.definition.htmlToLoad;
     78                                iframe.setAttribute( 'src',
     79                                        'javascript:void( (function(){' +
     80                                                   'document.open();' +
     81                                                   'document.domain="' + document.domain + '";' +
     82                                                   'document.write( window.parent.CKEDITOR._cke_htmlToLoad );' +
     83                                                   'delete window.parent.CKEDITOR._cke_htmlToLoad;' +
     84                                                   'document.close();' +
     85                                        '})() )' );
    7586                        }
     87                        else
     88                        {
     89                                var doc = iframe.$.contentWindow.document;
     90                                doc.open();
     91                                doc.write( this.definition.htmlToLoad );
     92                                doc.close();
     93                        }
    7694                },
    7795
     96                onHide : function()
     97                {
     98                        if ( CKEDITOR.env.ie )
     99                                this.getParentEditor().document.getBody().$.contentEditable = 'true';
     100                },
     101
    78102                onOk : function()
    79103                {
    80                         var iframe = CKEDITOR.document.getById( iframeId );
     104                        var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
     105                                iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ),
     106                                editor = this.getParentEditor(),
     107                                html = iframe.$.contentWindow.document.body.innerHTML;
    81108
    82                         var body = new CKEDITOR.dom.element(
    83                                 iframe.$.contentDocument ?
    84                                         iframe.$.contentDocument.body :
    85                                         iframe.$.contentWindow.document.body ) ;
     109                        editor.insertHtml( html );
    86110
    87                         var html = body.getHtml();
    88 
    89                         // Fix relative anchor URLs (IE automatically adds the current page URL).
    90                         var re = new RegExp( window.location + "#", 'g' );
    91                         html = html.replace( re, '#');
    92 
    93                         this.getParentEditor().insertHtml( html );
    94111                },
    95112
    96113                contents : [
     
    110127                                        },
    111128                                        {
    112129                                                type : 'html',
    113                                                 id : 'content',
    114                                                 style : 'width:340px;height:130px',
    115                                                 html : '<div>' + iframeHtml + '</div>'
     130                                                id : 'editing_area',
     131                                                style : 'width: 100%; height: 100%;',
     132                                                html : '<fieldset></fieldset>',
     133                                                focus : function()
     134                                                {
     135                                                        var div = this.getElement();
     136                                                        var iframe = div.getElementsByTag( 'iframe' );
     137                                                        if ( iframe.count() < 1 )
     138                                                                return;
     139                                                        iframe = iframe.getItem( 0 );
     140
     141                                                        // #3291 : JAWS needs the 500ms delay to detect that the editor iframe
     142                                                        // iframe is no longer editable. So that it will put the focus into the
     143                                                        // Paste from Word dialog's editable area instead.
     144                                                        setTimeout( function()
     145                                                        {
     146                                                                iframe.$.contentWindow.focus();
     147                                                        }, 500 );
     148                                                }
    116149                                        }
    117150                                ]
    118151                        }
  • _source/plugins/pastefromword/dialogs/pastefromword.js

     
    209209                onOk : function()
    210210                {
    211211                        var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
    212                                 iframe = container.getFirst(),
     212                                iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ),
    213213                                editor = this.getParentEditor(),
    214214                                html = this.definition.cleanWord( editor, iframe.$.contentWindow.document.body.innerHTML,
    215215                                                this.getValueOf( 'general', 'ignoreFontFace' ),
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy