mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
eba7d58dd1
TOC Widget is created in the mw target view class. Adding and removing a heading rebuilds the TOC Widget based on the the order of the page heading nodes. TOC Widget considers TOC page settings and displays in the default manor unless forced or disabled. TOC Widget still needs to be finalized by being placed in the surface. This could be a problem until we have a CE node for it to live in or have some DM work added. Roan and I have discussed how to go forward. To enable the widget you must add the following to LocalSettings.php: $wgVisualEditorEnableTocWidget = true; Change-Id: I488cfbbdb060e50d81f51e0f757e67d0114b8936
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable MWHeadingNode class.
|
|
*
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* ContentEditable MW heading node.
|
|
*
|
|
* @class
|
|
* @extends ve.ce.HeadingNode
|
|
* @constructor
|
|
* @param {ve.dm.MWHeadingNode} model Model to observe
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ce.MWHeadingNode = function VeCeMWHeadingNode( model, config ) {
|
|
// Parent constructor
|
|
ve.ce.HeadingNode.call( this, model, config );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ce.MWHeadingNode, ve.ce.HeadingNode );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ce.MWHeadingNode.static.name = 'mwHeading';
|
|
|
|
/* Methods */
|
|
|
|
ve.ce.MWHeadingNode.prototype.onSetup = function () {
|
|
// Parent method
|
|
ve.ce.HeadingNode.prototype.onSetup.call( this );
|
|
|
|
// Make reference to the surface
|
|
this.surface = this.root.getSurface().getSurface();
|
|
this.rebuildToc();
|
|
};
|
|
|
|
ve.ce.MWHeadingNode.prototype.onTeardown = function () {
|
|
// Parent method
|
|
ve.ce.HeadingNode.prototype.onTeardown.call( this );
|
|
|
|
this.rebuildToc();
|
|
};
|
|
|
|
ve.ce.MWHeadingNode.prototype.rebuildToc = function () {
|
|
if ( this.surface.mwTocWidget ) {
|
|
this.surface.mwTocWidget.rebuild();
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWHeadingNode );
|