diff --git a/src/ui/public/doc_table/components/table_row.js b/src/ui/public/doc_table/components/table_row.js index 24dc6d0120fa0..59718fe0f4eb9 100644 --- a/src/ui/public/doc_table/components/table_row.js +++ b/src/ui/public/doc_table/components/table_row.js @@ -117,6 +117,11 @@ module.directive('kbnTableRow', function ($compile) { }); const $target = reuse ? $(reuse).detach() : $(html); + + if ($target.hasClass('discover-table-sourcefield')) { + truncateSourceSummary($target); + } + $target.data('discover:html', html); const $before = $cells.eq(i - 1); if ($before.size()) { @@ -158,6 +163,22 @@ module.directive('kbnTableRow', function ($compile) { return text; } + + function truncateSourceSummary(sourceElement) { + const sourceList = sourceElement.find('dl'); + const listItems = sourceList.children(); + const listPairs = _.chunk(listItems, 2); + sourceList.empty(); + + let length = 0; + _.forEach(listPairs, (listPair) => { + length += (listPair[0].textContent.length + listPair[1].textContent.length); + if (length < 500) { + sourceList.append(listPair); + sourceList.append(' '); + } + }); + } } }; });