From 926006ea56818cef18757ef47413435a1423b8ce Mon Sep 17 00:00:00 2001 From: Ella Iseulde Van Dorpe <*@iseulde.com> Date: Wed, 29 Jul 2015 13:49:24 +0000 Subject: [PATCH] TinyMCE: views: correct cursor position after paste Fixes #33174. Built from https://develop.svn.wordpress.org/trunk@33484 git-svn-id: http://core.svn.wordpress.org/trunk@33451 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/mce-view.js | 28 +++++++++++------- wp-includes/js/mce-view.min.js | 2 +- .../js/tinymce/plugins/wpview/plugin.js | 1 + .../js/tinymce/plugins/wpview/plugin.min.js | 2 +- wp-includes/js/tinymce/wp-tinymce.js.gz | Bin 146775 -> 146783 bytes wp-includes/version.php | 2 +- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js index 41118ca19d..c0ae668062 100644 --- a/wp-includes/js/mce-view.js +++ b/wp-includes/js/mce-view.js @@ -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( - '
\u00a0
' + - '\u00a0
' + - '\u00a0
' + + '\u00a0
' + + ''+h+"
",processed:!0}),i=i.slice(g.index+g.content.length);i&&d.push({content:i})})}),a=_.pluck(d,"content").join(""),a.replace(/\s*
")},createInstance:function(a,b,c,d){var e,g,h=this.get(a);return b=tinymce.DOM.decode(b),!d&&(g=this.getInstance(b))?g:(e=encodeURIComponent(b),c=_.extend(c||{},{text:b,encodedText:e}),f[e]=new h(c))},getInstance:function(a){return"string"==typeof a?f[encodeURIComponent(a)]:f[d(a).attr("data-wpview-text")]},getText:function(a){return decodeURIComponent(d(a).attr("data-wpview-text")||"")},render:function(a){_.each(f,function(b){b.render(a)})},update:function(a,b,c,d){var e=this.getInstance(c);e&&e.update(a,b,c,d)},edit:function(a,b){var c=this.getInstance(b);c&&c.edit&&c.edit(c.text,function(d,e){c.update(d,a,b,e)})},remove:function(a,b){var c=this.getInstance(b);c&&c.remove(a,b)}},b.mce.View=function(a){_.extend(this,a),this.initialize()},b.mce.View.extend=Backbone.View.extend,_.extend(b.mce.View.prototype,{content:null,loader:!0,initialize:function(){},getContent:function(){return this.content},render:function(a,b){null!=a&&(this.content=a),a=this.getContent(),(this.loader||a)&&(b&&this.unbind(),this.replaceMarkers(),a?this.setContent(a,function(a,b,c){d(b).data("rendered",!0),this.bindNode.call(this,a,b,c)},b?null:!1):this.setLoader())},bindNode:function(){},unbindNode:function(){},unbind:function(){this.getNodes(function(a,b,c){this.unbindNode.call(this,a,b,c),d(b).trigger("wp-mce-view-unbind")},!0)},getEditors:function(a){_.each(tinymce.editors,function(b){b.plugins.wpview&&a.call(this,b)},this)},getNodes:function(a,b){this.getEditors(function(c){var e=this;d(c.getBody()).find('[data-wpview-text="'+e.encodedText+'"]').filter(function(){var a;return null==b?!0:(a=d(this).data("rendered")===!0,b?a:!a)}).each(function(){a.call(e,c,this,d(this).find(".wpview-content").get(0))})})},getMarkers:function(a){this.getEditors(function(b){var c=this;d(b.getBody()).find('[data-wpview-marker="'+this.encodedText+'"]').each(function(){a.call(c,b,this)})})},replaceMarkers:function(){this.getMarkers(function(a,b){return this.loader||d(b).text()===this.text?void a.dom.replace(a.dom.createFragment('
\xa0
\xa0