@datorama/core 22.12.6 → 22.12.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10088,6 +10088,9 @@ function tryParsePivotValue(str) {
10088
10088
  }
10089
10089
  return value;
10090
10090
  }
10091
+ function isHtmlAllowedForCol(gridOptions, colDef) {
10092
+ return (!gridOptions.disabledHTMLRenderingFields || !gridOptions.disabledHTMLRenderingFields.includes(getColField(colDef)));
10093
+ }
10091
10094
 
10092
10095
  let GridQuery = class GridQuery extends Query {
10093
10096
  constructor(store) {
@@ -10569,18 +10572,24 @@ function toolbarActionToContextAction(params) {
10569
10572
  const DATO_GRID_STORAGE_API = new InjectionToken('DATO_GRID_STORAGE_API');
10570
10573
 
10571
10574
  const defaultEditableColumnRenderer = params => params && params.value ? `<div class="value-wrapper ellipsis">${params.value}</div>` : null;
10572
- const editableCellRendererWithSearchHighlight = (params, searchTerm) => {
10575
+ const editableCellRendererWithSearchHighlight = (params, searchTerm, allowHTML) => {
10573
10576
  if (!params || !params.value) {
10574
10577
  return null;
10575
10578
  }
10576
- return `<div class="value-wrapper ellipsis">${searchHighlightCellRenderer(params, searchTerm)}</div>`;
10579
+ return `<div class="value-wrapper ellipsis">${searchHighlightCellRenderer(params, searchTerm, allowHTML)}</div>`;
10577
10580
  };
10578
- const searchHighlightCellRenderer = (params, searchTerm) => {
10581
+ const searchHighlightCellRenderer = (params, searchTerm, allowHTML = true) => {
10582
+ let cellValue = (params.valueFormatted || params.value || '').toString();
10583
+ if (!allowHTML) {
10584
+ cellValue = escape(cellValue);
10585
+ }
10586
+ else {
10587
+ cellValue = DOMPurify.sanitize(cellValue);
10588
+ }
10579
10589
  searchTerm = (searchTerm || '').trim();
10580
- const value = (params.valueFormatted || params.value || '').toString();
10581
10590
  return searchTerm
10582
- ? value.replace(new RegExp(searchTerm, 'gi'), (str) => `<span class="search-highlight">${str}</span>`)
10583
- : value;
10591
+ ? cellValue.replace(new RegExp(searchTerm, 'gi'), (str) => `<span class="search-highlight">${str}</span>`)
10592
+ : cellValue;
10584
10593
  };
10585
10594
  var GridMinWidths;
10586
10595
  (function (GridMinWidths) {
@@ -12100,7 +12109,7 @@ const defaultGridOptions = Object.assign({
12100
12109
  type: DatoGridColumnTypes.String,
12101
12110
  menuTabs: ['filterMenuTab'],
12102
12111
  headerComponentFramework: DatoGridColumnHeaderComponent
12103
- }, suppressCellSelection: true, suppressPropertyNamesCheck: true, rowHeight: 35, headerHeight: 30, rowSelection: GridRowSelectionType.MULTIPLE, rowDeselection: true, unSortIcon: true, animateRows: true, rememberGroupStateWhenNewData: true, groupMultiAutoColumn: true, groupDefaultExpanded: -1, usePivotGridStyle: false }, (isTestEnv() ? { suppressColumnVirtualisation: true, rowBuffer: 99999 } : {}));
12112
+ }, suppressCellSelection: true, suppressPropertyNamesCheck: true, rowHeight: 35, headerHeight: 30, rowSelection: GridRowSelectionType.MULTIPLE, rowDeselection: true, unSortIcon: true, animateRows: true, rememberGroupStateWhenNewData: true, groupMultiAutoColumn: true, groupDefaultExpanded: -1, usePivotGridStyle: false, disabledHTMLRenderingFields: [] }, (isTestEnv() ? { suppressColumnVirtualisation: true, rowBuffer: 99999 } : {}));
12104
12113
  const DEFAULT_GRID_SEARCH_DEBOUNCE_TIME = {
12105
12114
  CLIENT: 200,
12106
12115
  SERVER: 250
@@ -12744,11 +12753,12 @@ let GridService = class GridService {
12744
12753
  !this.hasCellRenderer(normalized, gridOptions) &&
12745
12754
  gridOptions.enableSearchHighlight) {
12746
12755
  normalized.cellRenderer = (params) => {
12756
+ const allowHTML = isHtmlAllowedForCol(gridOptions, params.colDef);
12747
12757
  const isEditable = (isFunction(normalized.editable) && normalized.editable(params)) ||
12748
12758
  (!isFunction(normalized.editable) && normalized.editable);
12749
12759
  return isEditable
12750
- ? editableCellRendererWithSearchHighlight(params, this.gridQuery.getSearchTerm())
12751
- : searchHighlightCellRenderer(params, this.gridQuery.getSearchTerm());
12760
+ ? editableCellRendererWithSearchHighlight(params, this.gridQuery.getSearchTerm(), allowHTML)
12761
+ : searchHighlightCellRenderer(params, this.gridQuery.getSearchTerm(), allowHTML);
12752
12762
  };
12753
12763
  }
12754
12764
  }
@@ -13958,7 +13968,7 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13958
13968
  rowActions: this.rowActions
13959
13969
  };
13960
13970
  let normalized = this.gridService.normalizeOptions(params);
13961
- const defaults = Object.assign(Object.assign(Object.assign({}, defaultGridOptions), (this.gridOptions.treeData ? defaultTreeOptions : {})), { icons: this.getGridIcons() });
13971
+ const defaults = Object.assign(Object.assign(Object.assign({}, defaultGridOptions), (this.gridOptions.treeData ? defaultTreeOptions : {})), { icons: this.getGridIcons(), disabledHTMLRenderingFields: normalized.disabledHTMLRenderingFields || defaultGridOptions.disabledHTMLRenderingFields });
13962
13972
  return deepmerge(defaults, normalized);
13963
13973
  }
13964
13974
  setGridRows(data) {
@@ -14146,17 +14156,18 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
14146
14156
  const textOverflow = cell.offsetWidth < cell.scrollWidth;
14147
14157
  if (textOverflow) {
14148
14158
  clearTimeout(this.cellMouseOutTimer);
14149
- const params = { cell, value: cell.innerText };
14159
+ const allowHTML = isHtmlAllowedForCol(this.gridOptions, event.colDef);
14160
+ const params = { cell, value: cell.innerText, allowHTML };
14150
14161
  isNil(this.tooltip) ? this.createAndShowTooltip(params) : this.updateTooltip(params);
14151
14162
  }
14152
14163
  }
14153
- createAndShowTooltip({ cell, value }) {
14164
+ createAndShowTooltip({ cell, value, allowHTML }) {
14154
14165
  this.tooltip = new Tooltip(cell, {
14155
14166
  placement: 'top',
14156
14167
  container: document.body,
14157
14168
  trigger: 'manual',
14158
- title: DOMPurify.sanitize(value),
14159
- html: true,
14169
+ title: allowHTML ? DOMPurify.sanitize(value) : value,
14170
+ html: allowHTML,
14160
14171
  popperOptions: {
14161
14172
  modifiers: {
14162
14173
  preventOverflow: { enabled: false }
@@ -22917,7 +22928,7 @@ function fixNgLeaks() {
22917
22928
  };
22918
22929
  }
22919
22930
 
22920
- window.coreVersion = '22.12.6';
22931
+ window.coreVersion = '22.12.7';
22921
22932
 
22922
22933
  /**
22923
22934
  * @license