mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-21 02:22:51 +00:00
EditCheck: Close any existing edit check dialog before opening onBeforeSave list
Depends-On: Ib58b05fab39bcdc7d68b84ae235cfff775d7712c Change-Id: I04e6b209935756d6e56d479ec09f341463622acb
This commit is contained in:
parent
e9c7503c72
commit
414e5d29ed
|
@ -156,42 +156,45 @@ if ( mw.config.get( 'wgVisualEditorConfig' ).editCheck || mw.editcheck.ecenable
|
|||
}
|
||||
|
||||
saveProcess.next( () => {
|
||||
toolbar.toggle( false );
|
||||
target.onContainerScroll();
|
||||
// surface.executeCommand( 'editCheckDialogBeforeSave' );
|
||||
const windowAction = ve.ui.actionFactory.create( 'window', surface, 'check' );
|
||||
return windowAction.open( 'editCheckDialog', { listener: 'onBeforeSave', reviewMode: true } )
|
||||
.then( ( instance ) => instance.closing )
|
||||
.then( ( data ) => {
|
||||
reviewToolbar.$element.remove();
|
||||
toolbar.toggle( true );
|
||||
target.toolbar = toolbar;
|
||||
if ( $contextContainer ) {
|
||||
surface.context.popup.$container = $contextContainer;
|
||||
surface.context.popup.containerPadding = contextPadding;
|
||||
}
|
||||
// Creating a new PositionedTargetToolbar stole the
|
||||
// toolbar windowmanagers, so we need to make the
|
||||
// original toolbar reclaim them:
|
||||
toolbar.disconnect( target );
|
||||
target.setupToolbar( surface );
|
||||
target.onContainerScroll();
|
||||
// .always is not chainable
|
||||
return windowAction.close( 'editCheckDialog' ).closed.then( () => {}, () => {} ).then( () => {
|
||||
toolbar.toggle( false );
|
||||
target.onContainerScroll();
|
||||
// surface.executeCommand( 'editCheckDialogBeforeSave' );
|
||||
return windowAction.open( 'editCheckDialog', { listener: 'onBeforeSave', reviewMode: true } )
|
||||
.then( ( instance ) => instance.closing )
|
||||
.then( ( data ) => {
|
||||
reviewToolbar.$element.remove();
|
||||
toolbar.toggle( true );
|
||||
target.toolbar = toolbar;
|
||||
if ( $contextContainer ) {
|
||||
surface.context.popup.$container = $contextContainer;
|
||||
surface.context.popup.containerPadding = contextPadding;
|
||||
}
|
||||
// Creating a new PositionedTargetToolbar stole the
|
||||
// toolbar windowmanagers, so we need to make the
|
||||
// original toolbar reclaim them:
|
||||
toolbar.disconnect( target );
|
||||
target.setupToolbar( surface );
|
||||
target.onContainerScroll();
|
||||
|
||||
if ( data ) {
|
||||
const delay = ve.createDeferred();
|
||||
// If they inserted, wait 2 seconds on desktop
|
||||
// before showing save dialog to make sure insertions are finialized
|
||||
setTimeout( () => {
|
||||
ve.track( 'counter.editcheck.preSaveChecksCompleted' );
|
||||
delay.resolve();
|
||||
}, !OO.ui.isMobile() && data.action !== 'reject' ? 2000 : 0 );
|
||||
return delay.promise();
|
||||
} else {
|
||||
// closed via "back" or otherwise
|
||||
ve.track( 'counter.editcheck.preSaveChecksAbandoned' );
|
||||
return ve.createDeferred().reject().promise();
|
||||
}
|
||||
} );
|
||||
if ( data ) {
|
||||
const delay = ve.createDeferred();
|
||||
// If they inserted, wait 2 seconds on desktop
|
||||
// before showing save dialog to make sure insertions are finialized
|
||||
setTimeout( () => {
|
||||
ve.track( 'counter.editcheck.preSaveChecksCompleted' );
|
||||
delay.resolve();
|
||||
}, !OO.ui.isMobile() && data.action !== 'reject' ? 2000 : 0 );
|
||||
return delay.promise();
|
||||
} else {
|
||||
// closed via "back" or otherwise
|
||||
ve.track( 'counter.editcheck.preSaveChecksAbandoned' );
|
||||
return ve.createDeferred().reject().promise();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
} else {
|
||||
// Counterpart to earlier preSaveChecksShown, for use in tracking
|
||||
|
|
Loading…
Reference in a new issue