Skip to content

Commit

Permalink
**** v 0.8.1.1 ****
Browse files Browse the repository at this point in the history
- Fix bug of frequent syntax desynchronisation when the first character of the textarea was highlighted
- In unload now check that parent.editareaLoader still exists before calling it
  • Loading branch information
cdolivet committed Apr 24, 2009
1 parent f4a620d commit 63cc815
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 53 deletions.
9 changes: 7 additions & 2 deletions _devel/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,14 @@ function test(){
<form action='' method='post' onsubmit='alert("hah")'>
<!--<iframe src='http://www.google.fr' style='position: fixed;width: 100%;height: 200px' id='iframe_test' ></iframe>-->
<div id="container" stfyle='position: absolute; top: 80px; left: 150px; border: solid red 1px; '>
<textarea id="src" style="height: 350px; width: 513px;" name="toto" enctype="multipart/form-data" onfojcus="this.focused=true;" onbjlur="this.focused=false;" >
<textarea id="src" style="height: 350px; width: 913px;" name="toto" enctype="multipart/form-data" onfojcus="this.focused=true;" onbjlur="this.focused=false;" >
<?php
$val='
$val='<?php
$authors = array();
$news = array();
/* this is a long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long comment for showing word-wrap feature */
$query = "SELECT author, COUNT(id) as \'nb_news\' FROM news_messages GROUP BY author";
$result = mysql_query($query, $DBnews);
< ?php
&ecute; &#x92c;&#x93f;&#x930;&#x92f;&#x93e;&#x928;&#x940;
//Thanks to TinyMCE developpers!
Expand Down
4 changes: 4 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**** v 0.8.1.1 ****
- Fix bug of frequent syntax desynchronisation when the first character of the textarea was highlighted
- In unload now check that parent.editareaLoader still exists before calling it

**** v 0.8.1 ****
- Improved speed of text highlighting process for huge file. Now we try to only insert or delete the changed caracters inside DOM text node instead of refreshing the whole area. (3 time faster in firefox)
- Greatly improved speed of line-height management in word-wrap context
Expand Down
8 changes: 6 additions & 2 deletions edit_area/edit_area.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,12 @@
parent.editAreaLoader.add_event(parent.window, "resize", editArea.update_size);
parent.editAreaLoader.add_event(top.window, "resize", editArea.update_size);
parent.editAreaLoader.add_event(window, "unload", function(){
parent.editAreaLoader.remove_event(parent.window, "resize", editArea.update_size);
parent.editAreaLoader.remove_event(top.window, "resize", editArea.update_size);
// in case where editAreaLoader have been already cleaned
if( parent.editAreaLoader )
{
parent.editAreaLoader.remove_event(parent.window, "resize", editArea.update_size);
parent.editAreaLoader.remove_event(top.window, "resize", editArea.update_size);
}
if(editAreas[editArea.id] && editAreas[editArea.id]["displayed"]){
editArea.execCommand("EA_unload");
}
Expand Down
Binary file modified edit_area/edit_area_full.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions edit_area/edit_area_full.js

Large diffs are not rendered by default.

Binary file modified edit_area/edit_area_full_with_plugins.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions edit_area/edit_area_full_with_plugins.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion edit_area/edit_area_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

function EditAreaLoader(){
var t=this;
t.version= "0.8.1";
t.version= "0.8.1.1";
date= new Date();
t.start_time=date.getTime();
t.win= "loading"; // window loading state
Expand Down
5 changes: 2 additions & 3 deletions edit_area/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@

nbOpendedSpan = beginStr.split('<span').length - 1;
nbClosedSpan = beginStr.split('</span').length - 1;

// retrieve the previously opened span (Add 1 for the first level span?)
span = t.content_highlight.getElementsByTagName('span')[ nbOpendedSpan ];

Expand Down Expand Up @@ -263,11 +262,11 @@
maxEndOffset = tmpMaxEndOffset;
}
}
// Note: maxEndOffset is no more used but maxStartOffset will be used

if( parentSpan.parentNode == t.content_highlight || parentSpan.parentNode.tagName == 'PRE' )
{
maxStartOffset = Math.max( 0, beginStr.indexOf( '<span' ) );
maxEndOffset = Math.max( 0, beginStr.indexOf( '</span' ) );
}

// find the matching text node (this will be one that will be at the end of the beginStr
Expand All @@ -280,7 +279,7 @@
lastEndPos = Math.max( 0, beginStr.lastIndexOf( '>', maxStartOffset ) );

// count the number of sub spans
nbSubSpanBefore = beginStr.substr( lastEndPos + 1 ).split('<span').length-1;
nbSubSpanBefore = beginStr.substr( lastEndPos ).split('<span').length-1;
}

// there is no sub-span before
Expand Down
85 changes: 44 additions & 41 deletions edit_area/manage_area.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@
}

tend= new Date().getTime();
/*if( (tend-t1) > 7 )
console.log( "tps total: "+ (tend-t1) + " tps get_infos: "+ (t2-t1)+ " tps selec: "+ (t2_1-t2)+ " tps highlight: "+ (t3-t2_1) +" tps lines: "+ (tLines-t3) +" tps cursor+lines: "+ (tend-tLines)+" \n" );
*/
//if( (tend-t1) > 7 )
// console.log( "tps total: "+ (tend-t1) + " tps get_infos: "+ (t2-t1)+ " tps selec: "+ (t2_1-t2)+ " tps highlight: "+ (t3-t2_1) +" tps lines: "+ (tLines-t3) +" tps cursor+lines: "+ (tend-tLines)+" \n" );


if(timer_checkup){
setTimeout("editArea.check_line_selection(true)", this.check_line_selection_timer);
Expand All @@ -129,46 +129,49 @@


EditArea.prototype.get_selection_infos= function(){
var sel={}, start, end;

var sel={}, start, end, len, str;
var t1 = new Date().getTime();
if(this.isIE)
this.getIESelection();
start=this.textarea.selectionStart;
end=this.textarea.selectionEnd;
start = this.textarea.selectionStart;
end = this.textarea.selectionEnd;

if(this.last_selection["selectionStart"]==start && this.last_selection["selectionEnd"]==end && this.last_selection["full_text"]==this.textarea.value)
if( this.last_selection["selectionStart"] == start && this.last_selection["selectionEnd"] == end && this.last_selection["full_text"] == this.textarea.value )
{
return this.last_selection;
}

if(this.tabulation!="\t" && this.textarea.value.indexOf("\t")!=-1)
{ // can append only after copy/paste
var len= this.textarea.value.length;
this.textarea.value=this.replace_tab(this.textarea.value);
start=end= start+(this.textarea.value.length-len);
this.area_select(start, 0);
len = this.textarea.value.length;
this.textarea.value = this.replace_tab(this.textarea.value);
start = end = start+(this.textarea.value.length-len);
this.area_select( start, 0 );
}

sel["selectionStart"]= start;
sel["selectionEnd"]= end;
sel["full_text"]= this.textarea.value;
sel["line_start"]=1;
sel["line_nb"]=1;
sel["curr_pos"]=0;
sel["curr_line"]="";
sel["indexOfCursor"]=0;
sel["selec_direction"]= this.last_selection["selec_direction"];
sel["selectionStart"] = start;
sel["selectionEnd"] = end;
sel["full_text"] = this.textarea.value;
sel["line_start"] = 1;
sel["line_nb"] = 1;
sel["curr_pos"] = 0;
sel["curr_line"] = "";
sel["indexOfCursor"] = 0;
sel["selec_direction"] = this.last_selection["selec_direction"];

//return sel;
var splitTab=sel["full_text"].split("\n");
var nbLine=Math.max(0, splitTab.length);
var nbChar=Math.max(0, sel["full_text"].length - (nbLine - 1)); // (remove \n caracters from the count)
if(sel["full_text"].indexOf("\r")!=-1)
nbChar= nbChar - (nbLine -1); // (remove \r caracters from the count)
sel["nb_line"]=nbLine;
sel["nb_char"]=nbChar;
var splitTab= sel["full_text"].split("\n");
var nbLine = Math.max(0, splitTab.length);
var nbChar = Math.max(0, sel["full_text"].length - (nbLine - 1)); // (remove \n caracters from the count)
if( sel["full_text"].indexOf("\r") != -1 )
nbChar = nbChar - ( nbLine - 1 ); // (remove \r caracters from the count)
sel["nb_line"] = nbLine;
sel["nb_char"] = nbChar;

if(start>0){
var str=sel["full_text"].substr(0,start);
sel["curr_pos"]= start - str.lastIndexOf("\n");
sel["line_start"]=Math.max(1, str.split("\n").length);
str = sel["full_text"].substr(0,start);
sel["curr_pos"] = start - str.lastIndexOf("\n");
sel["line_start"] = Math.max(1, str.split("\n").length);
}else{
sel["curr_pos"]=1;
}
Expand All @@ -177,9 +180,9 @@
}
sel["indexOfCursor"]=start;
sel["curr_line"]=splitTab[Math.max(0,sel["line_start"]-1)];
// determine in with direction the direction grow
if(sel["selectionStart"]==this.last_selection["selectionStart"]){

// determine in which direction the selection grow
if(sel["selectionStart"] == this.last_selection["selectionStart"]){
if(sel["selectionEnd"]>this.last_selection["selectionEnd"])
sel["selec_direction"]= "down";
else if(sel["selectionEnd"] == this.last_selection["selectionStart"])
Expand All @@ -189,12 +192,12 @@
}else{
sel["selec_direction"]= "up";
}

_$("nbLine").innerHTML= nbLine;
_$("nbChar").innerHTML= nbChar;
_$("linePos").innerHTML=sel["line_start"];
_$("currPos").innerHTML=sel["curr_pos"];

_$("nbLine").innerHTML = nbLine;
_$("nbChar").innerHTML = nbChar;
_$("linePos").innerHTML = sel["line_start"];
_$("currPos").innerHTML = sel["curr_pos"];

return sel;
};

Expand Down Expand Up @@ -225,7 +228,7 @@
selectionStart -= ( line_start - this.textarea.value.substr(0, selectionStart).split("\n").length ) * 2;

selectionEnd = selectionStart + range.text.length;
selectionEnd += (line_start + line_nb - 1 - this.textarea.value.substr(0, selectionStart + range.text.length).split("\n").length)*2;
selectionEnd += (line_start + line_nb - 1 - this.textarea.value.substr(0, selectionEnd ).split("\n").length)*2;

this.textarea.selectionStart = selectionStart;
this.textarea.selectionEnd = selectionEnd;
Expand Down

0 comments on commit 63cc815

Please sign in to comment.