Fix #4731: Tag counter in edit boxes should only count unique tags, not repeated.

Just use the `uniq` function from lodash. Adds ~1kb to the build.

Also rename `Utility.regexp_split` to `Utility.splitWords`.
This commit is contained in:
evazion
2021-02-23 18:49:53 -06:00
parent 868f1a1809
commit b2a423af64
6 changed files with 29 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
import Rails from '@rails/ujs';
import { hideAll } from 'tippy.js';
import words from "lodash/words";
let Utility = {};
@@ -113,9 +114,8 @@ Utility.regexp_escape = function(string) {
return string.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
}
Utility.regexp_split = function(string) {
string ??= "";
return string.match(/\S+/g) ?? [];
Utility.splitWords = function(string) {
return words(string, /\S+/g);
}
$.fn.selectEnd = function() {