Changeset 718 for trunk/plugins


Ignore:
Timestamp:
02/08/07 13:09:56 (12 years ago)
Author:
ray
Message:
  • PasteText? general update
  • Ticket #943 Paste Plain Text bad syntax when pasting in p or inline element
  • added checkbox to let the user select if the text is to be wrapped in paragraphs
  • added config to select whether the checkbox is to be displayed
  • added config to set initial state of checkbox
Location:
trunk/plugins/PasteText
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/PasteText/paste-text.js

    r677 r718  
    1 // Paste Plain Text plugin for HTMLArea 
     1// Paste Plain Text plugin for Xinha 
    22 
    3 // Distributed under the same terms as HTMLArea itself. 
     3// Distributed under the same terms as Xinha itself. 
    44// This notice MUST stay intact for use (see license.txt). 
    55 
    66function PasteText(editor) { 
    7   this.editor = editor; 
     7        this.editor = editor; 
    88        var cfg = editor.config; 
    99        var self = this; 
     
    1919            }); 
    2020 
    21   cfg.addToolbarElement("pastetext", ["paste", "killword"], 1); 
    22  
     21        cfg.addToolbarElement("pastetext", ["paste", "killword"], 1); 
    2322} 
    2423 
    2524PasteText._pluginInfo = { 
    2625        name          : "PasteText", 
    27         version       : "1.1", 
     26        version       : "1.2", 
    2827        developer     : "Michael Harris", 
    2928        developer_url : "http://www.jonesadvisorygroup.com", 
     
    3534 
    3635PasteText.prototype._lc = function(string) { 
    37     return HTMLArea._lc(string, 'PasteText'); 
     36    return Xinha._lc(string, 'PasteText'); 
    3837}; 
     38 
     39Xinha.Config.prototype.PasteText = 
     40{ 
     41        showParagraphOption : true, 
     42        newParagraphDefault :true 
     43} 
    3944 
    4045PasteText.prototype.buttonPress = function(editor) { 
    4146 
    42         outparam = { 
    43                  
    44         };  
    45         html=" "; 
    46         editor._popupDialog( "plugin://PasteText/paste_text", function( html ) { 
     47        var editor = this.editor; 
     48        var outparam = editor.config.PasteText;  
     49        var action = function( ret ) { 
     50                var html = ret.text; 
     51                var insertParagraphs = ret.insertParagraphs; 
    4752                html = html.replace(/</g, "&lt;"); 
    4853                html = html.replace(/>/g, "&gt;"); 
    49                 html = html.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"); 
    50                 html = html.replace(/\n/g,"</p><p>"); 
    51                 html="<p>"+html; 
    52                 editor.insertHTML(html); 
    53         }, outparam); 
     54                if ( ret.insertParagraphs) 
     55                { 
     56                        html = html.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;"); 
     57                        html = html.replace(/\n/g,"</p><p>"); 
     58                        html="<p>" + html + "</p>"; 
     59                        if (Xinha.is_ie) 
     60                        { 
     61                                editor.insertHTML(html); 
     62                        } 
     63                        else 
     64                        { 
     65                                editor.execCommand("inserthtml",false,html); 
     66                        } 
     67                } 
     68                else 
     69                { 
     70                        html = html.replace(/\n/g,"<br />"); 
     71                        editor.insertHTML(html); 
     72                } 
     73        } 
     74        Dialog( _editor_url+ "plugins/PasteText/popups/paste_text.html", action, outparam); 
    5475}; 
  • trunk/plugins/PasteText/popups/paste_text.html

    r677 r718  
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
    2 <html> 
     1<!DOCTYPE html 
     2     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
     3    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
     4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    35<head> 
    46  <title>Paste Text</title> 
    57  <link rel="stylesheet" type="text/css" href="../../../popups/popup.css" /> 
    68  <script type="text/javascript" src="../../../popups/popup.js"></script> 
    7 <script language="javascript"> 
     9<script type="text/javascript"> 
    810 
    9 function _CloseOnEsc(event) { 
    10   if ( event.keyCode == 27 ) { 
    11     window.close(); 
    12     return; 
    13   } 
    14 } 
     11function init() { 
    1512 
    16 function Init() { 
    1713  __dlg_translate("PasteText"); 
    18   __dlg_init(); 
    19   window.resizeTo(600, 450); 
     14  __dlg_init(null,{width:600,height:480}); 
     15 
    2016  var param = window.dialogArguments; 
    21   document.getElementById("SCREEN").focus(); 
     17  document.getElementById("paragraphOption").style.display = (param.showParagraphOption) ? '' : 'none'; 
     18   document.getElementById("insertParagraphs").checked = param.newParagraphDefault; 
     19  document.getElementById("inputArea").focus(); 
    2220} 
    2321 
     
    2826 
    2927function onOK() { 
    30   var ret = document.getElementById("SCREEN").value; 
     28  var ret = {}; 
     29  ret.text = document.getElementById("inputArea").value; 
     30  ret.insertParagraphs = document.getElementById("insertParagraphs").checked; 
    3131  __dlg_close( ret ); 
    3232} 
     33window.onload = init; 
    3334</script> 
    3435</head> 
    3536 
    36 <body class="dialog" onload="Init();"> 
     37<body class="dialog"> 
    3738<div class="title">Paste as Plain Text</div> 
    38 <textarea name="SCREEN" id="SCREEN" cols=22 rows=5 style="width: 100%; height: 315px; margin-top: 8px; margin-bottom: 4px; font-family: monospace; font-size: 11px;"></textarea> 
     39<textarea name="inputArea" id="inputArea" cols=22 rows=5 style="width: 100%; height: 315px; margin-top: 8px; margin-bottom: 4px; font-family: monospace; font-size: 11px;"></textarea> 
    3940<div id="buttons"> 
    40     <button type="submit" name="ok" onclick="return onOK();">OK</button> 
     41<label for="insertParagraphs" style="float:left;display:none" id="paragraphOption"> 
     42<input type="checkbox" id="insertParagraphs" /> Insert text in new paragraph  
     43</label> 
     44    <button type="button" name="ok" onclick="return onOK();">OK</button> 
    4145    <button type="button" name="cancel" onclick="return onCancel();">Cancel</button> 
    4246</div> 
Note: See TracChangeset for help on using the changeset viewer.