Commit c100054d by Akeru

Allow [[..]] filter notation in all text panels

Based on #408 with fixed filter service method. Supports html, text and
markdown panels.
parent 2fbb87e1
<div ng-controller='text' ng-init="init()" style="min-height:{{panel.height || row.height}}" ng-dblclick="openEditor()">
<!--<p ng-style="panel.style" ng-bind-html-unsafe="panel.content | striphtml | newlines"></p>-->
<markdown ng-show="ready && panel.mode == 'markdown'">
{{panel.content}}
<markdown ng-show="ready && panel.mode == 'markdown'" ng-bind-html-unsafe="panel.content | applymarkdown | applytemplate">
</markdown>
<p ng-show="panel.mode == 'text'" ng-style='panel.style' ng-bind-html-unsafe="panel.content | striphtml | newlines">
<p ng-show="panel.mode == 'text'" ng-style='panel.style' ng-bind-html-unsafe="panel.content | striphtml | newlines | applytemplate">
</p>
<p ng-show="panel.mode == 'html'" ng-bind-html-unsafe="panel.content">
<p ng-show="panel.mode == 'html'" ng-bind-html-unsafe="panel.content | applytemplate">
</p>
</div>
......@@ -14,7 +14,8 @@ define([
'angular',
'app',
'underscore',
'require'
'require',
'services/filterSrv'
],
function (angular, app, _, require) {
'use strict';
......@@ -98,4 +99,25 @@ function (angular, app, _, require) {
.replace(/</g, '&lt;');
};
});
module.filter('applytemplate', function(filterSrv) {
return function (input) {
return filterSrv.applyTemplateToTarget(input);
};
});
module.filter('applymarkdown', function() {
return function (input) {
if(require.defined('./lib/showdown')) {
var Showdown = require('./lib/showdown');
var converter = new Showdown.converter();
var text = input.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;');
return converter.makeHtml(text);
} else {
return input;
}
};
});
});
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