Unrelated linting
| @@ -1,5 +1,4 @@ | ||
| 1 | 1 | import { escapeRegex } from '../utils.js'; |
| 2 | -import { SlashCommand } from './SlashCommand.js'; | |
| 3 | 2 | import { SlashCommandParser } from './SlashCommandParser.js'; |
| 4 | 3 | |
| 5 | 4 | export class SlashCommandBrowser { |
| @@ -12,7 +11,7 @@ export class SlashCommandBrowser { | ||
| 12 | 11 | |
| 13 | 12 | renderInto(parent) { |
| 14 | 13 | if (!this.dom) { |
| 15 | 14 | const queryRegex = /(?:(?:^|\s+)([^\s"][^\s]S*?)(?:\s+|$))|(?:(?:^|\s+)"(.*?)(?:"|$)(?:\s+|$))/; |
| 16 | 15 | const root = document.createElement('div'); { |
| 17 | 16 | this.dom = root; |
| 18 | 17 | const search = document.createElement('div'); { |
| @@ -30,7 +29,7 @@ export class SlashCommandBrowser { | ||
| 30 | 29 | this.details?.remove(); |
| 31 | 30 | this.details = null; |
| 32 | 31 | let query = inp.value.trim(); |
| 33 | 32 | if (query.slice(-1) === '"' && !/(?:^|\s+)"/.test(query)) { |
| 34 | 33 | query = `"${query}`; |
| 35 | 34 | } |
| 36 | 35 | let fuzzyList = []; |
| @@ -59,7 +58,7 @@ export class SlashCommandBrowser { | ||
| 59 | 58 | cmd.helpString, |
| 60 | 59 | ]; |
| 61 | 60 | const find = ()=>targets.find(t=>(fuzzyList.find(f=>f.test(t)) ?? quotedList.find(q=>t.includes(q))) !== undefined) !== undefined; |
| 62 | 61 | if (fuzzyList.length + quotedList.length === 0 || find()) { |
| 63 | 62 | this.itemMap[cmd.name].classList.remove('isFiltered'); |
| 64 | 63 | } else { |
| 65 | 64 | this.itemMap[cmd.name].classList.add('isFiltered'); |
| @@ -78,7 +77,7 @@ export class SlashCommandBrowser { | ||
| 78 | 77 | list.classList.add('autoComplete'); |
| 79 | 78 | this.cmdList = Object |
| 80 | 79 | .keys(SlashCommandParser.commands) |
| 81 | 80 | .filter(key => SlashCommandParser.commands[key].name === key) // exclude aliases |
| 82 | 81 | .sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())) |
| 83 | 82 | .map(key => SlashCommandParser.commands[key]) |
| 84 | 83 | ; |
| @@ -97,7 +96,7 @@ export class SlashCommandBrowser { | ||
| 97 | 96 | } |
| 98 | 97 | } |
| 99 | 98 | } |
| 100 | 99 | if (this.details !== details) { |
| 101 | 100 | Array.from(list.querySelectorAll('.selected')).forEach(it=>it.classList.remove('selected')); |
| 102 | 101 | item.classList.add('selected'); |
| 103 | 102 | this.details?.remove(); |
| @@ -124,7 +123,7 @@ export class SlashCommandBrowser { | ||
| 124 | 123 | parent.append(this.dom); |
| 125 | 124 | |
| 126 | 125 | this.mo = new MutationObserver(muts=>{ |
| 127 | 126 | if (muts.find(mut=>Array.from(mut.removedNodes).find(it=>it === this.dom || it.contains(this.dom)))) { |
| 128 | 127 | this.mo.disconnect(); |
| 129 | 128 | window.removeEventListener('keydown', boundHandler); |
| 130 | 129 | } |
| @@ -136,7 +135,7 @@ export class SlashCommandBrowser { | ||
| 136 | 135 | } |
| 137 | 136 | |
| 138 | 137 | handleKeyDown(evt) { |
| 139 | 138 | if (!evt.shiftKey && !evt.altKey && evt.ctrlKey && evt.key.toLowerCase() === 'f') { |
| 140 | 139 | if (!this.dom.closest('body')) return; |
| 141 | 140 | if (this.dom.closest('.mes') && !this.dom.closest('.last_mes')) return; |
| 142 | 141 | evt.preventDefault(); |