Bladeren bron

Use string split instead of regex.

Paulo Reis 10 jaren geleden
bovenliggende
commit
01637386bd

+ 11 - 3
services/web/public/coffee/filters/wrapLongWords.coffee

@@ -3,13 +3,21 @@ define [
 ], (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 ' '
 
-		findWordsRegEx = new RegExp "\\w{#{minLength},}", "g"
-		wrappingTemplate = "<#{wrapperElName} class=\"break-word\">$&</#{wrapperElName}>"
+		wordsWrapped = for word in words
+			if _decodeHTMLEntities(word).length >= minLength
+				"<#{wrapperElName} class=\"break-word\">#{word}</#{wrapperElName}>"
+			else
+				word
 
-		baseStr.replace findWordsRegEx, wrappingTemplate
+		outputStr = wordsWrapped.join ' '
 
 
 	App.filter "wrapLongWords", () ->

+ 0 - 1
services/web/public/stylesheets/app/editor/chat.less

@@ -131,7 +131,6 @@
 
 .break-word {
 	word-break: break-all;
-	color: red;
 }
 
 .editor-dark {