Merge "CollabTarget: Replace button in toolbar"

This commit is contained in:
jenkins-bot 2019-05-09 17:03:25 +00:00 committed by Gerrit Code Review
commit 83729f53d7
2 changed files with 32 additions and 26 deletions

View file

@ -46,11 +46,6 @@ ve.init.mw.CollabTarget = function VeInitMwCollabTarget( title, rebaserUrl, conf
// eslint-disable-next-line no-jquery/no-global-selector
this.$editableContent = $( '#mw-content-text' );
this.toolbarExportButton = new OO.ui.ButtonWidget( {
label: ve.msg( 'visualeditor-rebase-client-export' ),
flags: [ 'progressive', 'primary' ]
} ).connect( this, { click: 'onExportButtonClick' } );
// Initialization
this.$element.addClass( 've-init-mw-articleTarget ve-init-mw-collabTarget' );
};
@ -94,6 +89,10 @@ ve.init.mw.CollabTarget.static.actionGroups = [
{
name: 'authorList',
include: [ 'authorList' ]
},
{
name: 'export',
include: [ 'export' ]
}
];
@ -111,25 +110,6 @@ ve.init.mw.CollabTarget.prototype.transformPage = function () {
ve.init.mw.CollabTarget.prototype.restorePage = function () {
};
/**
* @inheritdoc
*/
ve.init.mw.CollabTarget.prototype.setupToolbar = function () {
// Parent method
ve.init.mw.CollabTarget.super.prototype.setupToolbar.apply( this, arguments );
this.getToolbar().$actions.append( this.toolbarExportButton.$element );
};
/**
* Handle click events from the export button
*/
ve.init.mw.CollabTarget.prototype.onExportButtonClick = function () {
var surface = this.getSurface(),
windowAction = ve.ui.actionFactory.create( 'window', surface );
windowAction.open( 'mwExportWikitext', { surface: surface } );
};
/**
* Get the title of the imported document, if there was one
*
@ -149,3 +129,28 @@ ve.init.mw.CollabTarget.prototype.getPageName = function () {
/* Registration */
ve.init.mw.targetFactory.register( ve.init.mw.CollabTarget );
/**
* Export tool
*/
ve.ui.MWExportTool = function VeUiMWExportTool() {
// Parent constructor
ve.ui.MWExportTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.MWExportTool, ve.ui.Tool );
ve.ui.MWExportTool.static.name = 'export';
ve.ui.MWExportTool.static.displayBothIconAndLabel = true;
ve.ui.MWExportTool.static.group = 'export';
ve.ui.MWExportTool.static.autoAddToCatchall = false;
ve.ui.MWExportTool.static.flags = [ 'progressive', 'primary' ];
ve.ui.MWExportTool.static.title =
OO.ui.deferMsg( 'visualeditor-rebase-client-export' );
ve.ui.MWExportTool.static.commandName = 'mwExportWikitext';
ve.ui.toolFactory.register( ve.ui.MWExportTool );
ve.ui.commandRegistry.register(
new ve.ui.Command(
'mwExportWikitext', 'window', 'open',
{ args: [ 'mwExportWikitext' ] }
)
);

View file

@ -100,10 +100,11 @@ ve.ui.MWExportWikitextDialog.prototype.initialize = function () {
ve.ui.MWExportWikitextDialog.prototype.getSetupProcess = function ( data ) {
return ve.ui.MWExportWikitextDialog.super.prototype.getSetupProcess.call( this, data )
.next( function () {
var dialog = this;
var dialog = this,
surface = ve.init.target.getSurface();
this.titleButton.setDisabled( true );
this.wikitext.pushPending();
ve.init.target.getWikitextFragment( data.surface.getModel().getDocument() ).then( function ( wikitext ) {
ve.init.target.getWikitextFragment( surface.getModel().getDocument() ).then( function ( wikitext ) {
dialog.wikitext.setValue( wikitext.trim() );
dialog.wikitext.$input.scrollTop( 0 );
dialog.wikitext.popPending();