From 37a39cbefa3831c22f35c0aa834de11b63c833b5 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 18 Nov 2012 18:04:20 +0000 Subject: [PATCH] TinyMCE: place the caret after/under images with captions when inserting content, fixes #19389 git-svn-id: https://develop.svn.wordpress.org/trunk@22644 602fd350-edb4-49c9-b593-d223f7449a82 --- .../plugins/wpeditimage/editor_plugin_src.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js index fdc4a64dc3..c1b9d6bded 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js +++ b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js @@ -102,6 +102,23 @@ ed.wpGetImgCaption = function(content) { return t._get_shcode(content); }; + + // When inserting content, if the caret is inside a caption create new paragraph under + // and move the caret there + ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) { + var node, p; + + if ( cmd == 'mceInsertContent' ) { + node = ed.dom.getParent(ed.selection.getNode(), 'div.mceTemp'); + + if ( !node ) + return; + + p = ed.dom.create('p'); + ed.dom.insertAfter( p, node ); + ed.selection.setCursorLocation(p, 0); + } + }); }, _do_shcode : function(content) {