Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/233214
Change subject: Override new getDisplayTitle method for internal links
......................................................................
Override new getDisplayTitle method for internal links
This allows the URL paste handler to use the normalized title
as the text content. Add a test to cover this behaviour.
Depends on Ica48fea69cc in core.
Bug: T109980
Change-Id: I2784adaf2949a73256049921227dde0917ef9aef
---
M VisualEditor.hooks.php
M modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
A
modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
3 files changed, 51 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/14/233214/1
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 1a79507..316a288 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -612,6 +612,7 @@
'lib/ve/tests/ui/datatransferhandlers/ve.ui.DSVFileTransferHandler.test.js',
'lib/ve/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js',
'modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.test.js',
+
'modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js',
// VisualEditor initialization Tests
'lib/ve/tests/init/ve.init.Platform.test.js',
'modules/ve-mw/tests/init/targets/ve.init.mw.DesktopArticleTarget.test.js',
diff --git a/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
b/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
index 0373196..dbe22b0 100644
--- a/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
+++ b/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
@@ -192,6 +192,13 @@
return {};
};
+/**
+ * @inheritdoc
+ */
+ve.dm.MWInternalLinkAnnotation.prototype.getDisplayTitle = function () {
+ return this.getAttribute( 'normalizedTitle' );
+};
+
/* Registration */
ve.dm.modelRegistry.register( ve.dm.MWInternalLinkAnnotation );
diff --git
a/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
b/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
new file mode 100644
index 0000000..990d779
--- /dev/null
+++
b/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
@@ -0,0 +1,43 @@
+/*!
+ * VisualEditor UserInterface UrlStringTransferHandler tests.
+ *
+ * @copyright 2011-2015 VisualEditor Team and others; see
http://ve.mit-license.org
+ */
+
+/* global runUrlStringHandlerTest */
+
+QUnit.module( 've.ui.UrlStringTransferHandler (MW)' );
+
+/* Tests */
+
+QUnit.test( 'paste', function ( assert ) {
+ var i,
+ cases = [
+ {
+ msg: 'External link converts to internal link',
+ pasteString: location.origin +
mw.Title.newFromText( 'Main Page' ).getUrl(),
+ pasteType: 'text/plain',
+ expectedData: function () {
+ // Explicitly create an internal link
so we can assert this behaviour is working
+ var a =
ve.dm.MWInternalLinkAnnotation.static.newFromTitle( new mw.Title.newFromText(
'Main Page' ) ).element;
+ return [
+ [ 'M', [ a ] ],
+ [ 'a', [ a ] ],
+ [ 'i', [ a ] ],
+ [ 'n', [ a ] ],
+ [ ' ', [ a ] ],
+ [ 'P', [ a ] ],
+ [ 'a', [ a ] ],
+ [ 'g', [ a ] ],
+ [ 'e', [ a ] ],
+ ' '
+ ];
+ }
+ }
+ ];
+
+ QUnit.expect( cases.length );
+ for ( i = 0; i < cases.length; i++ ) {
+ runUrlStringHandlerTest( assert, cases[ i ].pasteString, cases[
i ].pasteHtml, cases[ i ].pasteType, cases[ i ].expectedData, cases[ i ].msg );
+ }
+} );
--
To view, visit https://gerrit.wikimedia.org/r/233214
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2784adaf2949a73256049921227dde0917ef9aef
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits