From 07bc5cbd4a3102c8c3d25946aea42ddc580cc159 Mon Sep 17 00:00:00 2001 From: Dmitri Akatov Date: Wed, 26 Jun 2013 17:27:12 +0100 Subject: [PATCH] when filtering matches, ignore img tags --- examples/typeahead2.html | 2 +- src/radians/contenteditable.coffee | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/typeahead2.html b/examples/typeahead2.html index 864edad..9fe33ed 100644 --- a/examples/typeahead2.html +++ b/examples/typeahead2.html @@ -26,7 +26,7 @@ angular.module('typeahead', ['ui.bootstrap', 'radians'])
Model: {{ selected | json }}
-
+
diff --git a/src/radians/contenteditable.coffee b/src/radians/contenteditable.coffee index d203f15..149fd87 100644 --- a/src/radians/contenteditable.coffee +++ b/src/radians/contenteditable.coffee @@ -24,3 +24,9 @@ angular.module('radians.contenteditable', []) .filter('typeaheadHighlight', -> (matchItem, query) -> matchItem ) +.filter('ignoreImgFilter', -> + noImg = (s) -> s.replace(/]*>/, '') + (items, query) -> + item for item in items \ + when noImg(item).match(new RegExp(noImg(query), 'gi')) +)