Summary plugin improvements: In-chat position, customizable template, force insert after X words

This commit is contained in:
Cohee
2023-07-30 23:10:37 +03:00
parent 02667d3d1a
commit 40f466b2c3
5 changed files with 139 additions and 69 deletions

View File

@ -470,6 +470,20 @@ export function getCharaFilename(chid) {
}
}
export function extractAllWords(value) {
const words = [];
if (!value) {
return words;
}
const matches = value.matchAll(/\b\w+\b/gim);
for (let match of matches) {
words.push(match[0].toLowerCase());
}
return words;
}
export function escapeRegex(string) {
return string.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
}