You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2025/05/17 01:57:10 UTC

(superset) branch optimize_tooltip updated: dompurify

This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch optimize_tooltip
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/optimize_tooltip by this push:
     new a2c6ee7a6a dompurify
a2c6ee7a6a is described below

commit a2c6ee7a6aad2aeb06c4bbb22f342f192caa1968
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Fri May 16 18:53:49 2025 -0700

    dompurify
---
 .../src/components/AsyncAceEditor/Tooltip.tsx      | 36 ++++++++++++----------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/superset-frontend/src/components/AsyncAceEditor/Tooltip.tsx b/superset-frontend/src/components/AsyncAceEditor/Tooltip.tsx
index 0148a70140..ce5083520b 100644
--- a/superset-frontend/src/components/AsyncAceEditor/Tooltip.tsx
+++ b/superset-frontend/src/components/AsyncAceEditor/Tooltip.tsx
@@ -52,25 +52,27 @@ export const Tooltip: React.FC<Props> = ({
   </div>
 );
 
-const tooltipTemplate = Handlebars.compile(`
-  <div class="tooltip-detail">
-    <div class="tooltip-detail-head">
-      <div class="tooltip-detail-title">
-        {{#if icon}}<span class="tooltip-icon">{{icon}}</span>{{/if}}{{title}}
+export function getTooltipHTML({
+  title,
+  icon,
+  body,
+  meta,
+  footer,
+}: Props): string {
+  const html = `
+    <div class="tooltip-detail">
+      <div class="tooltip-detail-head">
+        <div class="tooltip-detail-title">
+          ${icon ? `<span class="tooltip-icon">${icon}</span>` : ''}${title}
+        </div>
+        ${meta ? `<span class="tooltip-detail-meta"><span class="ant-tag">${meta}</span></span>` : ''}
       </div>
-      {{#if meta}}
-        <span class="tooltip-detail-meta"><span class="ant-tag">{{meta}}</span></span>
-      {{/if}}
+      ${body ? `<div class="tooltip-detail-body">${body}</div>` : ''}
+      ${footer ? `<div class="tooltip-detail-footer">${footer}</div>` : ''}
     </div>
-    {{#if body}}
-      <div class="tooltip-detail-body">{{body}}</div>
-    {{/if}}
-    {{#if footer}}
-      <div class="tooltip-detail-footer">{{footer}}</div>
-    {{/if}}
-  </div>
-`);
+  `;
 
-export const getTooltipHTML = (props: Props): string => tooltipTemplate(props);
+  return DOMPurify.sanitize(html);
+}
 
 export default Tooltip;