diff --git a/static/js/directives/ui/markdown/markdown-view.component.css b/static/js/directives/ui/markdown/markdown-view.component.css index 9cb3f601f..bfbc4957d 100644 --- a/static/js/directives/ui/markdown/markdown-view.component.css +++ b/static/js/directives/ui/markdown/markdown-view.component.css @@ -1,5 +1,6 @@ .markdown-view-content { word-wrap: break-word; + overflow: hidden; } .markdown-view-content p { diff --git a/static/js/services/util-service.js b/static/js/services/util-service.js index 760d7a372..131bb0d34 100644 --- a/static/js/services/util-service.js +++ b/static/js/services/util-service.js @@ -1,110 +1,111 @@ /** * Service which exposes various utility methods. */ -angular.module('quay').factory('UtilService', ['$sanitize', function($sanitize) { - var utilService = {}; +angular.module('quay').factory('UtilService', ['$sanitize', 'markdownConverterFactory', + function($sanitize, markdownConverterFactory) { + var utilService = {}; - var adBlockEnabled = null; + var adBlockEnabled = null; - utilService.isAdBlockEnabled = function(callback) { - if (adBlockEnabled !== null) { - callback(adBlockEnabled); - return; - } - - if(typeof blockAdBlock === 'undefined') { - callback(true); - return; - } - - var bab = new BlockAdBlock({ - checkOnLoad: false, - resetOnEnd: true - }); - - bab.onDetected(function() { adBlockEnabled = true; callback(true); }); - bab.onNotDetected(function() { adBlockEnabled = false; callback(false); }); - bab.check(); - }; - - utilService.isEmailAddress = function(val) { - var emailRegex = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; - return emailRegex.test(val); - }; - - utilService.getMarkedDown = function(string) { - return html = Markdown.getSanitizingConverter().makeHtml(string || ''); - }; - - utilService.getFirstMarkdownLineAsText = function(commentString, placeholderNeeded) { - if (!commentString) { - if (placeholderNeeded) { - return '

placeholder

'; + utilService.isAdBlockEnabled = function(callback) { + if (adBlockEnabled !== null) { + callback(adBlockEnabled); + return; } - return ''; - } - var lines = commentString.split('\n'); - var MARKDOWN_CHARS = { - '#': true, - '-': true, - '>': true, - '`': true + if(typeof blockAdBlock === 'undefined') { + callback(true); + return; + } + + var bab = new BlockAdBlock({ + checkOnLoad: false, + resetOnEnd: true + }); + + bab.onDetected(function() { adBlockEnabled = true; callback(true); }); + bab.onNotDetected(function() { adBlockEnabled = false; callback(false); }); + bab.check(); }; - for (var i = 0; i < lines.length; ++i) { - // Skip code lines. - if (lines[i].indexOf(' ') == 0) { - continue; + utilService.isEmailAddress = function(val) { + var emailRegex = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; + return emailRegex.test(val); + }; + + utilService.getMarkedDown = function(string) { + return markdownConverterFactory().makeHtml(string || ''); + }; + + utilService.getFirstMarkdownLineAsText = function(commentString, placeholderNeeded) { + if (!commentString) { + if (placeholderNeeded) { + return '

placeholder

'; + } + return ''; } - // Skip empty lines. - if ($.trim(lines[i]).length == 0) { - continue; + var lines = commentString.split('\n'); + var MARKDOWN_CHARS = { + '#': true, + '-': true, + '>': true, + '`': true + }; + + for (var i = 0; i < lines.length; ++i) { + // Skip code lines. + if (lines[i].indexOf(' ') == 0) { + continue; + } + + // Skip empty lines. + if ($.trim(lines[i]).length == 0) { + continue; + } + + // Skip control lines. + if (MARKDOWN_CHARS[$.trim(lines[i])[0]]) { + continue; + } + + return utilService.getMarkedDown(lines[i]); } - // Skip control lines. - if (MARKDOWN_CHARS[$.trim(lines[i])[0]]) { - continue; + return ''; + }; + + utilService.escapeHtmlString = function(text) { + var textStr = (text || '').toString(); + var adjusted = textStr.replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); + + return adjusted; + }; + + utilService.stringToHTML = function(text) { + text = utilService.escapeHtmlString(text); + text = text.replace(/\n/g, '
'); + return text; + }; + + utilService.getRestUrl = function(args) { + var url = ''; + for (var i = 0; i < arguments.length; ++i) { + if (i > 0) { + url += '/'; + } + url += encodeURI(arguments[i]) } + return url; + }; - return utilService.getMarkedDown(lines[i]); - } + utilService.textToSafeHtml = function(text) { + return $sanitize(utilService.escapeHtmlString(text)); + }; - return ''; - }; - - utilService.escapeHtmlString = function(text) { - var textStr = (text || '').toString(); - var adjusted = textStr.replace(/&/g, "&") - .replace(//g, ">") - .replace(/"/g, """) - .replace(/'/g, "'"); - - return adjusted; - }; - - utilService.stringToHTML = function(text) { - text = utilService.escapeHtmlString(text); - text = text.replace(/\n/g, '
'); - return text; - }; - - utilService.getRestUrl = function(args) { - var url = ''; - for (var i = 0; i < arguments.length; ++i) { - if (i > 0) { - url += '/'; - } - url += encodeURI(arguments[i]) - } - return url; - }; - - utilService.textToSafeHtml = function(text) { - return $sanitize(utilService.escapeHtmlString(text)); - }; - - return utilService; + return utilService; }]);