mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
85b807ed5d
This makes it possible to get identical rendering in the editor, but may make other things more complex. The Wikitext serializer is no longer compatible for rendering lists so it's been stubbed out. Also the way the toolbar works with lists is broken, so that's been disabled. The HTML serializer has been fixed to work correctly and no-longer-used styles have been removed. Change-Id: If156f55068b1f6d229b3fa789164f28b2e3dfc76
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
/**
|
|
* Creates an ve.ce.ListItemNode object.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
* @extends {ve.ce.LeafNode}
|
|
* @param {ve.dm.ListItemNode} model List item model to view
|
|
*/
|
|
ve.ce.ListItemNode = function( model ) {
|
|
// Inheritance
|
|
var style = model.getElementAttribute( 'style' ),
|
|
type = ve.ce.ListItemNode.domNodeTypes[style];
|
|
ve.ce.BranchNode.call( this, model, $( '<' + type + '></' + type + '>' ) );
|
|
|
|
// Properties
|
|
this.currentStylesHash = null;
|
|
|
|
// DOM Changes
|
|
this.$.addClass( 've-ce-listItemNode' );
|
|
|
|
// Events
|
|
var _this = this;
|
|
this.model.on( 'update', function() {
|
|
_this.setStyle();
|
|
} );
|
|
};
|
|
|
|
/* Static Members */
|
|
|
|
ve.ce.ListItemNode.domNodeTypes = {
|
|
'item': 'li',
|
|
'definition': 'dd',
|
|
'term': 'dt'
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
ve.ce.HeadingNode.prototype.setStyle = function() {
|
|
var style = this.model.getElementAttribute( 'style' ),
|
|
type = ve.ce.ListItemNode.domNodeTypes[style];
|
|
if ( type === undefined ) {
|
|
throw 'Invalid style attribute for heading node: ' + style;
|
|
}
|
|
if ( style !== this.currentStyleHash ) {
|
|
this.currentStyleHash = style;
|
|
this.convertDomElement( type );
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.DocumentNode.splitRules.listItem = {
|
|
'self': true,
|
|
'children': false
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.extendClass( ve.ce.ListItemNode, ve.ce.BranchNode );
|