New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on new line(enter key) mention list is not getting display for ContentEditable #209
Comments
It's difficult to know whether it's a newline in contentEditable. |
Thanks for your reply. |
Has anyone had any luck with this? Wanted to check before I dive into the source. |
I tried to investigate the matter again, but it appear to be even more messy than what I thought at first. I'm more interested in iframes than contenteditable, so contenteditable may be more or less messy, no idea. The common problem is that the Searching the web (since I'm rather bad at javascript), I found: Following the second suggestion, I modified the code like that: diff --git a/jquery.atwho.js b/jquery.atwho.js
index 3bcb5b2..67606da 100644
--- a/jquery.atwho.js
+++ b/jquery.atwho.js
@@ -267,7 +275,11 @@ Controller = (function() {
if (this.$inputor.is('textarea, input')) {
return this.$inputor.val();
} else {
- return this.$inputor.text();
+ return this.$inputor.html().trim()
+ .replace(/<br(\s*)\/*><\/p>/ig, "") // Firefox adds a <br></p> at the end of the last line
+ .replace(/<br(\s*)\/*>/ig, "\n") // replace single line-breaks
+ .replace(/<(p|div)(\s|>)/ig, "\n") // add a line break before all div and p tags
+ .replace(/(<([^>]+)>)/ig, ""); // remove any remaining tags;
}
};
@@ -275,6 +287,9 @@ Controller = (function() {
var caret_pos, content, end, query, start, subtext;
content = this.content();
caret_pos = this.$inputor.caret('pos');
+ if (!this.$inputor.is('textarea, input')) {
+ caret_pos += (content.match(/\n/g) || []).length;
+ }
subtext = content.slice(0, caret_pos);
query = this.callbacks("matcher").call(this, this.at, subtext, this.get_opt('start_with_space'));
if (typeof query === "string" && query.length <= this.get_opt('max_len', 20)) { and after a quick test is seems to work (tested only with chrome and firefox on linux). The problems with that change are:
P.S. |
@emanuele45 You are awesome. |
Do you think it is an acceptable solution? Glad! 😃 |
Would love a fix for this. At.js is awesome, but not being able to trigger autocomplete right after a newline breaks it. |
I just discovered the On Fri, Dec 5, 2014 at 2:45 PM, Alexander Aghassipour <
Adam Becker |
Thanks @ajb . That introduces the nuisance of having the autosuggest pop up when entering e.g. an email address. But probably the lesser of two evils. |
Got it, you're welcome. We use "{{" to trigger the dropdown :) On Fri, Dec 5, 2014 at 2:59 PM, Alexander Aghassipour <
Adam Becker |
Not be tested in IE. Anyone could do me a favour!? |
Hello,
We have seen your demo and it works fine but the only problem we faced was when we type any word (without space) and press ENTER KEY then after that we try to get user mention list but it not display, so instead we type word and give space and then press ENTER KEY then it will work fine.
So the conclusion is we require space to get mention, but it should get user mention list after ENTER
Can you please help me out in this issue.
Thanks
The text was updated successfully, but these errors were encountered: