mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-27 04:06:51 +00:00
Allow metadata to be annotated
To prevent dirty diffs when inline metadata appears inside annotations. Bug: 50060 Change-Id: I40da3d5e8e987571195142304b1a853e177e36ff
This commit is contained in:
parent
dbabfe5514
commit
4bcc07b120
|
@ -838,6 +838,12 @@ ve.dm.Converter.prototype.getDataFromDomRecursion = function ( domElement, wrapp
|
|||
// 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 @@ ve.dm.Converter.prototype.getDomSubtreeFromData = function ( data, container ) {
|
|||
)
|
||||
)
|
||||
) {
|
||||
// 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(
|
||||
|
|
|
@ -1406,6 +1406,34 @@ ve.dm.example.domToDataCases = {
|
|||
{ '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 @@ ve.dm.example.domToDataCases = {
|
|||
{ 'type': '/internalList' }
|
||||
]
|
||||
},
|
||||
'annotated comment': {
|
||||
'empty annotation with comment': {
|
||||
'html': '<body><p>Foo<b><!-- Bar --></b>Baz</p></body>',
|
||||
'data': [
|
||||
{ 'type': 'paragraph' },
|
||||
|
|
Loading…
Reference in a new issue