MediaWiki:Gadget-Break.js: Difference between revisions

From Elwiki
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
// Content to insert
// Content to insert
[
[
{ type: '<br/>' }
{ type: 'break'},
                    { type: '/break'}
],
],
// Annotate content to match surrounding annotations?
// Annotate content to match surrounding annotations?

Latest revision as of 21:28, 28 August 2022

ve.ui.commandRegistry.register(
	new ve.ui.Command(
		// Command name
		'myBreak',
		// Type and name of the action to execute
		'content', 'insert', // Calls the ve.ui.ContentAction#insert method
		{
			// Extra arguments for the action
			args: [
				// Content to insert
				[
					{ type: 'break'},
                    { type: '/break'}
				],
				// Annotate content to match surrounding annotations?
				true,
				// Move cursor to after the new content? (otherwise - select it)
				true
			],
			supportedSelections: [ 'linear' ]
		}
	)
);

ve.ui.MyBreakTool = function VeUiMyBreakTool() {
	ve.ui.MyBreakTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.MyBreakTool, ve.ui.Tool );
ve.ui.MyBreakTool.static.name = 'myBreak';
ve.ui.MyBreakTool.static.group = 'insert';
ve.ui.MyBreakTool.static.title = 'Line break';
ve.ui.MyBreakTool.static.commandName = 'myBreak';
ve.ui.toolFactory.register( ve.ui.MyBreakTool );

ve.ui.sequenceRegistry.register(
	new ve.ui.Sequence(
		'myBreak', // Sequence name
		'myBreak', // Command name
		',,', // Text to detect
		2 // Number of characters to delete after the sequence is matched:
		  // in this case, remove the entire 'kitten'
	)
);