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' => 79 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 80 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 25 ), |
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' => 192 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 193 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 192 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 193 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -365,16 +365,20 @@ |
366 | 366 | var $pre = $( '<pre>' + |
367 | 367 | html |
368 | 368 | .replace( /\r?\n/g, "" ) // IE7 inserts newlines before block elements |
369 | | - .replace( /\<br[^\>]*\>/gi, "\n" ) |
370 | 369 | .replace( / /g, " " ) // We inserted these to prevent IE from collapsing spaces |
371 | | - .replace( /\<p[^\>]*\>/gi, "\n" ) // IE uses </p><p> for user-inserted line breaks |
372 | | - .replace( /\<\/p[^\>]*\>/gi, "" ) |
373 | | - //.replace( /\<div[^\>]*\>/gi, "\n" ) // Webkit uses </div><div> for user-inserted line breaks |
374 | | - //.replace( /\<\/div[^\>]*\>/gi, "" ) |
375 | 370 | + '</pre>' ); |
376 | 371 | // Get rid of the noincludes when getting text |
377 | 372 | $pre.find( '.wikiEditor-noinclude' ).each( function() { $( this ).remove(); } ); |
| 373 | + // Convert tabs, <p>s and <br>s back |
378 | 374 | $pre.find( '.wikiEditor-tab' ).each( function() { $( this ).text( "\t" ) } ); |
| 375 | + $pre.find( 'br' ).each( function() { $( this ).replaceWith( "\n" ); } ); |
| 376 | + // Converting <p>s is wrong if there's nothing before them, so check that |
| 377 | + // .find( '* + p' ) isn't good enough because textnodes aren't considered |
| 378 | + $pre.find( 'p' ).each( function() { |
| 379 | + if ( this.previousSibling || this.parentNode != $pre.get( 0 ) ) { |
| 380 | + $( this ).text( "\n" + $( this ).text() ); |
| 381 | + } |
| 382 | + } ); |
379 | 383 | return $pre.text(); |
380 | 384 | }, |
381 | 385 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6789,16 +6789,20 @@ |
6790 | 6790 | var $pre = $( '<pre>' + |
6791 | 6791 | html |
6792 | 6792 | .replace( /\r?\n/g, "" ) // IE7 inserts newlines before block elements |
6793 | | - .replace( /\<br[^\>]*\>/gi, "\n" ) |
6794 | 6793 | .replace( / /g, " " ) // We inserted these to prevent IE from collapsing spaces |
6795 | | - .replace( /\<p[^\>]*\>/gi, "\n" ) // IE uses </p><p> for user-inserted line breaks |
6796 | | - .replace( /\<\/p[^\>]*\>/gi, "" ) |
6797 | | - //.replace( /\<div[^\>]*\>/gi, "\n" ) // Webkit uses </div><div> for user-inserted line breaks |
6798 | | - //.replace( /\<\/div[^\>]*\>/gi, "" ) |
6799 | 6794 | + '</pre>' ); |
6800 | 6795 | // Get rid of the noincludes when getting text |
6801 | 6796 | $pre.find( '.wikiEditor-noinclude' ).each( function() { $( this ).remove(); } ); |
| 6797 | + // Convert tabs, <p>s and <br>s back |
6802 | 6798 | $pre.find( '.wikiEditor-tab' ).each( function() { $( this ).text( "\t" ) } ); |
| 6799 | + $pre.find( 'br' ).each( function() { $( this ).replaceWith( "\n" ); } ); |
| 6800 | + // Converting <p>s is wrong if there's nothing before them, so check that |
| 6801 | + // .find( '* + p' ) isn't good enough because textnodes aren't considered |
| 6802 | + $pre.find( 'p' ).each( function() { |
| 6803 | + if ( this.previousSibling || this.parentNode != $pre.get( 0 ) ) { |
| 6804 | + $( this ).text( "\n" + $( this ).text() ); |
| 6805 | + } |
| 6806 | + } ); |
6803 | 6807 | return $pre.text(); |
6804 | 6808 | }, |
6805 | 6809 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -449,8 +449,8 @@ |
450 | 450 | event.preventDefault();return false;}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);} |
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 | | -html.replace(/\r?\n/g,"").replace(/\<br[^\>]*\>/gi,"\n").replace(/ /g," ").replace(/\<p[^\>]*\>/gi,"\n").replace(/\<\/p[^\>]*\>/gi,"") |
454 | | -+'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t")});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();} |
| 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)){$(this).text("\n"+$(this).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();} |
455 | 455 | if(typeof retval.text!='undefined'){retval=context.fn.htmlToText(retval.htmlText);}else if(retval.toString){retval=retval.toString();} |
456 | 456 | return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');var selTextArr;var selectAfter=false;var pre=options.pre,post=options.post;if(!selText){selText=options.peri;selectAfter=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';} |
457 | 457 | if(options.splitlines){selTextArr=selText.split(/\n/);} |