Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions angular-input-highlight.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
_countScrollbar = null
_countScrollbar = null
ENTITY_MAP =
"&": "&"
"<": "&lt;"
">": "&gt;"
'"': '&quot;'
"'": '&#39;'
"/": '&#x2F;'

escapeHTMLEntities = (str) ->
String(str).replace /[&<>"'\/]/g, (c) -> ENTITY_MAP[c]

countScrollbar = ->
return _countScrollbar if _countScrollbar != null
t = document.createElement('textarea');
Expand Down Expand Up @@ -64,13 +75,13 @@ angular.module 'input-highlight', []
markers = []
originalText = text

mirror.innerHTML = text
mirror.innerHTML = escapeHTMLEntities(text)
mirror.style.width = style.width;
canvas.width = mirror.clientWidth
canvas.height = mirror.clientHeight

for color, re of formatting
mirror.innerHTML = text.replace re, (s) ->
mirror.innerHTML = escapeHTMLEntities(text).replace re, (s) ->
"<span style=\"position:relative;background:red;\" data-marker=\"#{color}\">#{s}</span>"

containerRect = mirror.getClientRects()[0]
Expand Down
25 changes: 20 additions & 5 deletions angular-input-highlight.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.