Esanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/101231
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, 22 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/31/101231/1 diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js index adedc22..3ffd78e 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>' ).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 f7e0733..52b7725 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js @@ -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: newchange Gerrit-Change-Id: Iabe678c4246c1d1f51abb058b6e750811fdf9bea Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits