User:Catrope/common.js

mw.libs.ve.addPlugin( function {

// Line break tool

// Register command to insert break node ve.ui.commandRegistry.register(	new ve.ui.Command( 'break', 'content', 'insert', [ { 'type': 'break' }, { 'type': '/break' } ], true ) );

// Create tool ve.ui.BreakTool = function ( toolGroup, config ) { // Parent constructor ve.ui.Tool.call( this, toolGroup, config ); };

OO.inheritClass( ve.ui.BreakTool, ve.ui.Tool );

ve.ui.BreakTool.static.name = 'break'; ve.ui.BreakTool.static.title = 'Line break'; ve.ui.BreakTool.static.commandName = 'break'; // Link break tool to 'break' command

ve.ui.toolFactory.register( ve.ui.BreakTool );

// HR code

// HR node (DM) ve.dm.HorizontalRuleNode = function ( length, element ) { // Parent constructor ve.dm.LeafNode.call( this, 0, element ); }; OO.inheritClass( ve.dm.HorizontalRuleNode, ve.dm.LeafNode ); ve.dm.HorizontalRuleNode.static.name = 'horizontalRule'; ve.dm.HorizontalRuleNode.static.isContent = true; ve.dm.HorizontalRuleNode.static.matchTagNames = [ 'hr' ]; ve.dm.modelRegistry.register( ve.dm.HorizontalRuleNode );

// HR node (CE) ve.ce.HorizontalRuleNode = function ( model, config ) { // Parent constructor ve.ce.LeafNode.call( this, model, config ); // Mixin constructors ve.ce.FocusableNode.call( this ); ve.ce.ProtectedNode.call( this ); ve.ce.RelocatableNode.call( this ); }; OO.inheritClass( ve.ce.HorizontalRuleNode, ve.ce.LeafNode ); OO.mixinClass( ve.ce.HorizontalRuleNode, ve.ce.FocusableNode ); OO.mixinClass( ve.ce.HorizontalRuleNode, ve.ce.ProtectedNode ); OO.mixinClass( ve.ce.HorizontalRuleNode, ve.ce.RelocatableNode ); ve.ce.HorizontalRuleNode.static.name = 'horizontalRule'; // Link CE node to DM node by giving it the same name ve.ce.HorizontalRuleNode.static.tagName = 'hr'; ve.ce.nodeFactory.register( ve.ce.HorizontalRuleNode );

// HR command ve.ui.commandRegistry.register( new ve.ui.Command( 'rule', 'content', 'insert', [ { 'type': 'horizontalRule' }, { 'type': '/horizontalRule' } ], true ) );

// HR tool ve.ui.InsertRuleTool = function ( toolGroup, config ) { // Parent constructor ve.ui.Tool.call( this, toolGroup, config ); }; OO.inheritClass( ve.ui.InsertRuleTool, ve.ui.Tool ); ve.ui.InsertRuleTool.static.name = 'insertRule'; ve.ui.InsertRuleTool.static.title = 'Horizontal rule'; ve.ui.InsertRuleTool.static.commandName = 'rule'; // Link tool to command ve.ui.toolFactory.register( ve.ui.InsertRuleTool );

});