module.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. angular.module('kibana.text', [])
  2. .controller('text', function($scope, $rootScope) {
  3. // Set and populate defaults
  4. var _d = {
  5. group : "default",
  6. content : "",
  7. style: {},
  8. }
  9. _.defaults($scope.panel,_d);
  10. $scope.init = function() {
  11. }
  12. }).directive('markdown', function() {
  13. return {
  14. restrict: 'E',
  15. link: function(scope, element, attrs) {
  16. scope.$on('render', function() {
  17. render_panel();
  18. })
  19. function render_panel() {
  20. var scripts = $LAB.script("panels/text/lib/showdown.js")
  21. scripts.wait(function(){
  22. var converter = new Showdown.converter();
  23. var htmlText = converter.makeHtml(scope.panel.content);
  24. element.html(htmlText);
  25. });
  26. }
  27. render_panel();
  28. }
  29. }
  30. })
  31. .filter('newlines', function(){
  32. return function (input) {
  33. return input.replace(/\n/g, '<br/>');
  34. }
  35. })
  36. .filter('striphtml', function () {
  37. return function(text) {
  38. return text
  39. .replace(/&/g, '&amp;')
  40. .replace(/>/g, '&gt;')
  41. .replace(/</g, '&lt;');
  42. }
  43. });