jenkins-bot has submitted this change and it was merged.
Change subject: Add useful HTML in toDomElements for refs and templates.
......................................................................
Add useful HTML in toDomElements for refs and templates.
For the benefit of pasting out of VE.
Use data-ve-ignore where necessary to avoid the HTML being
used on the way back in to VE.
Change-Id: Iabe678c4246c1d1f51abb058b6e750811fdf9bea
---
M modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js
M modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js
2 files changed, 23 insertions(+), 8 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js
b/modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js
index da0b7bb..7d6a316 100644
--- a/modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js
+++ b/modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js
@@ -187,6 +187,10 @@
}
} else {
el.setAttribute( 'data-mw', JSON.stringify( mwData ) );
+ // HTML for the external clipboard, it will be ignored by the
converter
+ $( el ).append(
+ $( '<sup>', doc ).text( this.getIndexLabel(
dataElement, converter.internalList ) )
+ );
}
return [ el ];
diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js
b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js
index 875642e..52b7725 100644
--- a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js
+++ b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js
@@ -89,7 +89,7 @@
};
ve.dm.MWTransclusionNode.static.toDomElements = function ( dataElement, doc,
converter ) {
- var el,
+ var els, currentDom, i, len,
index = converter.getStore().indexOfHash( OO.getHash( [
this.getHashObject( dataElement ), undefined ] ) ),
originalMw = dataElement.attributes.originalMw;
@@ -105,20 +105,31 @@
return ve.copyDomElements(
dataElement.attributes.originalDomElements, doc );
} else {
if ( dataElement.attributes.originalDomElements ) {
- el = doc.createElement(
dataElement.attributes.originalDomElements[0].nodeName );
+ els = [ doc.createElement(
dataElement.attributes.originalDomElements[0].nodeName ) ];
} else {
- el = doc.createElement( 'span' );
+ els = [ doc.createElement( 'span' ) ];
+ // For the clipboard use the current DOM contents but
mark is ignored
+ // for the converter
+ currentDom = converter.getStore().value( index );
+ if ( currentDom ) {
+ currentDom = ve.copyDomElements( currentDom,
doc );
+ // i = 0 is the span
+ for ( i = 1, len = currentDom.length; i < len;
i++ ) {
+ currentDom[i].setAttribute(
'data-ve-ignore', 'true' );
+ els.push( currentDom[i] );
+ }
+ }
}
// All we need to send back to Parsoid is the original
transclusion marker, with a
// reconstructed data-mw property.
- el.setAttribute( 'typeof', 'mw:Transclusion' );
- el.setAttribute( 'data-mw', JSON.stringify(
dataElement.attributes.mw ) );
- // Mark the element as not having a generated contents with it
in case it is
+ els[0].setAttribute( 'typeof', 'mw:Transclusion' );
+ els[0].setAttribute( 'data-mw', JSON.stringify(
dataElement.attributes.mw ) );
+ // Mark the element as not having valid generated contents with
it in case it is
// inserted into another editor (e.g. via paste).
- el.setAttribute( 'data-ve-no-generated-contents', true );
+ els[0].setAttribute( 'data-ve-no-generated-contents', true );
// TODO: Include last-known generated contents in the output
for rich
// paste into a non-VE editor
- return [ el ];
+ return els;
}
};
--
To view, visit https://gerrit.wikimedia.org/r/101231
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iabe678c4246c1d1f51abb058b6e750811fdf9bea
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits