Commit 73af4df9 by Torkel Ödegaard

feat(panels): upgraded text panel

parent 11e35f7b
...@@ -25,6 +25,12 @@ export class PanelCtrl { ...@@ -25,6 +25,12 @@ export class PanelCtrl {
this.icon = plugin.info.icon; this.icon = plugin.info.icon;
this.editorTabIndex = 0; this.editorTabIndex = 0;
this.publishAppEvent('panel-instantiated', {scope: $scope}); this.publishAppEvent('panel-instantiated', {scope: $scope});
$scope.$on("refresh", () => this.refresh());
}
refresh() {
return;
} }
publishAppEvent(evtName, evt) { publishAppEvent(evtName, evt) {
...@@ -43,6 +49,8 @@ export class PanelCtrl { ...@@ -43,6 +49,8 @@ export class PanelCtrl {
editPanel() { editPanel() {
if (!this.editorTabs) { if (!this.editorTabs) {
this.editorTabs = [];
this.editorTabs.push({title: 'General', directiveFn: generalOptionsTabEditorTab});
this.initEditorTabs(); this.initEditorTabs();
} }
...@@ -54,8 +62,11 @@ export class PanelCtrl { ...@@ -54,8 +62,11 @@ export class PanelCtrl {
} }
initEditorTabs() { initEditorTabs() {
this.editorTabs = []; return;
this.editorTabs.push({title: 'General', directiveFn: generalOptionsTabEditorTab}); }
addEditorTab(title, directiveFn) {
this.editorTabs.push({title: title, directiveFn: directiveFn});
} }
getMenu() { getMenu() {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
import _ from 'lodash'; import _ from 'lodash';
import {PanelDirective, PanelCtrl} from '../../../features/panel/panel'; import {PanelDirective, PanelCtrl} from '../../../features/panel/panel';
function optionsEditorTab() {
return {templateUrl: 'public/app/plugins/panel/text/editor.html'};
}
// Set and populate defaults // Set and populate defaults
var panelDefaults = { var panelDefaults = {
mode : "markdown", // 'html', 'markdown', 'text' mode : "markdown", // 'html', 'markdown', 'text'
...@@ -26,8 +22,9 @@ export class TextPanelCtrl extends PanelCtrl { ...@@ -26,8 +22,9 @@ export class TextPanelCtrl extends PanelCtrl {
} }
initEditorTabs() { initEditorTabs() {
super.initEditorTabs(); this.addEditorTab('Options', () => {
this.editorTabs.push({title: 'Options', directiveFn: optionsEditorTab}); return { templateUrl: 'public/app/plugins/panel/text/editor.html' };
});
} }
render() { render() {
...@@ -41,7 +38,7 @@ export class TextPanelCtrl extends PanelCtrl { ...@@ -41,7 +38,7 @@ export class TextPanelCtrl extends PanelCtrl {
// this.panelRenderingComplete(); // this.panelRenderingComplete();
} }
refreshData() { refresh() {
this.render(); this.render();
} }
...@@ -65,8 +62,10 @@ export class TextPanelCtrl extends PanelCtrl { ...@@ -65,8 +62,10 @@ export class TextPanelCtrl extends PanelCtrl {
} else { } else {
System.import('vendor/showdown').then(Showdown => { System.import('vendor/showdown').then(Showdown => {
this.converter = new Showdown.converter(); this.converter = new Showdown.converter();
this.$scope.$apply(() => {
this.updateContent(this.converter.makeHtml(text)); this.updateContent(this.converter.makeHtml(text));
}); });
});
} }
} }
...@@ -77,10 +76,6 @@ export class TextPanelCtrl extends PanelCtrl { ...@@ -77,10 +76,6 @@ export class TextPanelCtrl extends PanelCtrl {
console.log('Text panel error: ', e); console.log('Text panel error: ', e);
this.content = this.$sce.trustAsHtml(html); this.content = this.$sce.trustAsHtml(html);
} }
if (!this.$scope.$$phase) {
this.$scope.$digest();
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment