Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/290068

Change subject: Undo sequence input stripping if window is dismissed
......................................................................

Undo sequence input stripping if window is dismissed

Bug: T110800
Change-Id: I334dabc711225b002beaa274aa87dbaa3f2c360e
---
M src/ui/actions/ve.ui.WindowAction.js
M src/ui/ve.ui.Command.js
M src/ui/ve.ui.Sequence.js
3 files changed, 20 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/68/290068/1

diff --git a/src/ui/actions/ve.ui.WindowAction.js 
b/src/ui/actions/ve.ui.WindowAction.js
index 2e46635..c88a0dd 100644
--- a/src/ui/actions/ve.ui.WindowAction.js
+++ b/src/ui/actions/ve.ui.WindowAction.js
@@ -91,7 +91,11 @@
                                        if ( 
!win.constructor.static.activeSurface ) {
                                                surface.getView().activate();
                                        }
-                                       closed.then( function () {
+                                       closed.then( function ( closedData ) {
+                                               // Sequence-triggered window 
closed without action, undo
+                                               if ( data.strippedSequence && 
!( closedData && closedData.action ) ) {
+                                                       
surface.getModel().undo();
+                                               }
                                                surface.getView().emit( 
'position' );
                                        } );
                                } );
diff --git a/src/ui/ve.ui.Command.js b/src/ui/ve.ui.Command.js
index b58397e..7fe5372 100644
--- a/src/ui/ve.ui.Command.js
+++ b/src/ui/ve.ui.Command.js
@@ -32,11 +32,12 @@
  * Execute command on a surface.
  *
  * @param {ve.ui.Surface} surface Surface to execute command on
+ * @param {Object} [args] Custom arguments to override defaults
  * @return {boolean} Command was executed
  */
-ve.ui.Command.prototype.execute = function ( surface ) {
+ve.ui.Command.prototype.execute = function ( surface, args ) {
        if ( this.isExecutable( surface.getModel().getFragment() ) ) {
-               return surface.execute.apply( surface, [ this.action, 
this.method ].concat( this.args ) );
+               return surface.execute.apply( surface, [ this.action, 
this.method ].concat( args || this.args ) );
        } else {
                return false;
        }
diff --git a/src/ui/ve.ui.Sequence.js b/src/ui/ve.ui.Sequence.js
index e43d77d..168007d 100644
--- a/src/ui/ve.ui.Sequence.js
+++ b/src/ui/ve.ui.Sequence.js
@@ -66,7 +66,7 @@
  * @return {boolean} The command executed
  */
 ve.ui.Sequence.prototype.execute = function ( surface, range ) {
-       var command, stripRange, executed, stripFragment, selection,
+       var command, stripRange, executed, stripFragment, selection, args,
                surfaceModel = surface.getModel();
 
        if ( surface.getCommands().indexOf( this.getCommandName() ) === -1 ) {
@@ -94,9 +94,19 @@
                surfaceModel.setLinearSelection( range );
        }
 
-       executed = command.execute( surface );
+       // For sequences that trigger dialogs, pass an extra flag so the window 
knows
+       // to un-strip the sequence if it is closed without action. See 
ve.ui.WindowAction.
+       if ( command.getAction() === 'window' && command.getMethod() === 'open' 
) {
+               args = ve.copy( command.args );
+               args[ 1 ] = args[ 1 ] || {};
+               args[ 1 ].strippedSequence = !!this.strip;
+       }
+
+       executed = command.execute( surface, args );
 
        if ( executed && stripFragment ) {
+               // Strip the typed text. This will be undone if the action 
triggered was
+               // window/open and the window is dismissed
                stripFragment.removeContent();
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/290068
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I334dabc711225b002beaa274aa87dbaa3f2c360e
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to