TinyMCE: views: correct cursor position after paste
Fixes #33174. git-svn-id: https://develop.svn.wordpress.org/trunk@33484 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8db3eeec7d
commit
b5c42d6b33
@ -421,23 +421,29 @@
|
||||
*/
|
||||
replaceMarkers: function() {
|
||||
this.getMarkers( function( editor, node ) {
|
||||
var selected = node === editor.selection.getNode(),
|
||||
$viewNode;
|
||||
|
||||
if ( ! this.loader && $( node ).text() !== this.text ) {
|
||||
editor.dom.setAttrib( node, 'data-wpview-marker', null );
|
||||
return;
|
||||
}
|
||||
|
||||
editor.dom.replace(
|
||||
editor.dom.createFragment(
|
||||
'<div class="wpview-wrap" data-wpview-text="' + this.encodedText + '" data-wpview-type="' + this.type + '">' +
|
||||
'<p class="wpview-selection-before">\u00a0</p>' +
|
||||
'<div class="wpview-body" contenteditable="false">' +
|
||||
'<div class="wpview-content wpview-type-' + this.type + '"></div>' +
|
||||
'</div>' +
|
||||
'<p class="wpview-selection-after">\u00a0</p>' +
|
||||
'</div>'
|
||||
),
|
||||
node
|
||||
$viewNode = editor.$(
|
||||
'<div class="wpview-wrap" data-wpview-text="' + this.encodedText + '" data-wpview-type="' + this.type + '">' +
|
||||
'<p class="wpview-selection-before">\u00a0</p>' +
|
||||
'<div class="wpview-body" contenteditable="false">' +
|
||||
'<div class="wpview-content wpview-type-' + this.type + '"></div>' +
|
||||
'</div>' +
|
||||
'<p class="wpview-selection-after">\u00a0</p>' +
|
||||
'</div>'
|
||||
);
|
||||
|
||||
editor.$( node ).replaceWith( $viewNode );
|
||||
|
||||
if ( selected ) {
|
||||
editor.wp.setViewCursor( false, $viewNode[0] );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
|
@ -729,6 +729,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||
// Add to editor.wp
|
||||
editor.wp = editor.wp || {};
|
||||
editor.wp.getView = getView;
|
||||
editor.wp.setViewCursor = setViewCursor;
|
||||
|
||||
// Keep for back-compat.
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user