Markdown: Replace rendering library (#17686)

* Replace remarkable with marked

* Add wrapper and options for marked
This commit is contained in:
Tobias Skarhed
2019-06-26 13:15:45 +02:00
committed by GitHub
parent 6fb36e705f
commit 8541214c9e
11 changed files with 54 additions and 61 deletions

View File

@@ -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));
});
}

View File

@@ -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 {