mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add Angular filter for wrapping words larger than N characters.
This commit is contained in:
parent
18d0c51da9
commit
c6334ffab7
1 changed files with 17 additions and 0 deletions
17
services/web/public/coffee/filters/wrapLongWords.coffee
Normal file
17
services/web/public/coffee/filters/wrapLongWords.coffee
Normal file
|
@ -0,0 +1,17 @@
|
|||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
DEF_MIN_LENGTH = 20
|
||||
|
||||
_getWrappedWordsString = (baseStr, wrapperElName, minLength) ->
|
||||
minLength = minLength || DEF_MIN_LENGTH
|
||||
|
||||
findWordsRegEx = new RegExp "\\w{#{minLength},}", "g"
|
||||
wrappingTemplate = "<#{wrapperElName} style='word-break: break-all;'>$&</#{wrapperElName}>"
|
||||
|
||||
baseStr.replace findWordsRegEx, wrappingTemplate
|
||||
|
||||
|
||||
App.filter "wrapLongWords", () ->
|
||||
(input, minLength) ->
|
||||
_getWrappedWordsString input, "span", minLength
|
Loading…
Reference in a new issue