mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 08:10:35 +00:00
Merge "Add handling for mw:DisplaySpace"
This commit is contained in:
commit
bc2204b6c0
|
@ -31,16 +31,28 @@ ve.dm.MWEntityNode.static.isContent = true;
|
|||
|
||||
ve.dm.MWEntityNode.static.matchTagNames = [ 'span' ];
|
||||
|
||||
ve.dm.MWEntityNode.static.matchRdfaTypes = [ 'mw:Entity' ];
|
||||
ve.dm.MWEntityNode.static.matchRdfaTypes = [ 'mw:Entity', 'mw:DisplaySpace' ];
|
||||
|
||||
ve.dm.MWEntityNode.static.allowedRdfaTypes = [ 'mw:Placeholder' ];
|
||||
|
||||
ve.dm.MWEntityNode.static.toDataElement = function ( domElements ) {
|
||||
return { type: this.name, attributes: { character: domElements[ 0 ].textContent } };
|
||||
var dataElement = {
|
||||
type: this.name,
|
||||
attributes: {
|
||||
character: domElements[ 0 ].textContent
|
||||
}
|
||||
};
|
||||
if ( domElements[ 0 ].getAttribute( 'typeof' ).indexOf( 'mw:DisplaySpace' ) !== -1 ) {
|
||||
dataElement.attributes.displaySpace = true;
|
||||
}
|
||||
return dataElement;
|
||||
};
|
||||
|
||||
ve.dm.MWEntityNode.static.toDomElements = function ( dataElement, doc ) {
|
||||
var domElement = doc.createElement( 'span' ),
|
||||
textNode = doc.createTextNode( dataElement.attributes.character );
|
||||
domElement.setAttribute( 'typeof', 'mw:Entity' );
|
||||
domElement.setAttribute( 'typeof',
|
||||
dataElement.attributes.displaySpace ? 'mw:DisplaySpace mw:Placeholder' : 'mw:Entity' );
|
||||
domElement.appendChild( textNode );
|
||||
return [ domElement ];
|
||||
};
|
||||
|
|
|
@ -1767,6 +1767,27 @@ ve.dm.mwExample.domToDataCases = {
|
|||
{ type: '/internalList' }
|
||||
]
|
||||
},
|
||||
'mw:DisplaySpace': {
|
||||
body: '<p>a<span typeof="mw:DisplaySpace mw:Placeholder"> </span>: b</p>',
|
||||
data: [
|
||||
{ type: 'paragraph' },
|
||||
'a',
|
||||
{
|
||||
type: 'mwEntity',
|
||||
attributes: {
|
||||
character: '\u00a0',
|
||||
displaySpace: true
|
||||
}
|
||||
},
|
||||
{ type: '/mwEntity' },
|
||||
':',
|
||||
' ',
|
||||
'b',
|
||||
{ type: '/paragraph' },
|
||||
{ type: 'internalList' },
|
||||
{ type: '/internalList' }
|
||||
]
|
||||
},
|
||||
'wrapping with mw:Entity': {
|
||||
body: 'a<span typeof="mw:Entity">¢</span>b<span typeof="mw:Entity">¥</span><span typeof="mw:Entity">™</span>',
|
||||
data: [
|
||||
|
|
Loading…
Reference in a new issue