Changeset 27786
- Timestamp:
- 03/27/2014 06:06:13 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
r27777 r27786 1 1 /* global tinymce */ 2 2 tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 3 var toolbarActive = false; 4 3 5 function parseShortcode( content ) { 4 6 return content.replace( /(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function( a, b, c ) { … … 103 105 104 106 if ( out.indexOf('[caption') !== 0 ) { 105 // the caption html seems bro cken, try to find the image that may be wrapped in a link107 // the caption html seems broken, try to find the image that may be wrapped in a link 106 108 // and may be followed by <p> with the caption text. 107 109 out = b.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' ); … … 340 342 editor.dom.remove( node ); 341 343 } 344 removeToolbar(); 342 345 } 343 346 … … 372 375 left: rectangle.x 373 376 }); 377 378 toolbarActive = true; 374 379 } 375 380 … … 382 387 383 388 editor.dom.setAttrib( editor.dom.select( 'img[data-wp-imgselect]' ), 'data-wp-imgselect', null ); 389 390 toolbarActive = false; 384 391 } 385 392 … … 754 761 var node, wrap, P, spacer, 755 762 selection = editor.selection, 763 keyCode = event.keyCode, 756 764 dom = editor.dom; 757 765 758 if ( event.keyCode === tinymce.util.VK.ENTER ) {766 if ( keyCode === tinymce.util.VK.ENTER ) { 759 767 // When pressing Enter inside a caption move the caret to a new parapraph under it 760 768 node = selection.getNode(); … … 783 791 selection.setCursorLocation( P, 0 ); 784 792 } 785 } else if ( event.keyCode === tinymce.util.VK.DELETE || event.keyCode === tinymce.util.VK.BACKSPACE ) {793 } else if ( keyCode === tinymce.util.VK.DELETE || keyCode === tinymce.util.VK.BACKSPACE ) { 786 794 node = selection.getNode(); 787 795 … … 797 805 return false; 798 806 } 807 808 removeToolbar(); 809 } 810 811 // Key presses will replace the image so we need to remove the toolbar 812 if ( toolbarActive ) { 813 if ( event.ctrlKey || event.metaKey || event.altKey || 814 ( keyCode < 48 && keyCode > 90 ) || keyCode > 186 ) { 815 return; 816 } 817 818 removeToolbar(); 799 819 } 800 820 }); … … 829 849 if ( dom.hasClass( node, 'remove' ) ) { 830 850 removeImage( image ); 831 removeToolbar();832 851 } else if ( dom.hasClass( node, 'edit' ) ) { 833 852 editImage( image );
Note: See TracChangeset
for help on using the changeset viewer.