From 534feb1e5ea50cc8616afd069dfab0d7fd8cca28 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Fri, 17 Jul 2020 18:00:58 +0200 Subject: [PATCH] Bring back scripts evaluation in TextPanel (#26413) (cherry picked from commit 718b78c4ceb7df61e2f779ec6a6821df04245be2) --- package.json | 1 + public/app/plugins/panel/text/TextPanel.tsx | 5 +++-- public/app/types/dangerously-set-html-content.d.ts | 11 +++++++++++ yarn.lock | 5 +++++ 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 public/app/types/dangerously-set-html-content.d.ts diff --git a/package.json b/package.json index 1474c3b283d..b5bc9d20d76 100644 --- a/package.json +++ b/package.json @@ -224,6 +224,7 @@ "core-js": "3.6.4", "d3": "5.15.0", "d3-scale-chromatic": "1.5.0", + "dangerously-set-html-content": "1.0.6", "emotion": "10.0.27", "eventemitter3": "4.0.0", "fast-text-encoding": "^1.0.0", diff --git a/public/app/plugins/panel/text/TextPanel.tsx b/public/app/plugins/panel/text/TextPanel.tsx index 043f5dea9a3..1e694567745 100644 --- a/public/app/plugins/panel/text/TextPanel.tsx +++ b/public/app/plugins/panel/text/TextPanel.tsx @@ -8,8 +8,10 @@ import config from 'app/core/config'; import { TextOptions } from './types'; import { stylesFactory } from '@grafana/ui'; import { css, cx } from 'emotion'; +import DangerouslySetHtmlContent from 'dangerously-set-html-content'; interface Props extends PanelProps {} + interface State { html: string; } @@ -78,8 +80,7 @@ export class TextPanel extends PureComponent { render() { const { html } = this.state; const styles = getStyles(); - - return
; + return ; } } diff --git a/public/app/types/dangerously-set-html-content.d.ts b/public/app/types/dangerously-set-html-content.d.ts new file mode 100644 index 00000000000..5c67b56d12a --- /dev/null +++ b/public/app/types/dangerously-set-html-content.d.ts @@ -0,0 +1,11 @@ +declare module 'dangerously-set-html-content' { + import React from 'react'; + + interface DangerouslySetHtmlContentProps extends React.HTMLAttributes { + html: string; + } + + class DangerouslySetHtmlContent extends React.Component {} + + export = DangerouslySetHtmlContent; +} diff --git a/yarn.lock b/yarn.lock index c1371e12d79..49e811d7f10 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10909,6 +10909,11 @@ d@1, d@^1.0.1: es5-ext "^0.10.50" type "^1.0.1" +dangerously-set-html-content@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/dangerously-set-html-content/-/dangerously-set-html-content-1.0.6.tgz#3f4017215f821ba3ff46fa9d745036b708d4378c" + integrity sha512-rZ9cjrVHpFLCzm/rF2ZTGIg24DfQ+E3DBtQ0+OacIVndNewl7+SZvn4n403il4xirZQwpwUJudn/USK8qm4fuQ== + dargs@^4.0.1: version "4.1.0" resolved "https://registry.yarnpkg.com/dargs/-/dargs-4.1.0.tgz#03a9dbb4b5c2f139bf14ae53f0b8a2a6a86f4e17"