{% load spire_core_tags %}
user.full_name === (this.word_at_cursor().substring(1)))){ // Does not toggle if the correct full_name is attached to an @ this.show_user_list = false } else { // Toggles if first character is @ this.show_user_list = this.word_at_cursor().charAt(0) === '@'; } }, word_at_cursor(){ const cursor_position = document.getElementById(this.id).selectionStart const string_start = this.comment.substring(0, cursor_position).match(/[a-zA-Z0-9-_@]+$/) const string_end = this.comment.substring(cursor_position).match(/^[a-zA-Z0-9-_@]+/) if(!string_start && !string_end) return '' return (string_start || '') + (string_end || '') }, word_end_index(){ let current_index = document.getElementById(this.id).selectionStart for(let i = current_index; i <= this.comment.length; i++ ){ if(this.char_is_space(this.comment.charAt(i))){ // Works forward to find a space and returns that index return i; } } return current_index; }, word_start_index(){ let current_index = document.getElementById(this.id).selectionStart if(this.char_is_space(this.comment.charAt(current_index))){ // Subtract one to get the word before the cursor current_index -= 1 } for(let i = current_index; i >= 0; i-- ){ if(this.char_is_space(this.comment.charAt(i))){ // Once we find a space we need to return the spot after it. return i + 1; } } // Return the start if there are no spaces return 0; } }">
{% csrf_token %}