Skip to content

Commit d6329b1

Browse files
committed
fix copy and paste
1 parent 1b43e72 commit d6329b1

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

static/js/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ exports.postAceInit = function(hook, context) {
3535
}
3636

3737
exports.aceAttribsToClasses = function(hook, context) {
38-
if(context.key == 'url'){
39-
var url = context.value;
40-
return ['url-' + url ];
38+
if (context.key === 'url'){
39+
if (/^ ?url-/.test(context.value)) {
40+
return [context.value];
41+
} else {
42+
return ['url-' + context.value];
43+
}
4144
}
4245
}
4346

@@ -83,6 +86,6 @@ function doInsertLink(url) {
8386
exports.collectContentPre = function(hook,context) {
8487
var url = /(?:^| )url-(\S*)/.exec(context.cls);
8588
if(url) {
86-
context.cc.doAttrib(context.state,"url::" + url);
89+
context.cc.doAttrib(context.state,"url::" + url[0]);
8790
}
8891
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
describe('ep_embedded_hyperlinks2', function () {
4+
beforeEach(async function () {
5+
await helper.aNewPad();
6+
this.timeout(60000);
7+
});
8+
9+
it('has correct links after copy and paste', async function() {
10+
// FIXME use clipboard API
11+
const html = '<span class="url-beta.etherpad.com/"><a href="http://beta.etherpad.com/">1link, </a></span>\
12+
<span class="b url-beta.etherpad.com/"><a href="http://beta.etherpad.com/"><b>2bold</b></a></span>\
13+
<span class="url-beta.etherpad.com/"><a href="http://beta.etherpad.com/">, 3link</a></span>'
14+
helper.linesDiv()[0].html(html);
15+
await helper.waitForPromise(() => helper.commits.length === 1);
16+
17+
await helper.waitForPromise(() => {
18+
const lineText = helper.textLines()[0];
19+
const firstSpan = helper.linesDiv()[0][0].children[0];
20+
const secondSpan = helper.linesDiv()[0][0].children[1];
21+
const thirdSpan = helper.linesDiv()[0][0].children[2];
22+
23+
return lineText === '1link, 2bold, 3link' &&
24+
firstSpan.children[0].getAttribute('href') === 'http://beta.etherpad.com/' &&
25+
secondSpan.children[0].getAttribute('href') === 'http://beta.etherpad.com/' &&
26+
thirdSpan.children[0].getAttribute('href') === 'http://beta.etherpad.com/' &&
27+
firstSpan.classList.contains('url-beta.etherpad.com/') &&
28+
!firstSpan.classList.contains('url-') &&
29+
secondSpan.classList.contains('url-beta.etherpad.com/') &&
30+
!secondSpan.classList.contains('url-') &&
31+
thirdSpan.classList.contains('url-beta.etherpad.com/') &&
32+
!thirdSpan.classList.contains('url-') &&
33+
secondSpan.classList.contains('b');
34+
});
35+
});
36+
37+
});

0 commit comments

Comments
 (0)