mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-28 19:41:33 +02:00
Merge pull request #293 from sharelatex/pr-wrap-long-words-chat
Wrap long words chat
This commit is contained in:
@@ -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(
|
||||
|
||||
25
services/web/public/coffee/filters/wrapLongWords.coffee
Normal file
25
services/web/public/coffee/filters/wrapLongWords.coffee
Normal 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
|
||||
@@ -3,4 +3,5 @@ define [
|
||||
"ide/chat/controllers/ChatController"
|
||||
"ide/chat/controllers/ChatMessageController"
|
||||
"ide/chat/directives/mathjax"
|
||||
"filters/wrapLongWords"
|
||||
], () ->
|
||||
@@ -129,6 +129,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.break-word {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.editor-dark {
|
||||
.chat {
|
||||
.new-message {
|
||||
|
||||
Reference in New Issue
Block a user