26 lines
777 B
JavaScript
26 lines
777 B
JavaScript
|
/**
|
||
|
* An element which displays its content processed as markdown.
|
||
|
*/
|
||
|
angular.module('quay').directive('markdownView', function () {
|
||
|
var directiveDefinitionObject = {
|
||
|
priority: 0,
|
||
|
templateUrl: '/static/directives/markdown-view.html',
|
||
|
replace: false,
|
||
|
transclude: false,
|
||
|
restrict: 'C',
|
||
|
scope: {
|
||
|
'content': '=content',
|
||
|
'firstLineOnly': '=firstLineOnly'
|
||
|
},
|
||
|
controller: function($scope, $element, $sce, UtilService) {
|
||
|
$scope.getMarkedDown = function(content, firstLineOnly) {
|
||
|
if (firstLineOnly) {
|
||
|
return $sce.trustAsHtml(UtilService.getFirstMarkdownLineAsText(content));
|
||
|
}
|
||
|
return $sce.trustAsHtml(UtilService.getMarkedDown(content));
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
return directiveDefinitionObject;
|
||
|
});
|