From c1f88f50eecc35d019888689448395242e4d7511 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Tue, 10 Dec 2013 20:11:35 +0000 Subject: [PATCH] Remove ve-pasteProtect class when falling back to clipboardData We already do this on the pasteTarget. Change-Id: Idcc7ed34daebfb5ed14925eb5ee8526d1001a2f1 --- modules/ve/ce/ve.ce.Surface.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index c9b6f78810..d06c5ed45d 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -872,7 +872,7 @@ ve.ce.Surface.prototype.beforePaste = function ( e ) { ve.ce.Surface.prototype.afterPaste = function () { var clipboardKey, clipboardId, clipboardIndex, $elements, parts, pasteData, slice, tx, internalListRange, - data, doc, html, + data, doc, htmlDoc, context, left, right, contextRange, beforePasteData = this.beforePasteData || {}, $window = this.$( OO.ui.Element.getWindow( this.$.context ) ), @@ -980,19 +980,21 @@ ve.ce.Surface.prototype.afterPaste = function () { this.$pasteTarget.filter('span[id],span[typeof],span[rel]').length === 0 ) { // CE destroyed an important span, so revert to using clipboard data - html = beforePasteData.html; + htmlDoc = ve.createDocumentFromHtml( beforePasteData.html ); + // Remove the pasteProtect class. See #onCopy. + $( htmlDoc ).find( 'span' ).removeClass( 've-pasteProtect' ); beforePasteData.context = null; } } - if ( !html ) { + if ( !htmlDoc ) { // If there were no problems, let CE do its sanitizing as it may // contain all sorts of horrible metadata (head tags etc.) // TODO: IE will always take this path, and so may have bugs with span unwapping // in edge cases (e.g. pasting a single MWReference) - html = this.$pasteTarget.html(); + htmlDoc = ve.createDocumentFromHtml( this.$pasteTarget.html() ); } // External paste - doc = ve.dm.converter.getModelFromDom( ve.createDocumentFromHtml( html ) ); + doc = ve.dm.converter.getModelFromDom( htmlDoc ); data = doc.data; // Clear metadata doc.metadata = new ve.dm.MetaLinearData( doc.getStore(), new Array( 1 + data.getLength() ) );