mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Markdown: Replace rendering library (#17686)
* Replace remarkable with marked * Add wrapper and options for marked
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import _ from 'lodash';
|
||||
import { PanelCtrl } from 'app/plugins/sdk';
|
||||
import Remarkable from 'remarkable';
|
||||
|
||||
import { sanitize, escapeHtml } from 'app/core/utils/text';
|
||||
import config from 'app/core/config';
|
||||
import { auto, ISCEService } from 'angular';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import { renderMarkdown } from '@grafana/data';
|
||||
|
||||
const defaultContent = `
|
||||
# Title
|
||||
@@ -19,7 +20,6 @@ export class TextPanelCtrl extends PanelCtrl {
|
||||
static templateUrl = `public/app/plugins/panel/text/module.html`;
|
||||
static scrollable = true;
|
||||
|
||||
remarkable: any;
|
||||
content: string;
|
||||
// Set and populate defaults
|
||||
panelDefaults = {
|
||||
@@ -82,12 +82,8 @@ export class TextPanelCtrl extends PanelCtrl {
|
||||
}
|
||||
|
||||
renderMarkdown(content: string) {
|
||||
if (!this.remarkable) {
|
||||
this.remarkable = new Remarkable();
|
||||
}
|
||||
|
||||
this.$scope.$applyAsync(() => {
|
||||
this.updateContent(this.remarkable.render(content));
|
||||
this.updateContent(renderMarkdown(content));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Libraries
|
||||
import React, { PureComponent } from 'react';
|
||||
import Remarkable from 'remarkable';
|
||||
import { debounce } from 'lodash';
|
||||
import { renderMarkdown } from '@grafana/data';
|
||||
|
||||
// Utils
|
||||
import { sanitize } from 'app/core/utils/text';
|
||||
@@ -17,8 +17,6 @@ interface State {
|
||||
}
|
||||
|
||||
export class TextPanel extends PureComponent<Props, State> {
|
||||
remarkable: Remarkable;
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
@@ -59,10 +57,7 @@ export class TextPanel extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
prepareMarkdown(content: string): string {
|
||||
if (!this.remarkable) {
|
||||
this.remarkable = new Remarkable();
|
||||
}
|
||||
return this.prepareHTML(this.remarkable.render(content));
|
||||
return this.prepareHTML(renderMarkdown(content));
|
||||
}
|
||||
|
||||
processContent(options: TextOptions): string {
|
||||
|
||||
Reference in New Issue
Block a user