Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/237067

Change subject: Use rendered contents when copying to clipboard
......................................................................

Use rendered contents when copying to clipboard

Bug: T111923
Bug: T111924
Change-Id: I04b98e317d0c883fc257c46552476041c7f53679
---
M modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js
1 file changed, 13 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/67/237067/1

diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js 
b/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js
index d0efc99..9b534f4 100644
--- a/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js
+++ b/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js
@@ -79,7 +79,7 @@
 };
 
 ve.dm.MWExtensionNode.static.toDomElements = function ( dataElement, doc, 
converter ) {
-       var el,
+       var el, els,
                index = converter.getStore().indexOfHash( OO.getHash( [ 
this.getHashObject( dataElement ), undefined ] ) ),
                originalMw = dataElement.attributes.originalMw;
 
@@ -92,10 +92,18 @@
                // The object in the store is also used for CE rendering so 
return a copy
                return ve.copyDomElements( dataElement.originalDomElements, doc 
);
        } else {
-               el = doc.createElement( this.tagName );
-               el.setAttribute( 'typeof', 'mw:Extension/' + 
this.getExtensionName( dataElement ) );
-               el.setAttribute( 'data-mw', JSON.stringify( 
dataElement.attributes.mw ) );
-               return [ el ];
+               if ( converter.isForClipboard() && index !== null ) {
+                       // For the clipboard use the current DOM contents so 
the user has something
+                       // meaningful to paste into external applications
+                       els = ve.copyDomElements( converter.getStore().value( 
index ), doc );
+                       els[ 0 ] = wrapTextNode( els[ 0 ] );
+               } else {
+                       el = doc.createElement( this.tagName );
+                       el.setAttribute( 'typeof', 'mw:Extension/' + 
this.getExtensionName( dataElement ) );
+                       el.setAttribute( 'data-mw', JSON.stringify( 
dataElement.attributes.mw ) );
+                       els = [ el ]
+               }
+               return els;
        }
 };
 

-- 
To view, visit https://gerrit.wikimedia.org/r/237067
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I04b98e317d0c883fc257c46552476041c7f53679
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to