Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -273,6 +273,7 @@ |
274 | 274 | * processing of events which did not actually change the content of the iframe. |
275 | 275 | */ |
276 | 276 | 'keydown': function( event ) { |
| 277 | + |
277 | 278 | switch ( event.which ) { |
278 | 279 | case 90: // z |
279 | 280 | if ( ( event.ctrlKey || event.metaKey ) && context.history.length ) { |
— | — | @@ -359,6 +360,27 @@ |
360 | 361 | } |
361 | 362 | } |
362 | 363 | return true; |
| 364 | + }, |
| 365 | + 'paste': function( event ) { |
| 366 | + context.$content.find( ':not(.wikiEditor)' ).addClass( 'wikiEditor' ); |
| 367 | + setTimeout( function() { |
| 368 | + var $selection = context.$content.find( ':not(.wikiEditor)' ); |
| 369 | + while ( $selection.length && $selection.length > 0){ |
| 370 | + var $currentElement = $selection.eq( 0 ); |
| 371 | + while ( !$currentElement.parent().is( 'body' ) && !$currentElement.parent().is( '.wikiEditor' ) ) { |
| 372 | + $currentElement = $currentElement.parent(); |
| 373 | + } |
| 374 | + if($currentElement.is("br")){ |
| 375 | + $currentElement.addClass('wikiEditor'); |
| 376 | + } |
| 377 | + else{ |
| 378 | + $("<p></p>").text( $currentElement.text() ).addClass( 'wikiEditor' ).insertAfter( $currentElement ); |
| 379 | + $currentElement.remove(); |
| 380 | + } |
| 381 | + $selection = context.$content.find( ':not(.wikiEditor)' ); |
| 382 | + } |
| 383 | + }, 100 ); |
| 384 | + return true; |
363 | 385 | } |
364 | 386 | }; |
365 | 387 | |
— | — | @@ -1263,6 +1285,9 @@ |
1264 | 1286 | .bind( 'keydown', function( event ) { |
1265 | 1287 | return context.fn.trigger( 'keydown', event ); |
1266 | 1288 | } ) |
| 1289 | + .bind( 'paste', function( event ){ |
| 1290 | + return context.fn.trigger( 'paste', event ); |
| 1291 | + } ) |
1267 | 1292 | .bind( 'keyup mouseup paste cut encapsulateSelection', function( event ) { |
1268 | 1293 | return context.fn.trigger( 'change', event ); |
1269 | 1294 | } ) |