mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-08 16:50:44 +02:00
Add Angular filter for wrapping words larger than N characters.
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user