Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/233390
Change subject: Put spaces between multiple links when pasting
......................................................................
Put spaces between multiple links when pasting
Bug: T109996
Change-Id: Ib925bf02c5653b809e91565e1b8d4acf73963a93
---
M src/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.js
M tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
2 files changed, 21 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/90/233390/1
diff --git a/src/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.js
b/src/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.js
index 0ed5b38..7017bba 100644
--- a/src/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.js
+++ b/src/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.js
@@ -78,11 +78,9 @@
* @inheritdoc
*/
ve.ui.UrlStringTransferHandler.prototype.process = function () {
- var links,
- html,
- doc,
- result,
+ var links, html, doc, result,
surface = this.surface,
+ store = surface.getModel().getDocument().getStore(),
linkAction = ve.ui.actionFactory.create( 'link', surface ),
data = this.item.getAsString();
@@ -130,7 +128,6 @@
result = [];
links.forEach( function ( link ) {
var i,
- store = surface.getModel().getDocument().getStore(),
annotation = linkAction.getLinkAnnotation( link.href ),
annotationSet = new ve.dm.AnnotationSet( store,
store.indexes( [
annotation
@@ -138,6 +135,11 @@
title = link.title || annotation.getDisplayTitle(),
content = title.split( '' );
+ // Put a space between multiple links
+ if ( result.length ) {
+ result.push( ' ' );
+ }
+
ve.dm.Document.static.addAnnotationsToData( content,
annotationSet );
for ( i = 0; i < content.length; i++ ) {
result.push( content[ i ] );
diff --git
a/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
b/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
index 80aeafc..f49ae97 100644
--- a/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
+++ b/tests/ui/datatransferhandlers/ve.ui.UrlStringTransferHandler.test.js
@@ -112,18 +112,23 @@
},
{
msg: 'Mozilla URI list',
- pasteString: 'http://example.com\n[[Foo]]',
+ pasteString:
'http://example.com\n[[Foo]]\nhttp://example.org\nBar',
pasteType: 'text/x-moz-url',
expectedData: function ( makeAnnotation ) {
- var a = makeAnnotation(
'http://example.com' );
+ var a1 = makeAnnotation(
'http://example.com' ),
+ a2 = makeAnnotation(
'http://example.org' );
return [
- [ '[', [ a ] ],
- [ '[', [ a ] ],
- [ 'F', [ a ] ],
- [ 'o', [ a ] ],
- [ 'o', [ a ] ],
- [ ']', [ a ] ],
- [ ']', [ a ] ]
+ [ '[', [ a1 ] ],
+ [ '[', [ a1 ] ],
+ [ 'F', [ a1 ] ],
+ [ 'o', [ a1 ] ],
+ [ 'o', [ a1 ] ],
+ [ ']', [ a1 ] ],
+ [ ']', [ a1 ] ],
+ ' ',
+ [ 'B', [ a2 ] ],
+ [ 'a', [ a2 ] ],
+ [ 'r', [ a2 ] ]
];
}
}
--
To view, visit https://gerrit.wikimedia.org/r/233390
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib925bf02c5653b809e91565e1b8d4acf73963a93
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