mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 00:55:00 +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
66 lines
1.3 KiB
JavaScript
66 lines
1.3 KiB
JavaScript
/**
|
|
* Creates an ve.ce.HeadingNode object.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
* @extends {ve.ce.LeafNode}
|
|
* @param {ve.dm.HeadingNode} model Heading model to view
|
|
*/
|
|
ve.ce.HeadingNode = function( model ) {
|
|
// Inheritance
|
|
var level = model.getElementAttribute( 'level' ),
|
|
type = ve.ce.HeadingNode.domNodeTypes[level];
|
|
if ( type === undefined ) {
|
|
throw 'Invalid level attribute for heading node: ' + level;
|
|
}
|
|
ve.ce.LeafNode.call( this, model, $( '<' + type + '></' + type + '>' ) );
|
|
|
|
// Properties
|
|
this.currentLevelHash = level;
|
|
|
|
// DOM Changes
|
|
this.$.addClass( 've-ce-headingNode' );
|
|
|
|
// Events
|
|
var _this = this;
|
|
this.model.on( 'update', function() {
|
|
_this.setLevel();
|
|
} );
|
|
};
|
|
|
|
/* Static Members */
|
|
|
|
ve.ce.HeadingNode.domNodeTypes = {
|
|
'1': 'h1',
|
|
'2': 'h2',
|
|
'3': 'h3',
|
|
'4': 'h4',
|
|
'5': 'h5',
|
|
'6': 'h6'
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
ve.ce.HeadingNode.prototype.setLevel = function() {
|
|
var level = this.model.getElementAttribute( 'level' ),
|
|
type = ve.ce.HeadingNode.domNodeTypes[level];
|
|
if ( type === undefined ) {
|
|
throw 'Invalid level attribute for heading node: ' + level;
|
|
}
|
|
if ( level !== this.currentLevelHash ) {
|
|
this.currentLevelHash = level;
|
|
this.convertDomElement( type );
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.DocumentNode.splitRules.heading = {
|
|
'self': true,
|
|
'children': null
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.extendClass( ve.ce.HeadingNode, ve.ce.LeafNode );
|