jenkins-bot has submitted this change and it was merged.
Change subject: (bug 43082) Fix problem by calling surfaceObserver.stop( true )
first - before calling handleEnter.
......................................................................
(bug 43082) Fix problem by calling surfaceObserver.stop( true ) first - before
calling handleEnter.
Change-Id: I35c892581943057acbf9ddd638576e998cc82c1a
---
M modules/ve/ce/ve.ce.Surface.js
1 file changed, 38 insertions(+), 35 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js
index 0434acf..c45e8b7 100644
--- a/modules/ve/ce/ve.ce.Surface.js
+++ b/modules/ve/ce/ve.ce.Surface.js
@@ -412,49 +412,56 @@
ve.ce.Surface.prototype.onDocumentKeyDown = function ( e ) {
var trigger;
- // Ignore keydowns while in IME mode but do not preventDefault them.
+ // Ignore keydowns while in IME mode but do not preventDefault them (so
text actually appear on
+ // the screen).
if ( this.inIme === true ) {
return;
}
- // IME
+ // When entering IME mode IE first keydown (e.which = 229) before it
fires compositionstart, so
+ // IME detection have to happen here instead of
onDocumentCompositionStart.
+ // TODO: This code and code in onDocumentCompositionStart are very
similar, consider moving them
+ // to one method.
if ( $.browser.msie === true && e.which === 229 ) {
this.inIme = true;
this.handleInsertion();
return;
}
- if ( ve.ce.isArrowKey( e.keyCode ) ) {
- // Detect start of selecting using shift+arrow keys.
- if ( !this.dragging && !this.selecting && e.shiftKey ) {
- this.selecting = true;
- this.emit( 'selectionStart' );
- }
- if ( ve.ce.isLeftOrRightArrowKey( e.keyCode ) ) {
- this.handleLeftOrRightArrowKey( e );
- } else {
- this.handleUpOrDownArrowKey( e );
- }
- } else if ( e.keyCode === ve.Keys.ENTER ) {
- e.preventDefault();
- this.handleEnter( e );
- } else if ( e.keyCode === ve.Keys.BACKSPACE ) {
- this.handleDelete( e, true );
- this.surfaceObserver.stop( true );
- this.surfaceObserver.start();
- } else if ( e.keyCode === ve.Keys.DELETE ) {
- this.handleDelete( e, false );
- this.surfaceObserver.stop( true );
- this.surfaceObserver.start();
- } else {
- // Execute key command if available
- this.surfaceObserver.stop( true );
- trigger = new ve.ui.Trigger( e );
- if ( trigger.isComplete() && this.surface.execute( trigger ) ) {
+ this.surfaceObserver.stop( true );
+ switch ( e.keyCode ) {
+ case ve.Keys.LEFT:
+ case ve.Keys.RIGHT:
+ case ve.Keys.UP:
+ case ve.Keys.DOWN:
+ if ( !this.dragging && !this.selecting && e.shiftKey ) {
+ this.selecting = true;
+ this.emit( 'selectionStart' );
+ }
+ if ( ve.ce.isLeftOrRightArrowKey( e.keyCode ) ) {
+ this.handleLeftOrRightArrowKey( e );
+ } else {
+ this.handleUpOrDownArrowKey( e );
+ }
+ break;
+ case ve.Keys.ENTER:
e.preventDefault();
- }
- this.surfaceObserver.start();
+ this.handleEnter( e );
+ break;
+ case ve.Keys.BACKSPACE:
+ this.handleDelete( e, true );
+ break;
+ case ve.Keys.DELETE:
+ this.handleDelete( e, false );
+ break;
+ default:
+ trigger = new ve.ui.Trigger( e );
+ if ( trigger.isComplete() && this.surface.execute(
trigger ) ) {
+ e.preventDefault();
+ }
+ break;
}
+ this.surfaceObserver.start();
};
/**
@@ -1072,9 +1079,6 @@
stack = [],
outermostNode = null;
- // Stop polling while we work
- this.surfaceObserver.stop();
-
// Handle removal first
if ( selection.from !== selection.to ) {
tx = ve.dm.Transaction.newFromRemoval( documentModel, selection
);
@@ -1181,7 +1185,6 @@
}
// Reset and resume polling
this.surfaceObserver.clear();
- this.surfaceObserver.start();
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/68300
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I35c892581943057acbf9ddd638576e998cc82c1a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Inez <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits