New wikitext editor: unwrap lists when changing style

Bug: T147227
Change-Id: I1a7f86e2a97855be5c44671d8f5918fb87bc70d0
This commit is contained in:
Ed Sanders 2016-10-03 16:10:21 -04:00
parent 88a44f3fe0
commit 69c332d1ad

View file

@ -120,18 +120,6 @@ ve.ui.wikitextCommandRegistry.register(
{ args: [ '<sup>', '</sup>', OO.ui.deferMsg( 'visualeditor-annotationbutton-superscript-tooltip' ) ], supportedSelections: [ 'linear' ] }
)
);
ve.ui.wikitextCommandRegistry.register(
new ve.ui.Command(
'number', 'mwWikitext', 'wrapLine',
{ args: [ '# ', '', OO.ui.deferMsg( 'visualeditor-listbutton-number-tooltip' ) ], supportedSelections: [ 'linear' ] }
)
);
ve.ui.wikitextCommandRegistry.register(
new ve.ui.Command(
'bullet', 'mwWikitext', 'wrapLine',
{ args: [ '* ', '', OO.ui.deferMsg( 'visualeditor-listbutton-bullet-tooltip' ) ], supportedSelections: [ 'linear' ] }
)
);
( function () {
var i, heading = '';
@ -186,6 +174,27 @@ ve.ui.wikitextCommandRegistry.register(
{ args: [ '<blockquote>', '</blockquote>', OO.ui.deferMsg( 'visualeditor-formatdropdown-format-blockquote' ), unformat ], supportedSelections: [ 'linear' ] }
)
);
function unlist( keepType, text ) {
var matches;
if ( ( matches = text.match( /^[*#] */ ) ) && text.slice( 0, 1 ) !== keepType ) {
return [ matches[ 0 ].length, 0 ];
}
}
ve.ui.wikitextCommandRegistry.register(
new ve.ui.Command(
'number', 'mwWikitext', 'wrapLine',
{ args: [ '# ', '', OO.ui.deferMsg( 'visualeditor-listbutton-number-tooltip' ), unlist.bind( this, '#' ) ], supportedSelections: [ 'linear' ] }
)
);
ve.ui.wikitextCommandRegistry.register(
new ve.ui.Command(
'bullet', 'mwWikitext', 'wrapLine',
{ args: [ '* ', '', OO.ui.deferMsg( 'visualeditor-listbutton-bullet-tooltip' ), unlist.bind( this, '*' ) ], supportedSelections: [ 'linear' ] }
)
);
} )();
ve.ui.wikitextCommandRegistry.register(