diff --git a/main/tests/cypress/cypress/integration/project/grid/misc/proper-display.js b/main/tests/cypress/cypress/integration/project/grid/misc/proper-display.js new file mode 100644 index 000000000..c191f6444 --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/misc/proper-display.js @@ -0,0 +1,25 @@ +describe(__filename, function () { + it('proper tag assignment to each text snippet', function () { + const fixture = [ + ['tests'], + ['2021-01-31https://www.google.com'], + [ + // eslint-disable-next-line max-len + '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', + ], + ['github 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(1, 'tests').children('div').children('span'); + cy.getCell(2, 'tests') + .children('div') + .children('a') + .should('have.attr', 'href'); + }); +}); diff --git a/main/webapp/modules/core/scripts/views/data-table/cell-ui.js b/main/webapp/modules/core/scripts/views/data-table/cell-ui.js index d4564644b..1cf7b82e4 100644 --- a/main/webapp/modules/core/scripts/views/data-table/cell-ui.js +++ b/main/webapp/modules/core/scripts/views/data-table/cell-ui.js @@ -96,17 +96,36 @@ DataTableCellUI.prototype._render = function() { nonstringSpan.className = 'data-table-value-nonstring'; nonstringSpan.textContent = cell.v; divContent.appendChild(nonstringSpan); - } else if (URL.looksLikeUrl(cell.v)) { - var url = document.createElement('a'); - url.textContent = cell.v; - url.setAttribute('href', cell.v); - url.setAttribute('target', '_blank'); - divContent.appendChild(url); } else { - var span = document.createElement('span'); - span.textContent = cell.v; - divContent.appendChild(span); - } + var arr = cell.v.split(" "); + var spanArr = []; + for (var i=0; i