Add quote search command (#2747)

This commit is contained in:
Bruce Berrios 2022-03-22 14:08:50 -04:00 committed by GitHub
parent 7e30eca23d
commit 76c230315c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 5 deletions

View file

@ -3076,6 +3076,16 @@ export const defaultCommands: MonkeyTypes.CommandsGroup = {
$("#top #menu .icon-button.view-settings").trigger("click");
},
},
{
id: "viewQuoteSearchPopup",
display: "Search for quotes",
icon: "fa-search",
exec: (): void => {
UpdateConfig.setMode("quote");
$("#quote-search-button").trigger("click");
},
shouldFocusTestUI: false,
},
{
id: "viewAccount",
display: "View Account Page",

View file

@ -186,7 +186,7 @@ export let show = (): void => {
$("#commandLine input").trigger("focus");
};
function hide(): void {
function hide(shouldFocusTestUI = true): void {
UpdateConfig.previewFontFamily(Config.fontFamily);
// applyCustomThemeColors();
if (!ThemeController.randomTheme) {
@ -203,19 +203,27 @@ function hide(): void {
() => {
$("#commandLineWrapper").addClass("hidden");
$("#commandLine").removeClass("allCommands");
TestUI.focusWords();
if (shouldFocusTestUI) {
TestUI.focusWords();
}
}
);
TestUI.focusWords();
if (shouldFocusTestUI) {
TestUI.focusWords();
}
}
function trigger(command: string): void {
let subgroup = false;
let input = false;
let shouldFocusTestUI = true;
const list = CommandlineLists.current[CommandlineLists.current.length - 1];
let sticky = false;
$.each(list.list, (_index, obj) => {
if (obj.id == command) {
if (obj.shouldFocusTestUI !== undefined) {
shouldFocusTestUI = obj.shouldFocusTestUI;
}
if (obj.input) {
input = true;
const escaped = obj.display.split("</i>")[1] ?? obj.display;
@ -239,7 +247,7 @@ function trigger(command: string): void {
});
if (!subgroup && !input && !sticky) {
AnalyticsController.log("usedCommandLine", { command });
hide();
hide(shouldFocusTestUI);
}
}

View file

@ -578,6 +578,7 @@ declare namespace MonkeyTypes {
hover?: () => void;
available?: () => void;
beforeSubgroup?: () => void;
shouldFocusTestUI?: boolean;
}
interface CommandsGroup {

View file

@ -220,7 +220,7 @@
<div class="button" quote="1">medium</div>
<div class="button" quote="2">long</div>
<div class="button" quote="3">thicc</div>
<div class="button" quote="-2">search</div>
<div id="quote-search-button" class="button" quote="-2">search</div>
</div>
<div class="group customGroup hidden">
<div class="button customChange">change</div>