Changeset 962


Ignore:
Timestamp:
02/04/08 00:43:21 (6 years ago)
Author:
ray
Message:
  • #1149 [Safari] retain editing position doesn't work
  • #1148 HTML entities break when cursor is inside when switching from HTML to WYSIWYG
  • #1147 getSelectedHTML() throws error when nothing is selected
  • #1146 [ExtendedFileManager] IE6 doesn't show images
Location:
trunk
Files:
10 deleted
13 edited
11 copied

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r961 r962  
    44444444 
    44454445    } catch (ex) {} 
    4446     } 
     4446  } 
    44474447   
    44484448  var btn = editor._toolbarObjects[cmdID].element; 
     
    45954595    case 'justifyleft'  : 
    45964596    case 'justifyright' : 
     4597    { 
    45974598      cmdID.match(/^justify(.*)$/); 
    45984599      var ae = this.activeElement(this.getSelection());       
     
    46054606        this._doc.execCommand(cmdID, UI, param); 
    46064607      } 
     4608    }     
    46074609    break; 
    46084610     
  • trunk/XinhaLoader.js

    r961 r962  
    190190    arguments.callee.done = true; 
    191191    // kill the timer 
    192          
    193192    if (Xinha.onloadTimer) clearInterval(Xinha.onloadTimer); 
    194193     
  • trunk/examples/Newbie.html

    r917 r962  
    1818<form action=""> 
    1919<div> 
    20 <textarea id="myTextArea" name="myTextArea" rows="10" cols="50" style="width: 100%"></textarea> 
     20<textarea id="myTextArea" name="myTextArea" rows="25" cols="50" style="width: 100%"></textarea> 
    2121</div> 
    2222</form> 
  • trunk/examples/XinhaConfig.js

    r937 r962  
    3939   'CharacterMap', 
    4040   'ContextMenu', 
    41    'ListType', 
     41   'SmartReplace', 
    4242   'Stylist', 
    4343   'Linker', 
  • trunk/examples/simple_example.html

    r836 r962  
    55<title>Simple example of Xinha</title> 
    66<script type="text/javascript"> 
    7 /************************************************************************ 
    8  * Please refer to http://xinha.python-hosting.com/wiki/NewbieGuide 
    9  ************************************************************************ 
    10  * You must set _editor_url to the URL (including trailing slash) where 
    11  * where xinha is installed, it's highly recommended to use an absolute URL 
    12  *  eg: _editor_url = "/path/to/xinha/"; 
    13  * You may try a relative URL if you wish] 
    14  *  eg: _editor_url = "../";   
    15  * in this example we do a little regular expression to find the absolute path. 
    16  ************************************************************************/ 
    177var _editor_url  = document.location.href.replace(/examples\/simple_example\.html.*/, '') 
    18 // And the language we need to use in the editor. 
     8 
    199var _editor_lang = "en"; 
    2010</script> 
     
    2212<script type="text/javascript" src="../XinhaCore.js"></script> 
    2313<script type="text/javascript"> 
    24 /************************************************************************ 
    25  * Plugins you will be using in the editors on this page. 
    26  * List all the plugins you will need, even if not all the editors will 
    27  * use all the plugins. 
    28  ************************************************************************ 
    29  * Please refer to http://xinha.python-hosting.com/wiki/Plugins for the 
    30  * list of availables plugins 
    31  ************************************************************************/ 
     14 
    3215var xinha_plugins = 
    3316[ 
    34  'CharacterMap', 
    35  'ContextMenu',  
    36  'ListType', 
    37  'SpellChecker', 
    38  'Stylist', 
    39  'SuperClean', 
    40  'TableOperations' 
     17 'Linker' 
    4118]; 
    42 /************************************************************************ 
    43  * Names of the textareas you will be turning into editors 
    44  ************************************************************************/ 
    4519var xinha_editors = 
    4620[ 
     
    4822  'anotherOne' 
    4923]; 
    50 /************************************************************************ 
    51  * Initialisation function 
    52  ************************************************************************/ 
     24 
    5325function xinha_init() 
    5426{ 
    55   // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :) 
    5627  if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return; 
    57   /************************************************************************* 
    58    * We create a default configuration to be used by all the editors. 
    59    * If you wish to configure some of the editors differently this will be 
    60    * done later after editors are initiated. 
    61    ************************************************************************ 
    62    * Please refer to http://xinha.python-hosting.com/wiki/Documentation/Customise 
    63    * for the configuration parameters 
    64    ************************************************************************/ 
     28 
    6529  var xinha_config = new Xinha.Config(); 
    66   /************************************************************************ 
    67    * We first create editors for the textareas. 
    68    * You can do this in two ways, either 
    69    * 
    70    *   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins); 
    71    * 
    72    * if you want all the editor objects to use the same set of plugins, OR; 
    73    * 
    74    *   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config); 
    75    *   xinha_editors['myTextArea'].registerPlugins(['Stylist']); 
    76    *   xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']); 
    77    * 
    78    * if you want to use a different set of plugins for one or more of the 
    79    * editors. 
    80    ************************************************************************/ 
     30 
    8131  xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins); 
    82   /************************************************************************ 
    83    * If you want to change the configuration variables of any of the 
    84    * editors,  this is the place to do that, for example you might want to 
    85    * change the width and height of one of the editors, like this... 
    86    ************************************************************************/ 
    87   xinha_editors.myTextArea.config.width = '640px'; 
    88   xinha_editors.myTextArea.config.height = '480px'; 
    89   /************************************************************************ 
    90    * Or remove the statusbar on the other one, like this... 
    91    * For every possible configuration, please refer to 
    92    * http://xinha.python-hosting.com/wiki/Documentation/ConfigVariablesList 
    93    ************************************************************************/ 
    94   xinha_editors.anotherOne.config.statusBar = false; 
    95   /************************************************************************ 
    96    * Finally we "start" the editors, this turns the textareas into 
    97    * Xinha editors. 
    98    ************************************************************************/ 
     32 
    9933  Xinha.startEditors(xinha_editors); 
    10034} 
    101 window.onload = xinha_init; 
     35Xinha.addOnloadHandler(xinha_init); 
    10236</script> 
    103 <link type="text/css" rel="stylesheet" title="blue-look" href="../skins/blue-look/skin.css"> 
    104 <link type="text/css" rel="alternate stylesheet" title="green-look" href="../skins/green-look/skin.css"> 
    105 <link type="text/css" rel="alternate stylesheet" title="xp-blue" href="../skins/xp-blue/skin.css"> 
    106 <link type="text/css" rel="alternate stylesheet" title="xp-green" href="../skins/xp-green/skin.css"> 
    107 <link type="text/css" rel="alternate stylesheet" title="inditreuse" href="../skins/inditreuse/skin.css"> 
    108 <link type="text/css" rel="alternate stylesheet" title="blue-metallic" href="../skins/blue-metallic/skin.css"> 
     37 
    10938</head> 
    11039 
    11140<body> 
    11241 
    113 <form onsubmit="alert(this.myTextArea.value); alert(this.anotherOne.value); return false;"> 
    114 <textarea id="myTextArea" name="myTextArea" rows="10" cols="80" style="width:100%"> 
     42<form onsubmit="alert(this.myTextArea.value); return false;"> 
     43<textarea id="myTextArea" name="myTextArea" rows="25" cols="80"> 
    11544&lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
    11645Aliquam et tellus vitae justo varius placerat. Suspendisse iaculis 
     
    12150Curabitur pharetra bibendum lectus.&lt;/p&gt; 
    12251</textarea> 
    123 <textarea id="anotherOne" name="anotherOne" rows="10" cols="80" style="width:100%"> 
    124 &lt;ul&gt; 
    125 &lt;li&gt; Phasellus et massa sed diam viverra semper.  &lt;/li&gt; 
    126 &lt;li&gt; Mauris tincidunt felis in odio.              &lt;/li&gt; 
    127 &lt;li&gt; Nulla placerat nunc ut pede.                 &lt;/li&gt; 
    128 &lt;li&gt; Vivamus ultrices mi sit amet urna.           &lt;/li&gt; 
    129 &lt;li&gt; Quisque sed augue quis nunc laoreet volutpat.&lt;/li&gt; 
    130 &lt;li&gt; Nunc sit amet metus in tortor semper mattis. &lt;/li&gt; 
    131 &lt;/ul&gt; 
    132 </textarea> 
    133 <input type="submit"> 
    134 </form> 
    13552 
    13653</body> 
  • trunk/examples/testbed.html

    r897 r962  
    154154      &lt;/head&gt; 
    155155      &lt;body&gt; 
    156       &lt;img src="http://xinha.python-hosting.com/trac/logo.jpg" usemap="#m1"&gt; 
     156      &lt;img src="../images/xinha_logo.gif" usemap="#m1"&gt; 
    157157      &lt;map name="m1"&gt; 
    158158      &lt;area shape="rect" coords="137,101,255,124" href="http://www.mydomain.com"&gt; 
  • trunk/modules/Gecko/Gecko.js

    r957 r962  
    189189/*  This is now handled by a plugin   
    190190    case 13: // ENTER 
    191       if( !ev.shiftKey && editor.config.mozParaHandler == 'dirty' ) 
    192       { 
    193         this.dom_checkInsertP(); 
    194         Xinha._stopEvent(ev); 
    195       } 
     191 
    196192    break;*/ 
    197193 
     
    620616{ 
    621617  var sel = this.getSelection(); 
     618  if (sel.isCollapsed) return ''; 
    622619  var range = this.createRange(sel); 
    623620  return Xinha.getHTML(range.cloneContents(), false, this); 
     
    710707      var after = ta.value.substring( index, ta.value.length ); 
    711708 
    712       if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, and inside the body) 
     709      if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, entities, and inside the body) 
    713710      { 
    714711        var tagEnd = after.indexOf(">") + 1; 
     
    716713      } 
    717714      else ta.value = before + cc + after; 
     715      ta.value = ta.value.replace(new RegExp ('(&[^'+cc+']*?)('+cc+')([^'+cc+']*?;)'), "$1$3$2"); 
    718716      ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); 
    719717      ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); 
  • trunk/modules/InternetExplorer/InternetExplorer.js

    r943 r962  
    455455{ 
    456456  var sel = this.getSelection(); 
     457  if (this.selectionEmpty) return ''; 
    457458  var range = this.createRange(sel); 
    458459   
     
    542543    var after  = ta.value.substring( index + cc.length , ta.value.length ); 
    543544     
    544     if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, and inside the body) 
     545    if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, entities, and inside the body) 
    545546    { 
    546547      var tagEnd = after.indexOf(">") + 1; 
     
    548549    } 
    549550    else ta.value = before + cc + after; 
     551    ta.value = ta.value.replace(new RegExp ('(&[^'+cc+']*?)('+cc+')([^'+cc+']*?;)'), "$1$3$2"); 
    550552    ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); 
    551553    ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); 
  • trunk/modules/WebKit/WebKit.js

    • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
    r961 r962  
    1414    -- 
    1515    --  The file is loaded as a special plugin by the Xinha Core when 
    16     --  Xinha is being run under a Webkit based browser with the Midas 
    17     --  editing API. 
     16    --  Xinha is being run under a Webkit based browser such as Safari 
    1817    -- 
    1918    --  It provides implementation and specialisation for various methods 
     
    2625    --   that way. 
    2726    -- 
    28     --  $HeadURL: http://svn.xinha.webfactional.com/trunk/modules/Gecko/Gecko.js $ 
    29     --  $LastChangedDate: 2007-10-12 12:00:47 +0200 (Fr, 12 Okt 2007) $ 
    30     --  $LastChangedRevision: 901 $ 
    31     --  $LastChangedBy: ray $ 
     27    --  $HeadURL$ 
     28    --  $LastChangedDate$ 
     29    --  $LastChangedRevision$ 
     30    --  $LastChangedBy$ 
    3231    --------------------------------------------------------------------------*/ 
    3332                                                     
     
    3534  name          : "WebKit", 
    3635  origin        : "Xinha Core", 
    37   version       : "$LastChangedRevision: 901 $".replace(/^[^:]*: (.*) \$$/, '$1'), 
     36  version       : "$LastChangedRevision$".replace(/^[^:]*: (.*) \$$/, '$1'), 
    3837  developer     : "The Xinha Core Developer Team", 
    39   developer_url : "$HeadURL: http://svn.xinha.webfactional.com/trunk/modules/Gecko/Gecko.js $".replace(/^[^:]*: (.*) \$$/, '$1'), 
     38  developer_url : "$HeadURL$".replace(/^[^:]*: (.*) \$$/, '$1'), 
    4039  sponsor       : "", 
    4140  sponsor_url   : "", 
     
    4847} 
    4948 
    50 /** Allow Gecko to handle some key events in a special way. 
     49/** Allow Webkit to handle some key events in a special way. 
    5150 */ 
    5251   
     
    568567{ 
    569568  var sel = this.getSelection(); 
     569  if (sel.isCollapsed) return ''; 
    570570  var range = this.createRange(sel); 
    571571 
     
    651651}; 
    652652 
    653 //Control character for retaining edit location when switching modes 
    654 Xinha.prototype.cc = String.fromCharCode(173);  
     653Xinha.prototype.cc = String.fromCharCode(8286);  
    655654 
    656655Xinha.prototype.setCC = function ( target ) 
     
    666665      var after = ta.value.substring( index, ta.value.length ); 
    667666 
    668       if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, and inside the body) 
     667      if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, enities and inside the body) 
    669668      { 
    670669        var tagEnd = after.indexOf(">") + 1; 
     
    672671      } 
    673672      else ta.value = before + cc + after; 
     673      ta.value = ta.value.replace(new RegExp ('(&[^'+cc+']*?)('+cc+')([^'+cc+']*?;)'), "$1$3$2"); 
    674674      ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); 
    675675      ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); 
     
    685685Xinha.prototype.findCC = function ( target ) 
    686686{ 
    687   if (target == "textarea") 
    688   { // window.find() doesn't find text in textarea, neither does Safari's normal find feature 
    689         // hope they will fix this some time 
    690         // this mechanism to scroll into 
    691     var ta = this._textArea; 
    692     var val = ta.value; 
    693         ta.value =''; 
    694         var initialTaHeight = ta.scrollHeight; 
    695         var start = val.indexOf(this.cc); 
    696     var end = start + this.cc.length; 
    697     ta.value = val.substring( 0, start ); 
    698         var scrollTo = 0; 
    699         if ( ta.scrollHeight > initialTaHeight) 
    700         { 
    701                 scrollTo = ta.scrollHeight; 
    702         } 
    703         ta.value += val.substring( end, val.length ); 
    704     ta.selectionStart = start; 
    705     ta.selectionEnd = start; 
    706     ta.scrollTop = scrollTo; 
    707     ta.focus(); 
     687  if ( target == 'textarea' ) 
     688  { 
     689  var ta = this._textArea; 
     690  var pos = ta.value.indexOf( this.cc ); 
     691  if ( pos == -1 ) return; 
     692  var end = pos + this.cc.length; 
     693  var before =  ta.value.substring( 0, pos ); 
     694  var after = ta.value.substring( end, ta.value.length ); 
     695  ta.value = before ; 
     696 
     697  ta.scrollTop = ta.scrollHeight; 
     698  var scrollPos = ta.scrollTop; 
     699   
     700  ta.value += after; 
     701  ta.setSelectionRange(pos,pos); 
     702 
     703  ta.focus(); 
     704   
     705  ta.scrollTop = scrollPos; 
     706 
    708707  } 
    709708  else 
  • trunk/plugins/ExtendedFileManager/assets/manager.css

    r937 r962  
    1010.dirs { padding: 1em;   } 
    1111 
    12 .imageFrame { overflow-x:hidden; width: 100%; height: 145px; margin:0px; background-color: #fff;} 
     12.imageFrame { overflow-x:hidden; width: 100%; height: 155px; margin:0px; background-color: #fff;} 
    1313.smallWidth{ width: 4em; } 
    1414.largelWidth{ width: 30em; } 
  • trunk/plugins/ExtendedFileManager/assets/manager.js

    r957 r962  
    5656         
    5757        var w = 650; 
    58         var h = 200; 
     58        var h = 600; 
    5959         
    6060        window.resizeTo(w,h); 
     
    234234                } 
    235235        }; 
    236         imgManager.location.replace( iframeUrl ); 
     236        imgManager.location.replace(iframeUrl); 
    237237 
    238238    if (manager_mode == 'image' && typeof Xinha.colorPicker != "undefined" && document.getElementById('f_backgroundColor') && document.getElementById('f_backgroundColor').type == 'text') { 
     
    249249      new Xinha.colorPicker.InputBinding(document.getElementById('f_borderColor'),pickerConfig); 
    250250    } 
    251         setTimeout(function() { addEvent(window, 'resize', resize); }, 500); 
     251        setTimeout(function() { resize();addEvent(window, 'resize', resize); }, 500); 
    252252} 
    253253 
  • trunk/plugins/ExtendedFileManager/manager.php

    r937 r962  
    104104                echo 'var manager_mode="image";'; 
    105105        } 
     106        //IE doesn't like a relative URL when changing a window's location 
     107        $iframe_url = str_replace( array("backend.php","manager.php"), "", $_SERVER["PHP_SELF"] ) . $IMConfig['backend_url']; 
    106108        ?> 
    107109         
    108         var iframeUrl = '<?php print $IMConfig['backend_url']; ?>__function=images&mode=<?php echo $insertMode;?>&viewtype=<?php echo $IMConfig['view_type'] ?>'; 
     110        var iframeUrl = '<?php print $iframe_url ?>__function=images&mode=<?php echo $insertMode;?>&viewtype=<?php echo $IMConfig['view_type'] ?>'; 
    109111 
    110112/* ]]> */ 
  • trunk/plugins/GenericPlugin/generic-plugin.js

    r960 r962  
    4343GenericPlugin.prototype.onExecCommand = function ( cmdID, UI, param ) 
    4444{ 
    45         return false; 
     45        if (cmdID != 'removeformat') return false; 
     46 
     47        var editor = this.editor; 
     48        var sel = editor.getSelection(); 
     49        var range = editor.createRange(sel); 
     50 
     51        var els = editor._doc.getElementsByTagName('*'); 
     52         
     53        var start = ( range.startContainer.nodeType == 1 ) ? range.startContainer : range.startContainer.parentNode; 
     54        var end = ( range.endContainer.nodeType == 1 ) ? range.endContainer : range.endContainer.parentNode; 
     55         
     56        function clean(node) 
     57        { 
     58                node.removeAttribute('style'); 
     59        } 
     60         
     61        for (var i=0; i<els.length;i++) 
     62        { 
     63                if (els[i] == start) 
     64                { 
     65                        console.log({el : els[i], 'cmp' : 'start'}); 
     66                }  
     67                else if (els[i] == end) 
     68                { 
     69                        console.log({el : els[i], 'cmp' : 'end'}); 
     70                } 
     71                else 
     72                { 
     73                        clean(els[i]); 
     74                        console.log({el : els[i], 'cmp' : range.isPointInRange( els[i], 0 )}); 
     75                } 
     76                 
     77        } 
     78        return true; 
    4679} 
    4780 
Note: See TracChangeset for help on using the changeset viewer.