Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions frontend/src/ts/input/handlers/insert-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import {
} from "../../utils/strings";
import * as TestState from "../../test/test-state";
import * as TestLogic from "../../test/test-logic";
import {
findSingleActiveFunboxWithFunction,
isFunboxActiveWithProperty,
} from "../../test/funbox/list";
import { isFunboxActiveWithProperty } from "../../test/funbox/list";
import { Config } from "../../config/store";
import { flash } from "../../events/keymap";
import * as WeakSpot from "../../test/weak-spot";
Expand Down Expand Up @@ -160,20 +157,12 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
Config.oppositeShiftMode === "off" ? null : isCorrectShiftUsed();

// is char correct
const funboxCorrect = findSingleActiveFunboxWithFunction(
"isCharCorrect",
)?.functions.isCharCorrect(
const charCorrect = isCharCorrect({
data,
currentWord[(testInput + data).length - 1] ?? "",
);
const charCorrect =
funboxCorrect ??
isCharCorrect({
data,
inputValue: testInput,
targetWord: currentWord,
correctShiftUsed,
});
inputValue: testInput,
targetWord: currentWord,
correctShiftUsed,
});

// word navigation check
const noSpaceForce =
Expand All @@ -186,13 +175,12 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
// when moving to the next word, correctness is word-level (a correct word-completing
// space has charCorrect === false, so charCorrect can't be used below)
const correct = goingToNextWord
? (funboxCorrect ??
isWordCorrect({
? isWordCorrect({
data,
inputValue: testInput,
targetWord: currentWord,
correctShiftUsed,
}))
})
: charCorrect;

// handing cases where last char needs to be removed
Expand Down
37 changes: 0 additions & 37 deletions frontend/src/ts/test/funbox/funbox-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export type FunboxFunctions = {
pullSection?: (language?: Language) => Promise<JSONData.Section | false>;
handleSpace?: () => void;
getEmulatedChar?: (event: KeyboardEvent) => string | null;
isCharCorrect?: (char: string, originalChar: string) => boolean;
handleKeydown?: (event: KeyboardEvent) => Promise<void>;
getResultContent?: () => string;
start?: () => void;
Expand Down Expand Up @@ -261,42 +260,6 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
}
return null;
},
isCharCorrect(char: string, originalChar: string): boolean {
if (
(char === "a" ||
char === "ArrowLeft" ||
char === "j" ||
char === "←") &&
originalChar === "←"
) {
return true;
}
if (
(char === "s" ||
char === "ArrowDown" ||
char === "k" ||
char === "↓") &&
originalChar === "↓"
) {
return true;
}
if (
(char === "w" || char === "ArrowUp" || char === "i" || char === "↑") &&
originalChar === "↑"
) {
return true;
}
if (
(char === "d" ||
char === "ArrowRight" ||
char === "l" ||
char === "→") &&
originalChar === "→"
) {
return true;
}
return false;
},
getWordHtml(char: string, letterTag?: boolean): string {
let retval = "";
if (char === "↑") {
Expand Down
1 change: 0 additions & 1 deletion packages/funbox/src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ const list: Record<FunboxName, FunboxMetadata> = {
"getWord",
"rememberSettings",
"getEmulatedChar",
"isCharCorrect",
"getWordHtml",
],
name: "arrows",
Expand Down
5 changes: 0 additions & 5 deletions packages/funbox/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ export function checkCompatibility(
funboxesToCheck.filter((f) =>
f.frontendFunctions?.includes("getEmulatedChar"),
).length <= 1;
const oneCharCheckerMax =
funboxesToCheck.filter((f) =>
f.frontendFunctions?.includes("isCharCorrect"),
).length <= 1;
const oneCharReplacerMax =
funboxesToCheck.filter((f) => f.frontendFunctions?.includes("getWordHtml"))
.length <= 1;
Expand Down Expand Up @@ -240,7 +236,6 @@ export function checkCompatibility(
oneToPushOrPullSectionMax &&
onePunctuateWordMax &&
oneGetEmulatedCharMax &&
oneCharCheckerMax &&
oneCharReplacerMax &&
oneChangesCapitalisationMax &&
oneCssModificationPerElement &&
Expand Down
Loading