Esanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/70061
Change subject: Allow metadata to be annotated ...................................................................... Allow metadata to be annotated To prevent dirty diffs when inline metadata appears inside annotations. Bug: 50060 Change-Id: I40da3d5e8e987571195142304b1a853e177e36ff --- M modules/ve/dm/ve.dm.Converter.js M modules/ve/test/dm/ve.dm.example.js 2 files changed, 40 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/61/70061/1 diff --git a/modules/ve/dm/ve.dm.Converter.js b/modules/ve/dm/ve.dm.Converter.js index 2522e29..d09537b 100644 --- a/modules/ve/dm/ve.dm.Converter.js +++ b/modules/ve/dm/ve.dm.Converter.js @@ -838,6 +838,12 @@ // TODO treat this as a node with nodeName #comment, removes code duplication childDataElements = this.createDataElements( ve.dm.AlienMetaItem, [ childDomElement ] ); childDataElements.push( { 'type': '/' + childDataElements[0].type } ); + + // Annotate + if ( !context.annotations.isEmpty() ) { + childDataElements[0].annotations = context.annotations.getIndexes().slice(); + } + if ( context.inWrapper ) { wrappedMetaItems = wrappedMetaItems.concat( childDataElements ); if ( wrappedWhitespace !== '' ) { @@ -1042,13 +1048,15 @@ ) ) ) { - // Annotated text or annotated nodes + // Annotated text, nodes or meta text = ''; while ( ve.isArray( data[i] ) || ( - data[i].annotations !== undefined && - this.nodeFactory.isNodeContent( data[i].type ) + data[i].annotations !== undefined && ( + this.metaItemFactory.lookup( data[i].type ) || + this.nodeFactory.isNodeContent( data[i].type ) + ) ) ) { annotations = new ve.dm.AnnotationSet( diff --git a/modules/ve/test/dm/ve.dm.example.js b/modules/ve/test/dm/ve.dm.example.js index 83278d1..451c5cb 100644 --- a/modules/ve/test/dm/ve.dm.example.js +++ b/modules/ve/test/dm/ve.dm.example.js @@ -1406,6 +1406,34 @@ { 'type': '/internalList' } ] }, + 'annotated metadata': { + 'html': '<body><p><b><!--foo-->bar<!--baz--></b></p></body>', + 'data': [ + { 'type': 'paragraph' }, + { + 'type': 'alienMeta', + 'annotations': [ ve.dm.example.bold ], + 'attributes': { + 'domElements': $( '<!--foo-->' ).toArray() + } + }, + { 'type': '/alienMeta' }, + [ 'b', [ ve.dm.example.bold ] ], + [ 'a', [ ve.dm.example.bold ] ], + [ 'r', [ ve.dm.example.bold ] ], + { + 'type': 'alienMeta', + 'annotations': [ ve.dm.example.bold ], + 'attributes': { + 'domElements': $( '<!--baz-->' ).toArray() + } + }, + { 'type': '/alienMeta' }, + { 'type': '/paragraph' }, + { 'type': 'internalList' }, + { 'type': '/internalList' } + ] + }, 'wrapping of bare content': { 'html': '<body>abc</body>', 'data': [ @@ -1715,7 +1743,7 @@ { 'type': '/internalList' } ] }, - 'annotated comment': { + 'empty annotation with comment': { 'html': '<body><p>Foo<b><!-- Bar --></b>Baz</p></body>', 'data': [ { 'type': 'paragraph' }, -- To view, visit https://gerrit.wikimedia.org/r/70061 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I40da3d5e8e987571195142304b1a853e177e36ff 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