Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 26 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 85 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 86 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 26 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 45 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 11 ), |
— | — | @@ -82,10 +82,10 @@ |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 198 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 199 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 198 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 199 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -376,13 +376,24 @@ |
377 | 377 | // .find( '* + p' ) isn't good enough because textnodes aren't considered |
378 | 378 | $pre.find( 'p' ).each( function() { |
379 | 379 | if ( this.previousSibling || this.parentNode != $pre.get( 0 ) ) { |
380 | | - var text = "\n" + $( this ).text(); |
| 380 | + var text = $( this ).text(); |
381 | 381 | // If this <p> is preceded by some text, add a \n at the beginning, and if |
382 | 382 | // it's followed by a textnode, add a \n at the end |
383 | 383 | // We need the traverser because there can be other weird stuff in between |
384 | | - // TODO: We need a reverse traverser, write this |
385 | | - var t = new context.fn.rawTraverser( this.lastChild, -10, this ).next(); |
| 384 | + |
| 385 | + // Check for preceding text |
| 386 | + // FIXME: Add an option to disable depth checking, -10 is a hack |
| 387 | + var t = new context.fn.rawTraverser( this.firstChild, -10, this ).prev(); |
386 | 388 | while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
| 389 | + t = t.prev(); |
| 390 | + } |
| 391 | + if ( t ) { |
| 392 | + text = "\n" + text; |
| 393 | + } |
| 394 | + |
| 395 | + // Check for following text |
| 396 | + t = new context.fn.rawTraverser( this.lastChild, -10, this ).next(); |
| 397 | + while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
387 | 398 | t = t.next(); |
388 | 399 | } |
389 | 400 | if ( t && !t.inP && t.node.nodeName != 'P' ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6800,13 +6800,24 @@ |
6801 | 6801 | // .find( '* + p' ) isn't good enough because textnodes aren't considered |
6802 | 6802 | $pre.find( 'p' ).each( function() { |
6803 | 6803 | if ( this.previousSibling || this.parentNode != $pre.get( 0 ) ) { |
6804 | | - var text = "\n" + $( this ).text(); |
| 6804 | + var text = $( this ).text(); |
6805 | 6805 | // If this <p> is preceded by some text, add a \n at the beginning, and if |
6806 | 6806 | // it's followed by a textnode, add a \n at the end |
6807 | 6807 | // We need the traverser because there can be other weird stuff in between |
6808 | | - // TODO: We need a reverse traverser, write this |
6809 | | - var t = new context.fn.rawTraverser( this.lastChild, -10, this ).next(); |
| 6808 | + |
| 6809 | + // Check for preceding text |
| 6810 | + // FIXME: Add an option to disable depth checking, -10 is a hack |
| 6811 | + var t = new context.fn.rawTraverser( this.firstChild, -10, this ).prev(); |
6810 | 6812 | while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
| 6813 | + t = t.prev(); |
| 6814 | + } |
| 6815 | + if ( t ) { |
| 6816 | + text = "\n" + text; |
| 6817 | + } |
| 6818 | + |
| 6819 | + // Check for following text |
| 6820 | + t = new context.fn.rawTraverser( this.lastChild, -10, this ).next(); |
| 6821 | + while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
6811 | 6822 | t = t.next(); |
6812 | 6823 | } |
6813 | 6824 | if ( t && !t.inP && t.node.nodeName != 'P' ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -450,7 +450,9 @@ |
451 | 451 | if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});} |
452 | 452 | addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'htmlToText':function(html){var $pre=$('<pre>'+ |
453 | 453 | html.replace(/\r?\n/g,"").replace(/ /g," ") |
454 | | -+'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t")});$pre.find('br').each(function(){$(this).replaceWith("\n");});$pre.find('p').each(function(){if(this.previousSibling||this.parentNode!=$pre.get(0)){var text="\n"+$(this).text();var t=new context.fn.rawTraverser(this.lastChild,-10,this).next();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.next();} |
| 454 | ++'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t")});$pre.find('br').each(function(){$(this).replaceWith("\n");});$pre.find('p').each(function(){if(this.previousSibling||this.parentNode!=$pre.get(0)){var text=$(this).text();var t=new context.fn.rawTraverser(this.firstChild,-10,this).prev();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.prev();} |
| 455 | +if(t){text="\n"+text;} |
| 456 | +t=new context.fn.rawTraverser(this.lastChild,-10,this).next();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.next();} |
455 | 457 | if(t&&!t.inP&&t.node.nodeName!='P'){text+="\n";} |
456 | 458 | $(this).text(text);}});return $pre.text();},'getContents':function(){return context.fn.htmlToText(context.$content.html());},'getSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();}else if(context.$iframe[0].contentWindow.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();} |
457 | 459 | if(typeof retval.text!='undefined'){retval=context.fn.htmlToText(retval.htmlText);}else if(retval.toString){retval=retval.toString();} |