jenkins-bot has submitted this change and it was merged.

Change subject: Update VE core submodule to master (d020898)
......................................................................


Update VE core submodule to master (d020898)

New changes:
985edd2 Localisation updates from https://translatewiki.net.
9883b44 Follow-up 985edd24: Fix build for added language 'shn'
b0d5ee2 Localisation updates from https://translatewiki.net.
18ca837 Localisation updates from https://translatewiki.net.
f6a0945 Don't include trailing punctuation in autolinked typed text

Local changes:
* Add MW-specific trailing punctuation rules for autolinking

Change-Id: Iaa620142222f47e9fde2d03b935f38c24d38800b
---
M VisualEditor.hooks.php
M lib/ve
A modules/ve-mw/tests/ui/actions/ve.ui.MWLinkAction.test.js
M modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js
4 files changed, 73 insertions(+), 0 deletions(-)

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



diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 6744e25..6d7eefc 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -606,6 +606,7 @@
                                
'modules/ve-mw/tests/ui/actions/ve.ui.FormatAction.test.js',
                                
'lib/ve/tests/ui/actions/ve.ui.IndentationAction.test.js',
                                
'lib/ve/tests/ui/actions/ve.ui.LinkAction.test.js',
+                               
'modules/ve-mw/tests/ui/actions/ve.ui.MWLinkAction.test.js',
                                
'lib/ve/tests/ui/actions/ve.ui.ListAction.test.js',
                                // VisualEditor initialization Tests
                                'lib/ve/tests/init/ve.init.Platform.test.js',
diff --git a/lib/ve b/lib/ve
index 28c686e..d020898 160000
--- a/lib/ve
+++ b/lib/ve
-Subproject commit 28c686e9ef0d8b36ae3d4656d2ccdc423df4d62b
+Subproject commit d020898606ed382aec403389ab7bfb65b9d8b620
diff --git a/modules/ve-mw/tests/ui/actions/ve.ui.MWLinkAction.test.js 
b/modules/ve-mw/tests/ui/actions/ve.ui.MWLinkAction.test.js
new file mode 100644
index 0000000..7de1f5e
--- /dev/null
+++ b/modules/ve-mw/tests/ui/actions/ve.ui.MWLinkAction.test.js
@@ -0,0 +1,60 @@
+/*!
+ * VisualEditor UserInterface Actions MWLinkAction tests.
+ *
+ * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+QUnit.module( 've.ui.MWLinkAction' );
+
+/* Tests */
+
+function runMWAutolinkTest( assert, html, method, range, expectedRange, 
expectedData, expectedOriginalData, msg ) {
+       var status,
+               expectFail = /^Don't/.test( msg ),
+               surface = ve.test.utils.createModelOnlySurfaceFromHtml( html || 
ve.dm.example.html ),
+               linkAction = new ve.ui.MWLinkAction( surface ),
+               data = ve.copy( surface.getModel().getDocument().getFullData() 
),
+               originalData = ve.copy( data );
+
+       expectedData( data );
+       if ( expectedOriginalData ) {
+               expectedOriginalData( originalData );
+       }
+       surface.getModel().setLinearSelection( range );
+       status = linkAction[method]();
+       assert.equal( status, !expectFail, msg + ': action return value' );
+
+       assert.equalLinearData( surface.getModel().getDocument().getFullData(), 
data, msg + ': data models match' );
+       assert.equalRange( surface.getModel().getSelection().getRange(), 
expectedRange, msg + ': ranges match' );
+
+       if ( status ) {
+               surface.getModel().undo();
+       }
+
+       assert.equalLinearData( surface.getModel().getDocument().getFullData(), 
originalData, msg + ' (undo): data models match' );
+       assert.equalRange( surface.getModel().getSelection().getRange(), 
expectedRange, msg + ' (undo): ranges match' );
+}
+
+QUnit.test( 'MW autolink', function ( assert ) {
+       var i,
+               cases = [
+                       {
+                               html: 
'<p>https://en.wikipedia.org/wiki/Red_(disambiguation) xyz</p>',
+                               range: new ve.Range( 1, 52 ),
+                               method: 'autolinkUrl',
+                               expectedRange: new ve.Range( 52, 52 ),
+                               expectedData: function ( data ) {
+                                       for ( var i = 1; i < 51; i++ ) {
+                                               data[i] = [ data[i], [ 0 ] ];
+                                       }
+                               },
+                               msg: 'Strip trailing punctuation (but not 
matched parens)'
+                       }
+               ];
+
+       QUnit.expect( cases.length * 5 );
+       for ( i = 0; i < cases.length; i++ ) {
+               runMWAutolinkTest( assert, cases[i].html, cases[i].method, 
cases[i].range, cases[i].expectedRange, cases[i].expectedData, 
cases[i].expectedOriginalData, cases[i].msg );
+       }
+} );
diff --git a/modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js 
b/modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js
index 53405ff..107c177 100644
--- a/modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js
+++ b/modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js
@@ -36,6 +36,18 @@
 /* Methods */
 
 /**
+ * Match the trailing punctuation set used for autolinks in wikitext.
+ * Closing parens are only stripped if open parens are missing from the
+ * candidate text, so that URLs with embedded matched parentheses (like
+ * wiki articles with disambiguation text) autolink nicely.
+ * @method
+ * @inheritdoc
+ */
+ve.ui.MWLinkAction.prototype.getTrailingPunctuation = function ( candidate ) {
+       return /\(/.test( candidate ) ? /[,;.:!?]+$/ : /[,;.:!?)]+$/;
+};
+
+/**
  * @method
  * @inheritdoc
  * @return {ve.dm.MWExternalLinkAnnotation} The annotation to use.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iaa620142222f47e9fde2d03b935f38c24d38800b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to