|
|
|
@ -1,3 +1,11 @@
|
|
|
|
|
# utility functions to escape a query
|
|
|
|
|
# @param str the string to escape
|
|
|
|
|
escapeRegexp = (str) -> str.replace /([.?*+^$[\]\\(){}|-])/g, "\\$1"
|
|
|
|
|
|
|
|
|
|
# removes all img tags
|
|
|
|
|
# @param str a string possibly containing img tags
|
|
|
|
|
noImg = (str) -> str.replace /<img[^>]*>/g, ''
|
|
|
|
|
|
|
|
|
|
angular.module('radians.contenteditable', [])
|
|
|
|
|
.directive('contenteditable', ->
|
|
|
|
|
require: 'ngModel',
|
|
|
|
@ -22,11 +30,12 @@ angular.module('radians.contenteditable', [])
|
|
|
|
|
null
|
|
|
|
|
)
|
|
|
|
|
.filter('typeaheadHighlight', ->
|
|
|
|
|
# don't highlight anything!
|
|
|
|
|
(matchItem, query) -> matchItem
|
|
|
|
|
)
|
|
|
|
|
.filter('ignoreImgFilter', ->
|
|
|
|
|
noImg = (s) -> s.replace(/<img[^>]*>/, '')
|
|
|
|
|
# when matching query against the items, ignore all img tags
|
|
|
|
|
(items, query) ->
|
|
|
|
|
item for item in items \
|
|
|
|
|
when noImg(item).match(new RegExp(noImg(query), 'gi'))
|
|
|
|
|
when noImg(item).match(new RegExp(escapeRegexp(noImg(query)), 'gi'))
|
|
|
|
|
)
|
|
|
|
|