diff --git src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
index 3ba19b4..343e48f 100644
|
|
|
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 ) { |
5 | 7 | var id, cls, w, cap, img, width, |
… |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
102 | 104 | }); |
103 | 105 | |
104 | 106 | if ( out.indexOf('[caption') !== 0 ) { |
105 | | // the caption html seems brocken, try to find the image that may be wrapped in a link |
| 107 | // 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' ); |
108 | 110 | } |
… |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
339 | 341 | } else { |
340 | 342 | editor.dom.remove( node ); |
341 | 343 | } |
| 344 | removeToolbar(); |
342 | 345 | } |
343 | 346 | |
344 | 347 | function addToolbar( node ) { |
… |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
371 | 374 | top: rectangle.y, |
372 | 375 | left: rectangle.x + rectangle.w - toolbarSize.w |
373 | 376 | }); |
| 377 | |
| 378 | toolbarActive = true; |
374 | 379 | } |
375 | 380 | |
376 | 381 | function removeToolbar() { |
… |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
381 | 386 | } |
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 | |
386 | 393 | function isPlaceholder( node ) { |
… |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
753 | 760 | editor.on( 'keydown', function( event ) { |
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(); |
761 | 769 | wrap = dom.getParent( node, 'div.mceTemp' ); |
… |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
782 | 790 | editor.nodeChanged(); |
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 | |
788 | 796 | if ( node.nodeName === 'DIV' && dom.hasClass( node, 'mceTemp' ) ) { |
… |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
796 | 804 | removeImage( node ); |
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 | }); |
801 | 821 | |
… |
… |
tinymce.PluginManager.add( 'wpeditimage', function( editor ) { |
828 | 848 | |
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 ); |
834 | 853 | } |