0
0
Fork 0

Fix #204, fix #515 - URL truncating is now a style so copypasting is not

affected, replaced onClick handler with onMouseUp/Down to detect text
selection not trigger onClick handler then
This commit is contained in:
Eugen Rochko 2017-01-24 17:05:44 +01:00
parent b06a375ee4
commit 80cefd5b3c
4 changed files with 42 additions and 5 deletions

View file

@ -65,8 +65,11 @@ class Formatter
end
def link_html(url)
link_text = truncate(url.gsub(/\Ahttps?:\/\/(www\.)?/, ''), length: 30)
"<a rel=\"nofollow noopener\" target=\"_blank\" href=\"#{url}\">#{link_text}</a>"
prefix = url.match(/\Ahttps?:\/\/(www\.)?/).to_s
text = url[prefix.length, 30]
suffix = url[prefix.length + 30..-1]
"<a rel=\"nofollow noopener\" target=\"_blank\" href=\"#{url}\"><span class=\"invisible\">#{prefix}</span><span class=\"ellipsis\">#{text}</span><span class=\"invisible\">#{suffix}</span></a>"
end
def hashtag_html(match)