diff --git a/frontend/src/ts/commandline/commandline.ts b/frontend/src/ts/commandline/commandline.ts index d0e16e0b5..78fb9c0e9 100644 --- a/frontend/src/ts/commandline/commandline.ts +++ b/frontend/src/ts/commandline/commandline.ts @@ -410,8 +410,9 @@ function handleInputSubmit(): void { if (inputModeParams.command === null) { throw new Error("Can't handle input submit - command is null"); } - const value = inputValue; - inputModeParams.command.exec?.(value); + inputModeParams.command.exec?.({ + input: inputValue, + }); void AnalyticsController.log("usedCommandLine", { command: inputModeParams.command.id, }); @@ -444,11 +445,15 @@ async function runActiveCommand(): Promise { await showCommands(); await updateActiveCommand(); } else { - command.exec?.(); + command.exec?.({ + commandlineModal: modal, + }); const isSticky = command.sticky ?? false; if (!isSticky) { void AnalyticsController.log("usedCommandLine", { command: command.id }); - hide(true); + if (!command.opensModal) { + hide(true); + } } else { await filterSubgroup(); await showCommands(); diff --git a/frontend/src/ts/commandline/lists.ts b/frontend/src/ts/commandline/lists.ts index eb13928f3..40a77c6b3 100644 --- a/frontend/src/ts/commandline/lists.ts +++ b/frontend/src/ts/commandline/lists.ts @@ -241,7 +241,7 @@ export const commands: MonkeyTypes.CommandsSubgroup = { }, input: true, icon: "fa-tint", - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined) return; void UpdateConfig.setCustomLayoutfluid( input as MonkeyTypes.CustomLayoutFluidSpaces @@ -308,7 +308,7 @@ export const commands: MonkeyTypes.CommandsSubgroup = { return Config.customBackground; }, input: true, - exec: (input): void => { + exec: ({ input }): void => { UpdateConfig.setCustomBackground(input ?? ""); }, }, @@ -366,7 +366,7 @@ export const commands: MonkeyTypes.CommandsSubgroup = { icon: "fa-cog", alias: "import config", input: true, - exec: async (input): Promise => { + exec: async ({ input }): Promise => { if (input === undefined || input === "") return; try { await UpdateConfig.apply(JSON.parse(input)); diff --git a/frontend/src/ts/commandline/lists/background-filter.ts b/frontend/src/ts/commandline/lists/background-filter.ts index 3e6556f75..3e7fc3961 100644 --- a/frontend/src/ts/commandline/lists/background-filter.ts +++ b/frontend/src/ts/commandline/lists/background-filter.ts @@ -12,7 +12,7 @@ const subgroup: MonkeyTypes.CommandsSubgroup = { defaultValue: (): string => { return Config.customBackgroundFilter[0].toString(); }, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; const newFilters = Config.customBackgroundFilter; newFilters[0] = parseFloat(input); @@ -27,7 +27,7 @@ const subgroup: MonkeyTypes.CommandsSubgroup = { defaultValue: (): string => { return Config.customBackgroundFilter[1].toString(); }, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; const newFilters = Config.customBackgroundFilter; newFilters[1] = parseFloat(input); @@ -42,7 +42,7 @@ const subgroup: MonkeyTypes.CommandsSubgroup = { defaultValue: (): string => { return Config.customBackgroundFilter[2].toString(); }, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; const newFilters = Config.customBackgroundFilter; newFilters[2] = parseFloat(input); @@ -57,7 +57,7 @@ const subgroup: MonkeyTypes.CommandsSubgroup = { defaultValue: (): string => { return Config.customBackgroundFilter[3].toString(); }, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; const newFilters = Config.customBackgroundFilter; newFilters[3] = parseFloat(input); diff --git a/frontend/src/ts/commandline/lists/font-family.ts b/frontend/src/ts/commandline/lists/font-family.ts index ac2bd3a42..91db4e7f3 100644 --- a/frontend/src/ts/commandline/lists/font-family.ts +++ b/frontend/src/ts/commandline/lists/font-family.ts @@ -39,9 +39,9 @@ function update(fonts: MonkeyTypes.FontObject[]): void { hover: (): void => { UI.clearFontPreview(); }, - exec: (name) => { - if (name === undefined || name === "") return; - UpdateConfig.setFontFamily(name.replace(/\s/g, "_")); + exec: ({ input }) => { + if (input === undefined || input === "") return; + UpdateConfig.setFontFamily(input.replace(/\s/g, "_")); // Settings.groups.fontFamily.updateInput(); }, }); diff --git a/frontend/src/ts/commandline/lists/font-size.ts b/frontend/src/ts/commandline/lists/font-size.ts index 49b39cc02..c4706d626 100644 --- a/frontend/src/ts/commandline/lists/font-size.ts +++ b/frontend/src/ts/commandline/lists/font-size.ts @@ -9,7 +9,7 @@ const commands: MonkeyTypes.Command[] = [ defaultValue: (): string => { return Config.fontSize.toString(); }, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; UpdateConfig.setFontSize(parseFloat(input)); }, diff --git a/frontend/src/ts/commandline/lists/min-acc.ts b/frontend/src/ts/commandline/lists/min-acc.ts index e8bfa0b06..84466ef8e 100644 --- a/frontend/src/ts/commandline/lists/min-acc.ts +++ b/frontend/src/ts/commandline/lists/min-acc.ts @@ -17,7 +17,7 @@ const subgroup: MonkeyTypes.CommandsSubgroup = { display: "custom...", configValue: "custom", input: true, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; UpdateConfig.setMinAccCustom(parseInt(input)); UpdateConfig.setMinAcc("custom"); diff --git a/frontend/src/ts/commandline/lists/min-burst.ts b/frontend/src/ts/commandline/lists/min-burst.ts index 9df00ab44..0ecd089ba 100644 --- a/frontend/src/ts/commandline/lists/min-burst.ts +++ b/frontend/src/ts/commandline/lists/min-burst.ts @@ -18,7 +18,7 @@ const subgroup: MonkeyTypes.CommandsSubgroup = { display: "fixed...", configValue: "fixed", input: true, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; UpdateConfig.setMinBurst("fixed"); const newVal = getTypingSpeedUnit(Config.typingSpeedUnit).toWpm( @@ -32,7 +32,7 @@ const subgroup: MonkeyTypes.CommandsSubgroup = { display: "flex...", configValue: "flex", input: true, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; UpdateConfig.setMinBurst("flex"); const newVal = getTypingSpeedUnit(Config.typingSpeedUnit).toWpm( diff --git a/frontend/src/ts/commandline/lists/min-wpm.ts b/frontend/src/ts/commandline/lists/min-wpm.ts index 29aeccefd..507187cc5 100644 --- a/frontend/src/ts/commandline/lists/min-wpm.ts +++ b/frontend/src/ts/commandline/lists/min-wpm.ts @@ -18,7 +18,7 @@ const subgroup: MonkeyTypes.CommandsSubgroup = { display: "custom...", configValue: "custom", input: true, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; const newVal = getTypingSpeedUnit(Config.typingSpeedUnit).toWpm( parseInt(input) diff --git a/frontend/src/ts/commandline/lists/pace-caret.ts b/frontend/src/ts/commandline/lists/pace-caret.ts index 4d411546c..aefbc55fb 100644 --- a/frontend/src/ts/commandline/lists/pace-caret.ts +++ b/frontend/src/ts/commandline/lists/pace-caret.ts @@ -56,7 +56,7 @@ const subgroup: MonkeyTypes.CommandsSubgroup = { display: "custom...", configValue: "custom", input: true, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; const newVal = getTypingSpeedUnit(Config.typingSpeedUnit).toWpm( parseInt(input) diff --git a/frontend/src/ts/commandline/lists/tags.ts b/frontend/src/ts/commandline/lists/tags.ts index ec9ed2ee7..46f4166e2 100644 --- a/frontend/src/ts/commandline/lists/tags.ts +++ b/frontend/src/ts/commandline/lists/tags.ts @@ -5,6 +5,7 @@ import * as TagController from "../../controllers/tag-controller"; import Config from "../../config"; import * as PaceCaret from "../../test/pace-caret"; import { isAuthenticated } from "../../firebase"; +import AnimatedModal from "../../utils/animated-modal"; const subgroup: MonkeyTypes.CommandsSubgroup = { title: "Change tags...", @@ -39,6 +40,7 @@ function update(): void { display: "Create tag", icon: "fa-plus", shouldFocusTestUI: false, + exec: ({ commandlineModal }): void => { EditTagsPopup.show( "add", undefined, @@ -97,6 +99,8 @@ function update(): void { display: "Create tag", icon: "fa-plus", shouldFocusTestUI: false, + opensModal: true, + exec: ({ commandlineModal }): void => { EditTagsPopup.show( "add", undefined, diff --git a/frontend/src/ts/commandline/lists/time.ts b/frontend/src/ts/commandline/lists/time.ts index b545e003f..34416071e 100644 --- a/frontend/src/ts/commandline/lists/time.ts +++ b/frontend/src/ts/commandline/lists/time.ts @@ -54,7 +54,7 @@ const commands: MonkeyTypes.Command[] = [ id: "changeTimeConfigCustom", display: "custom...", input: true, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; UpdateConfig.setMode("time"); UpdateConfig.setTimeConfig(parseInt(input)); diff --git a/frontend/src/ts/commandline/lists/words.ts b/frontend/src/ts/commandline/lists/words.ts index a1a2d62a2..b780f722e 100644 --- a/frontend/src/ts/commandline/lists/words.ts +++ b/frontend/src/ts/commandline/lists/words.ts @@ -65,7 +65,7 @@ const commands: MonkeyTypes.Command[] = [ id: "changeWordCountCustom", display: "custom...", input: true, - exec: (input): void => { + exec: ({ input }): void => { if (input === undefined || input === "") return; UpdateConfig.setMode("words"); UpdateConfig.setWordCount(parseInt(input)); diff --git a/frontend/src/ts/types/types.d.ts b/frontend/src/ts/types/types.d.ts index 37585be9f..936b796af 100644 --- a/frontend/src/ts/types/types.d.ts +++ b/frontend/src/ts/types/types.d.ts @@ -293,6 +293,11 @@ declare namespace MonkeyTypes { }; }; + type CommandExecOptions = { + input?: string; + commandlineModal?: unknown; + }; + type Command = { id: string; display: string; @@ -306,11 +311,12 @@ declare namespace MonkeyTypes { input?: boolean; visible?: boolean; customStyle?: string; + opensModal?: boolean; defaultValue?: () => string; configKey?: keyof SharedTypes.Config; configValue?: string | number | boolean | number[]; configValueMode?: "include"; - exec?: (input?: string) => void; + exec?: (options: CommandExecOptions) => void; hover?: () => void; available?: () => boolean; active?: () => boolean;