Revert "Merge pull request #3588 from singhakshita/hyperlink-issue-tests"

This reverts commit 79aa260442, reversing
changes made to d6edf5ddb0.

See discussion at:
https://github.com/OpenRefine/OpenRefine/pull/3588
This commit is contained in:
Antonin Delpeuch 2021-02-07 09:21:26 +01:00
parent 79aa260442
commit a0bea8f8c7
13 changed files with 794 additions and 2447 deletions

View File

@ -1,23 +0,0 @@
describe(__filename, function () {
it('verify <a>href tags created for URLs within cell text', function () {
const fixture = [
['tests'],
['2021-01-31https://www.google.com'],
[
'https://www.wikidata.org/wiki/Property:P670 https://www.wikidata.org/wiki/Property:P669 are now mapped to https://schema.org/streetAddress via https://www.wikidata.org/wiki/Property:P2235',
],
['vhjhjjj https://github.com/OpenRefine/OpenRefine/issues/2519'],
]
cy.loadAndVisitProject(fixture)
cy.getCell(0, 'tests').contains('2021-01-31https://www.google.com')
cy.getCell(1, 'tests')
.children('div')
.children('a')
.should('have.attr', 'href')
cy.getCell(2, 'tests')
.children('div')
.children('a')
.should('have.attr', 'href')
})
})

File diff suppressed because it is too large Load Diff

View File

@ -96,40 +96,17 @@ DataTableCellUI.prototype._render = function() {
nonstringSpan.className = 'data-table-value-nonstring';
nonstringSpan.textContent = cell.v;
divContent.appendChild(nonstringSpan);
}
else{
var arr = cell.v.split(" ");
var spanArr =[];
for( var i=0;i<arr.length;i++){
if(URL.looksLikeUrl(arr[i])){
if(spanArr.length !=0 ){
var span = document.createElement('span');
span.textContent = spanArr.join(" ");
divContent.appendChild(span).appendChild(document.createTextNode('\u00A0'));
spanArr = [];
}
} else if (URL.looksLikeUrl(cell.v)) {
var url = document.createElement('a');
url.textContent = arr[i];
url.setAttribute('href', arr[i]);
url.textContent = cell.v;
url.setAttribute('href', cell.v);
url.setAttribute('target', '_blank');
divContent.appendChild(url);
if( i== arr.length-1){
divContent.appendChild(url)
}
else{
divContent.appendChild(url).appendChild(document.createTextNode('\u00A0'));
}
}
else{
spanArr.push(arr[i]);
}
}
if(spanArr.length !=0){
} else {
var span = document.createElement('span');
span.textContent = spanArr.join(" ");
span.textContent = cell.v;
divContent.appendChild(span);
}
}
} else {
var divContentRecon = $(divContent);
var r = cell.r;