diff --git a/public/app/plugins/panel/text/editor.html b/public/app/plugins/panel/text/editor.html
index b3b8afbbec0..ea281d61a30 100644
--- a/public/app/plugins/panel/text/editor.html
+++ b/public/app/plugins/panel/text/editor.html
@@ -1,17 +1,17 @@
-
+
-
-
+
+
-
diff --git a/public/app/plugins/panel/text/module.html b/public/app/plugins/panel/text/module.html
index 5a933d5acc3..12a02597384 100644
--- a/public/app/plugins/panel/text/module.html
+++ b/public/app/plugins/panel/text/module.html
@@ -1,3 +1 @@
-
-
-
+
diff --git a/public/app/plugins/panel/text/module.js b/public/app/plugins/panel/text/module.js
deleted file mode 100644
index e0e21c8e1ae..00000000000
--- a/public/app/plugins/panel/text/module.js
+++ /dev/null
@@ -1,113 +0,0 @@
-define([
- 'angular',
- 'app/app',
- 'lodash',
- 'require',
- 'app/features/panel/panel_meta',
-],
-function (angular, app, _, require, PanelMeta) {
- 'use strict';
-
- var converter;
-
- /** @ngInject */
- function TextPanelCtrl($scope, templateSrv, $sce, panelSrv) {
-
- $scope.panelMeta = new PanelMeta({
- panelName: 'Text',
- editIcon: "fa fa-text-width",
- fullscreen: true,
- });
-
- $scope.panelMeta.addEditorTab('Edit text', 'app/plugins/panel/text/editor.html');
-
- // Set and populate defaults
- var _d = {
- title : 'default title',
- mode : "markdown", // 'html', 'markdown', 'text'
- content : "",
- style: {},
- };
-
- _.defaults($scope.panel, _d);
-
- $scope.init = function() {
- panelSrv.init($scope);
- $scope.ready = false;
- $scope.render();
- };
-
- $scope.refreshData = function() {
- $scope.panelMeta.loading = false;
- $scope.render();
- };
-
- $scope.render = function() {
- if ($scope.panel.mode === 'markdown') {
- $scope.renderMarkdown($scope.panel.content);
- }
- else if ($scope.panel.mode === 'html') {
- $scope.updateContent($scope.panel.content);
- }
- else if ($scope.panel.mode === 'text') {
- $scope.renderText($scope.panel.content);
- }
- $scope.panelRenderingComplete();
- };
-
- $scope.renderText = function(content) {
- content = content
- .replace(/&/g, '&')
- .replace(/>/g, '>')
- .replace(/');
-
- $scope.updateContent(content);
- };
-
- $scope.renderMarkdown = function(content) {
- var text = content
- .replace(/&/g, '&')
- .replace(/>/g, '>')
- .replace(/
+
+import _ from 'lodash';
+import {PanelDirective, PanelCtrl} from '../../../features/panel/panel';
+
+function optionsEditorTab() {
+ return {templateUrl: 'public/app/plugins/panel/text/editor.html'};
+}
+
+ // Set and populate defaults
+var panelDefaults = {
+ mode : "markdown", // 'html', 'markdown', 'text'
+ content : "# title",
+};
+
+export class TextPanelCtrl extends PanelCtrl {
+ converter: any;
+ content: string;
+
+ /** @ngInject */
+ constructor($scope, private templateSrv, private $sce) {
+ super($scope);
+
+ _.defaults(this.panel, panelDefaults);
+ this.render();
+ }
+
+ initEditorTabs() {
+ super.initEditorTabs();
+ this.editorTabs.push({title: 'Options', directiveFn: optionsEditorTab});
+ }
+
+ render() {
+ if (this.panel.mode === 'markdown') {
+ this.renderMarkdown(this.panel.content);
+ } else if (this.panel.mode === 'html') {
+ this.updateContent(this.panel.content);
+ } else if (this.panel.mode === 'text') {
+ this.renderText(this.panel.content);
+ }
+ // this.panelRenderingComplete();
+ }
+
+ refreshData() {
+ this.render();
+ }
+
+ renderText(content) {
+ content = content
+ .replace(/&/g, '&')
+ .replace(/>/g, '>')
+ .replace(/');
+ this.updateContent(content);
+ }
+
+ renderMarkdown(content) {
+ var text = content
+ .replace(/&/g, '&')
+ .replace(/>/g, '>')
+ .replace(/ {
+ this.converter = new Showdown.converter();
+ this.updateContent(this.converter.makeHtml(text));
+ });
+ }
+ }
+
+ updateContent(html) {
+ try {
+ this.content = this.$sce.trustAsHtml(this.templateSrv.replace(html, this.panel.scopedVars));
+ } catch (e) {
+ console.log('Text panel error: ', e);
+ this.content = this.$sce.trustAsHtml(html);
+ }
+
+ if (!this.$scope.$$phase) {
+ this.$scope.$digest();
+ }
+ }
+}
+
+class TextPanel extends PanelDirective {
+ templateUrl = `app/plugins/panel/text/module.html`;
+ controller = TextPanelCtrl;
+}
+
+export {TextPanel as Panel}