nodebb-plugin-link-mentions
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "nodebb-plugin-link-mentions", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "NodeBB plugin that allows adding custom mentions to preconfigured links by prepending '^' to their corresponding keywords", | ||
@@ -5,0 +5,0 @@ "main": "library.js", |
@@ -10,5 +10,15 @@ 'use strict'; | ||
let slugify; | ||
let prevTerm = ''; | ||
let noMatch = false; | ||
const strategy = { | ||
match: new RegExp(`\\B\\${SYMBOL}([^\\s\\n]*)?$`), | ||
match: new RegExp(`\\B\\${SYMBOL}(([^\\s\\n]\\s?)*)?$`), | ||
search: function (term, callback) { | ||
// Don't search on further key presses if there's no match already | ||
if (term && term.startsWith(prevTerm) && noMatch) { | ||
return callback([]); | ||
} | ||
noMatch = false; | ||
prevTerm = term; | ||
// Get composer metadata | ||
@@ -26,2 +36,3 @@ const uuid = data.options.className && data.options.className.match(/dropdown-(.+?)\s/)[1]; | ||
noMatch = pairs.length < 1; | ||
callback(pairs.sort((a, b) => a.toLocaleLowerCase() > b.toLocaleLowerCase())); | ||
@@ -28,0 +39,0 @@ }); |
20835
321