Remove ve-pasteProtect class when falling back to clipboardData

We already do this on the pasteTarget.

Change-Id: Idcc7ed34daebfb5ed14925eb5ee8526d1001a2f1
This commit is contained in:
Ed Sanders 2013-12-10 20:11:35 +00:00
parent 333166e818
commit c1f88f50ee

View file

@ -872,7 +872,7 @@ ve.ce.Surface.prototype.beforePaste = function ( e ) {
ve.ce.Surface.prototype.afterPaste = function () { ve.ce.Surface.prototype.afterPaste = function () {
var clipboardKey, clipboardId, clipboardIndex, var clipboardKey, clipboardId, clipboardIndex,
$elements, parts, pasteData, slice, tx, internalListRange, $elements, parts, pasteData, slice, tx, internalListRange,
data, doc, html, data, doc, htmlDoc,
context, left, right, contextRange, context, left, right, contextRange,
beforePasteData = this.beforePasteData || {}, beforePasteData = this.beforePasteData || {},
$window = this.$( OO.ui.Element.getWindow( this.$.context ) ), $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 this.$pasteTarget.filter('span[id],span[typeof],span[rel]').length === 0
) { ) {
// CE destroyed an important span, so revert to using clipboard data // 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; beforePasteData.context = null;
} }
} }
if ( !html ) { if ( !htmlDoc ) {
// If there were no problems, let CE do its sanitizing as it may // If there were no problems, let CE do its sanitizing as it may
// contain all sorts of horrible metadata (head tags etc.) // contain all sorts of horrible metadata (head tags etc.)
// TODO: IE will always take this path, and so may have bugs with span unwapping // TODO: IE will always take this path, and so may have bugs with span unwapping
// in edge cases (e.g. pasting a single MWReference) // in edge cases (e.g. pasting a single MWReference)
html = this.$pasteTarget.html(); htmlDoc = ve.createDocumentFromHtml( this.$pasteTarget.html() );
} }
// External paste // External paste
doc = ve.dm.converter.getModelFromDom( ve.createDocumentFromHtml( html ) ); doc = ve.dm.converter.getModelFromDom( htmlDoc );
data = doc.data; data = doc.data;
// Clear metadata // Clear metadata
doc.metadata = new ve.dm.MetaLinearData( doc.getStore(), new Array( 1 + data.getLength() ) ); doc.metadata = new ve.dm.MetaLinearData( doc.getStore(), new Array( 1 + data.getLength() ) );