TinyMCE: when pressing Enter while an image with caption is selected, fix moving the caret in a new paragraph under it, fix opening the Image Properties popup in IE9, see #21173

git-svn-id: https://develop.svn.wordpress.org/trunk@21254 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2012-07-10 02:31:30 +00:00
parent e256a654ba
commit e69e38219b
1 changed files with 41 additions and 50 deletions

View File

@ -11,24 +11,7 @@
t.editor = ed;
t._createButtons();
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
ed.addCommand('WP_EditImage', function() {
var el = ed.selection.getNode(), vp, H, W, cls = ed.dom.getAttrib(el, 'class');
if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 || el.nodeName != 'IMG' )
return;
vp = tinymce.DOM.getViewPort();
H = 680 < (vp.h - 70) ? 680 : vp.h - 70;
W = 650 < vp.w ? 650 : vp.w;
ed.windowManager.open({
file: url + '/editimage.html',
width: W+'px',
height: H+'px',
inline: true
});
});
ed.addCommand('WP_EditImage', t._editImage);
ed.onInit.add(function(ed) {
ed.dom.events.add(ed.getBody(), 'dragstart', function(e) {
@ -38,6 +21,27 @@
ed.selection.select(parent);
}
});
// when pressing Return inside a caption move the caret to a new parapraph under it
ed.dom.events.add(ed.getBody(), 'keydown', function(e) {
var n, DL, DIV, P, content;
if ( e.keyCode == 13 ) {
n = ed.selection.getNode();
DL = ed.dom.getParent(n, 'dl.wp-caption');
if ( DL )
DIV = ed.dom.getParent(DL, 'div.mceTemp');
if ( DIV ) {
ed.dom.events.cancel(e);
P = ed.dom.create('p', {}, '\uFEFF');
ed.dom.insertAfter( P, DIV );
ed.selection.setCursorLocation(P, 0);
return false;
}
}
});
});
// resize the caption <dl> when the image is soft-resized by the user (only possible in Firefox and IE)
@ -90,35 +94,6 @@
}
});
// when pressing Return inside a caption move the caret to a new parapraph under it
ed.onKeyPress.add(function(ed, e) {
var n, DL, DIV, P;
if ( e.keyCode == 13 ) {
n = ed.selection.getNode();
DL = ed.dom.getParent(n, 'dl.wp-caption');
if ( DL )
DIV = ed.dom.getParent(DL, 'div.mceTemp');
if ( DIV ) {
P = ed.dom.create('p', {}, '<br>');
ed.dom.insertAfter( P, DIV );
ed.selection.select(P.firstChild);
if ( tinymce.isIE ) {
ed.selection.setContent('');
} else {
ed.selection.setContent('<br _moz_dirty="">');
ed.selection.setCursorLocation(P, 0);
}
ed.dom.events.cancel(e);
return false;
}
}
});
ed.onBeforeSetContent.add(function(ed, o) {
o.content = ed.wpSetImgCaption(o.content);
});
@ -239,9 +214,7 @@
});
tinymce.dom.Event.add(editButton, 'mousedown', function(e) {
var ed = tinyMCE.activeEditor;
ed.windowManager.bookmark = ed.selection.getBookmark('simple');
ed.execCommand("WP_EditImage");
t._editImage();
});
dellButton = DOM.add('wp_editbtns', 'img', {
@ -269,6 +242,24 @@
});
},
_editImage : function() {
var ed = this.editor, url = this.url, el = ed.selection.getNode(), vp, H, W, cls = el.className;
if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 || el.nodeName != 'IMG' )
return;
vp = tinymce.DOM.getViewPort();
H = 680 < (vp.h - 70) ? 680 : vp.h - 70;
W = 650 < vp.w ? 650 : vp.w;
ed.windowManager.open({
file: url + '/editimage.html',
width: W+'px',
height: H+'px',
inline: true
});
},
getInfo : function() {
return {
longname : 'Edit Image',