jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/377471 )

Change subject: Trigger proper undo/redo when inputType=historyUndo/Redo
......................................................................


Trigger proper undo/redo when inputType=historyUndo/Redo

Bug: T175634
Change-Id: Ic0bcec267a021ccdc9285ec9713eb82dd2fb0c42
---
M src/ce/ve.ce.Surface.js
M tests/ce/ve.ce.TestRunner.js
2 files changed, 23 insertions(+), 1 deletion(-)

Approvals:
  DLynch: Looks good to me, approved
  jenkins-bot: Verified
  Jforrester: Looks good to me, but someone else must approve



diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 6a7fb06..b81f76c 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -280,6 +280,19 @@
 ];
 
 /**
+ * Values of InputEvent.inputType which map to a command
+ *
+ * Currently these are triggered when the user selects
+ * undo/redo from the context menu in Chrome.
+ *
+ * @type {Object}
+ */
+ve.ce.Surface.static.inputTypeCommands = {
+       historyUndo: 'undo',
+       historyRedo: 'redo'
+};
+
+/**
  * Cursor holder template
  *
  * @static
@@ -2439,7 +2452,14 @@
  * @method
  * @param {jQuery.Event} e The input event
  */
-ve.ce.Surface.prototype.onDocumentInput = function () {
+ve.ce.Surface.prototype.onDocumentInput = function ( e ) {
+       var inputType = e.originalEvent.inputType;
+
+       if ( inputType && inputType in 
this.constructor.static.inputTypeCommands ) {
+               this.getSurface().executeCommand( 
this.constructor.static.inputTypeCommands[ inputType ] );
+               e.preventDefault();
+               return;
+       }
        this.incRenderLock();
        try {
                this.surfaceObserver.pollOnce();
diff --git a/tests/ce/ve.ce.TestRunner.js b/tests/ce/ve.ce.TestRunner.js
index 8d50294..a48bacc 100644
--- a/tests/ce/ve.ce.TestRunner.js
+++ b/tests/ce/ve.ce.TestRunner.js
@@ -169,6 +169,8 @@
  * @param {Object} ev Fake event object with any necessary properties
  */
 ve.ce.TestRunner.prototype.sendEvent = function ( eventName, ev ) {
+       // Ensure ev has an originalEvent property.
+       ev.originalEvent = ev.originalEvent || {};
        this.view.eventSequencer.onEvent( eventName, ev );
 };
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic0bcec267a021ccdc9285ec9713eb82dd2fb0c42
Gerrit-PatchSet: 3
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>
Gerrit-Reviewer: DLynch <dly...@wikimedia.org>
Gerrit-Reviewer: Divec <da...@troi.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to