MediaWiki

Gadget-ve-linebreak.js

From Dogcraft Wiki

No edit summary
Tag: Manual revert
mNo edit summary
Line 1: Line 1:
ve.ui.commandRegistry.register(
ve.ui.commandRegistry.register(
new ve.ui.Command(
new ve.ui.Command(
// Command name
// Command name
'myBreak',
'myBreak',
// Type and name of the action to execute
// Type and name of the action to execute
'content', 'insert', // Calls the ve.ui.ContentAction#insert method
'content', 'insert', // Calls the ve.ui.ContentAction#insert method
{
{
// Extra arguments for the action
// Extra arguments for the action
args: [
args: [
// Content to insert
// Content to insert
[
[
{ type: 'break' },
{ type: 'break' },
{ type: '/break' }
{ type: '/break' }
],
// Annotate content to match surrounding annotations?
true,
// Move cursor to after the new content? (otherwise - select it)
true
],
],
supportedSelections: [ 'linear' ]
// Annotate content to match surrounding annotations?
}
true,
)
// Move cursor to after the new content? (otherwise - select it)
);
true
],
ve.ui.triggerRegistry.register(
supportedSelections: [ 'linear' ]
}
)
);
 
ve.ui.triggerRegistry.register(
'myBreak', // Command name
{
mac: new ve.ui.Trigger( 'cmd+shift+n' ),
pc: new ve.ui.Trigger( 'ctrl+shift+n' )
}
);
 
ve.ui.sequenceRegistry.register(
new ve.ui.Sequence(
'br', // Sequence name
'myBreak', // Command name
'<br>', // Text to detect
4 // Number of characters to delete after the sequence is matched:
  // in this case, remove the entire 'kitten'
),
new ve.ui.Sequence(
'br /', // Sequence name
'myBreak', // Command name
'myBreak', // Command name
{
'<br />', // Text to detect
mac: new ve.ui.Trigger( 'cmd+shift+n' ),
6 // Number of characters to delete after the sequence is matched:
pc: new ve.ui.Trigger( 'ctrl+shift+n' )
  // in this case, remove the entire 'kitten'
}
),
);
new ve.ui.Sequence(
'br/', // Sequence name
'myBreak', // Command name
'<br/>', // Text to detect
5 // Number of characters to delete after the sequence is matched:
  // in this case, remove the entire 'kitten'
),
new ve.ui.Sequence(
'\n', // Sequence name
'myBreak', // Command name
'\n', // Text to detect
2 // Number of characters to delete after the sequence is matched:
  // in this case, remove the entire 'kitten'
)
);

Revision as of 15:12, 4 November 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.triggerRegistry.register(
	'myBreak', // Command name
	{
		mac: new ve.ui.Trigger( 'cmd+shift+n' ),
		pc: new ve.ui.Trigger( 'ctrl+shift+n' )
	}
);

ve.ui.sequenceRegistry.register(
	new ve.ui.Sequence(
		'br', // Sequence name
		'myBreak', // Command name
		'<br>', // Text to detect
		4 // Number of characters to delete after the sequence is matched:
		  // in this case, remove the entire 'kitten'
	),
	new ve.ui.Sequence(
		'br /', // Sequence name
		'myBreak', // Command name
		'<br />', // Text to detect
		6 // Number of characters to delete after the sequence is matched:
		  // in this case, remove the entire 'kitten'
	),
	new ve.ui.Sequence(
		'br/', // Sequence name
		'myBreak', // Command name
		'<br/>', // Text to detect
		5 // Number of characters to delete after the sequence is matched:
		  // in this case, remove the entire 'kitten'
	),
	new ve.ui.Sequence(
		'\n', // Sequence name
		'myBreak', // Command name
		'\n', // Text to detect
		2 // Number of characters to delete after the sequence is matched:
		  // in this case, remove the entire 'kitten'
	)
);
This page was last modified on 4 November 2022, at 15:12. (18 months ago)