@grafana/data#renderMarkdown TypeScript Examples

The following examples show how to use @grafana/data#renderMarkdown. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginHelp.tsx    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
loadHelp = () => {
    const { plugin, type } = this.props;
    this.setState({ isLoading: true });

    getBackendSrv()
      .get(`/api/plugins/${plugin.id}/markdown/${type}`)
      .then((response: string) => {
        const helpHtml = renderMarkdown(response);

        if (response === '' && type === 'help') {
          this.setState({
            isError: false,
            isLoading: false,
            help: this.constructPlaceholderInfo(),
          });
        } else {
          this.setState({
            isError: false,
            isLoading: false,
            help: helpHtml,
          });
        }
      })
      .catch(() => {
        this.setState({
          isError: true,
          isLoading: false,
        });
      });
  };
Example #2
Source File: PanelHeaderCorner.tsx    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
getInfoContent = (): JSX.Element => {
    const { panel } = this.props;
    const markdown = panel.description || '';
    const interpolatedMarkdown = templateSrv.replace(markdown, panel.scopedVars);
    const markedInterpolatedMarkdown = renderMarkdown(interpolatedMarkdown);
    const links = this.props.links && this.props.links.getLinks(panel);

    return (
      <div className="panel-info-content markdown-html">
        <div dangerouslySetInnerHTML={{ __html: markedInterpolatedMarkdown }} />

        {links && links.length > 0 && (
          <ul className="panel-info-corner-links">
            {links.map((link, idx) => {
              return (
                <li key={idx}>
                  <a className="panel-info-corner-links__item" href={link.href} target={link.target}>
                    {link.title}
                  </a>
                </li>
              );
            })}
          </ul>
        )}
      </div>
    );
  };
Example #3
Source File: UsersListPage.tsx    From grafana-chinese with Apache License 2.0 6 votes vote down vote up
constructor(props: Props) {
    super(props);

    if (this.props.externalUserMngInfo) {
      this.externalUserMngInfoHtml = renderMarkdown(this.props.externalUserMngInfo);
    }

    this.state = {
      showInvites: false,
    };
  }
Example #4
Source File: module.ts    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
onRender() {
    if (this.panel.mode === 'markdown') {
      this.renderMarkdown(this.panel.content);
    } else if (this.panel.mode === 'html') {
      this.updateContent(this.panel.content);
    }
    this.renderingCompleted();
  }
Example #5
Source File: module.ts    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
renderMarkdown(content: string) {
    this.$scope.$applyAsync(() => {
      this.updateContent(renderMarkdown(content));
    });
  }
Example #6
Source File: TextPanel.tsx    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
prepareMarkdown(content: string): string {
    return this.prepareHTML(renderMarkdown(content));
  }