Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/232276
Change subject: Use only relevant html when creating DTI from image
......................................................................
Use only relevant html when creating DTI from image
Avoids the need for htmlStr variable too.
Change-Id: I19e8c17df18838f70768dfcc9bf4d8af7c367329
---
M src/ce/ve.ce.Surface.js
1 file changed, 8 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/76/232276/1
diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index fb43731..5ea2b46 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -1894,7 +1894,7 @@
// jshint unused:false
var clipboardKey, clipboardId, clipboardIndex, clipboardHash, range,
$elements, parts, pasteData, slice, tx, internalListRange,
- data, doc, htmlStr, htmlDoc, $images, i,
+ data, doc, htmlDoc, $images, i,
context, left, right, contextRange,
items = [],
importantElement = '[id],[typeof],[rel]',
@@ -2042,8 +2042,7 @@
// If the clipboardKey is set (paste from other VE
instance), and clipboard
// data is available, then make sure important spans
haven't been dropped
if ( !$elements ) {
- htmlStr = beforePasteData.html;
- $elements = $( $.parseHTML( htmlStr ) );
+ $elements = $( $.parseHTML(
beforePasteData.html ) );
}
if (
// HACK: Allow the test runner to force the use
of clipboardData
@@ -2053,8 +2052,7 @@
)
) {
// CE destroyed an important element, so revert
to using clipboard data
- htmlStr = beforePasteData.html;
- htmlDoc = ve.createDocumentFromHtml( htmlStr );
+ htmlDoc = ve.createDocumentFromHtml(
beforePasteData.html );
// Remove the pasteProtect class. See #onCopy.
$( htmlDoc ).find( 'span' ).removeClass(
've-pasteProtect' );
beforePasteData.context = null;
@@ -2065,15 +2063,17 @@
// contain all sorts of horrible metadata (head tags
etc.)
// TODO: IE will always take this path, and so may have
bugs with span unwrapping
// in edge cases (e.g. pasting a single MWReference)
- htmlStr = this.$pasteTarget.html();
- htmlDoc = ve.createDocumentFromHtml( htmlStr );
+ htmlDoc = ve.createDocumentFromHtml(
this.$pasteTarget.html() );
}
// Some browsers don't provide pasted image data through the
clipboardData API and
// instead create img tags with data URLs, so detect those here
$images = $( htmlDoc.body ).find( 'img[src^=data\\:]' );
if ( $images.length ) {
for ( i = 0; i < $images.length; i++ ) {
- items.push(
ve.ui.DataTransferItem.static.newFromDataUri( $images.eq( i ).attr( 'src' ),
htmlStr ) );
+ items.push(
ve.ui.DataTransferItem.static.newFromDataUri(
+ $images.eq( i ).attr( 'src' ),
+ $images[i].outerHTML
+ ) );
}
if ( this.handleDataTransferItems( items, true ) ) {
return;
--
To view, visit https://gerrit.wikimedia.org/r/232276
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I19e8c17df18838f70768dfcc9bf4d8af7c367329
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits