Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ exports.postAceInit = function(hook, context) {
}

exports.aceAttribsToClasses = function(hook, context) {
if(context.key == 'url'){
var url = context.value;
return ['url-' + url ];
if (context.key === 'url'){
if (/^ ?url-/.test(context.value)) {
return [context.value];
} else {
return ['url-' + context.value];
}
}
}

Expand Down Expand Up @@ -83,6 +86,6 @@ function doInsertLink(url) {
exports.collectContentPre = function(hook,context) {
var url = /(?:^| )url-(\S*)/.exec(context.cls);
if(url) {
context.cc.doAttrib(context.state,"url::" + url);
context.cc.doAttrib(context.state,"url::" + url[0]);
}
}
28 changes: 28 additions & 0 deletions static/tests/frontend/specs/embeddedlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,32 @@ describe('ep_embedded_hyperlinks2', function () {
secondSpan.classList.contains('b');
});
});

it('has correct links after copy and paste', async function() {
// FIXME use clipboard API
const html = '<span class="url-beta.etherpad.com/"><a href="http://beta.etherpad.com/">1link, </a></span>\
<span class="b url-beta.etherpad.com/"><a href="http://beta.etherpad.com/"><b>2bold</b></a></span>\
<span class="url-beta.etherpad.com/"><a href="http://beta.etherpad.com/">, 3link</a></span>'
helper.linesDiv()[0].html(html);
await helper.waitForPromise(() => helper.commits.length === 1);

await helper.waitForPromise(() => {
const lineText = helper.textLines()[0];
const firstSpan = helper.linesDiv()[0][0].children[0];
const secondSpan = helper.linesDiv()[0][0].children[1];
const thirdSpan = helper.linesDiv()[0][0].children[2];

return lineText === '1link, 2bold, 3link' &&
firstSpan.children[0].getAttribute('href') === 'http://beta.etherpad.com/' &&
secondSpan.children[0].getAttribute('href') === 'http://beta.etherpad.com/' &&
thirdSpan.children[0].getAttribute('href') === 'http://beta.etherpad.com/' &&
firstSpan.classList.contains('url-beta.etherpad.com/') &&
!firstSpan.classList.contains('url-') &&
secondSpan.classList.contains('url-beta.etherpad.com/') &&
!secondSpan.classList.contains('url-') &&
thirdSpan.classList.contains('url-beta.etherpad.com/') &&
!thirdSpan.classList.contains('url-') &&
secondSpan.classList.contains('b');
});
});
});