Merge pull request #293 from sharelatex/pr-wrap-long-words-chat

Wrap long words chat
This commit is contained in:
Paulo Jorge Reis 2016-08-03 16:32:36 +01:00 committed by GitHub
commit 60f8e577a8
4 changed files with 31 additions and 1 deletions

View file

@ -45,7 +45,7 @@ aside.chat(
mathjax,
ng-repeat="content in message.contents track by $index"
)
span(ng-bind-html="content | linky:'_blank'")
span(ng-bind-html="content | linky:'_blank' | wrapLongWords")
.new-message
textarea(

View file

@ -0,0 +1,25 @@
define [
"base"
], (App) ->
DEF_MIN_LENGTH = 20
_decodeHTMLEntities = (str) ->
str.replace /&#(\d+);/g, (match, dec) ->
String.fromCharCode dec;
_getWrappedWordsString = (baseStr, wrapperElName, minLength) ->
minLength = minLength || DEF_MIN_LENGTH
words = baseStr.split ' '
wordsWrapped = for word in words
if _decodeHTMLEntities(word).length >= minLength
"<#{wrapperElName} class=\"break-word\">#{word}</#{wrapperElName}>"
else
word
outputStr = wordsWrapped.join ' '
App.filter "wrapLongWords", () ->
(input, minLength) ->
_getWrappedWordsString input, "span", minLength

View file

@ -3,4 +3,5 @@ define [
"ide/chat/controllers/ChatController"
"ide/chat/controllers/ChatMessageController"
"ide/chat/directives/mathjax"
"filters/wrapLongWords"
], () ->

View file

@ -129,6 +129,10 @@
}
}
.break-word {
word-break: break-all;
}
.editor-dark {
.chat {
.new-message {