Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hari's GSoC Spell Checking UI: Initial Implementation #500

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
679669a
adding spell checker as an enabled mode
satti-hari-krishna-reddy Jun 16, 2024
896a77e
specifying path to spell checker
satti-hari-krishna-reddy Jun 16, 2024
a6958e2
included spell checker as a new mode
satti-hari-krishna-reddy Jun 16, 2024
12eb793
adding spell check as a link in the nav bar
satti-hari-krishna-reddy Jun 16, 2024
0138309
empty initial spell check component
satti-hari-krishna-reddy Jun 17, 2024
03ee1b5
fixing import for spell check component
satti-hari-krishna-reddy Jun 17, 2024
530cd5b
initial code for spell checker interface
satti-hari-krishna-reddy Jun 17, 2024
46ca008
fix issues with text rendering
satti-hari-krishna-reddy Jun 21, 2024
b35ca82
fixng styling
satti-hari-krishna-reddy Jun 21, 2024
45855bb
fixing issue with state updates with renderHighlightText
satti-hari-krishna-reddy Jun 22, 2024
f91abdd
adding handleSubmit function
satti-hari-krishna-reddy Jun 22, 2024
7c21473
refactoring SpellCheck component
satti-hari-krishna-reddy Jun 22, 2024
61fb332
removing unnecessary script
satti-hari-krishna-reddy Jun 22, 2024
554f455
trying to fix eslint issues
satti-hari-krishna-reddy Jun 28, 2024
30a2847
fixed lint errors
satti-hari-krishna-reddy Jun 28, 2024
1dae8d2
fixed a failing test case
satti-hari-krishna-reddy Jun 28, 2024
52d2efe
Merge branch 'apertium:master' into gsoc-speller-checker
satti-hari-krishna-reddy Jun 28, 2024
23b4597
fixing the text not showing up from local storage
satti-hari-krishna-reddy Jun 28, 2024
5587092
fixing prettier error and improving applySuggestion function
satti-hari-krishna-reddy Jun 28, 2024
bd0e486
saving and restoring caret position
satti-hari-krishna-reddy Jun 29, 2024
5940fae
getting available voikko modes
satti-hari-krishna-reddy Jul 26, 2024
67971dc
making sure to strip way any html tags
satti-hari-krishna-reddy Jul 26, 2024
ad0fdb1
renaming the apy endpoint for spell checking
satti-hari-krishna-reddy Jul 28, 2024
bf50986
test(SpellChecker): add initial unit test cases
satti-hari-krishna-reddy Jul 28, 2024
33877f0
reverting to spellers
satti-hari-krishna-reddy Jul 29, 2024
5269f1f
fix small circle issue when no suggestions are returned
satti-hari-krishna-reddy Aug 1, 2024
34a4554
Added logic for instant spell check triggered after a delay of 3 seco…
satti-hari-krishna-reddy Aug 4, 2024
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
10 changes: 8 additions & 2 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ const Plugin = {

let defaultStrings: unknown;

let pairsResponse, analyzersResponse, generatorsResponse;
let pairsResponse, analyzersResponse, generatorsResponse, spellerResponse;
try {
[pairsResponse, analyzersResponse, generatorsResponse] = await Promise.all([
[pairsResponse, analyzersResponse, generatorsResponse, spellerResponse] = await Promise.all([
apyGet('list', {}),
apyGet('list', { q: 'analyzers' }),
apyGet('list', { q: 'generators' }),
apyGet('list', { q: 'spellers' }),
]);
} catch (error) {
let message = new String(error).toString();
Expand Down Expand Up @@ -104,6 +105,9 @@ const Plugin = {
const generators = Object.fromEntries(
Object.entries(generatorsResponse.data as Record<string, string>).filter(([code]) => allowedLang(code)),
);
const spellers = Object.fromEntries(
Object.entries(spellerResponse.data as Record<string, string>).filter(([code]) => allowedLang(code)),
);

let pairPrefs = {};
try {
Expand All @@ -116,6 +120,7 @@ const Plugin = {
...pairs.flatMap(({ sourceLanguage, targetLanguage }) => [sourceLanguage, targetLanguage]),
...Object.keys(analyzers),
...Object.keys(generators),
...Object.keys(spellers),
...Object.keys(languages),
...Object.keys(locales),
].filter(Boolean);
Expand Down Expand Up @@ -170,6 +175,7 @@ const Plugin = {
'window.PAIR_PREFS': JSON.stringify(pairPrefs),
'window.ANALYZERS': JSON.stringify(analyzers),
'window.GENERATORS': JSON.stringify(generators),
'window.SPELLERS': JSON.stringify(spellers),
...initialOptions.define,
};

Expand Down
2 changes: 1 addition & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
apyURL: 'https://beta.apertium.org/apy',

defaultMode: Mode.Translation,
enabledModes: new Set([Mode.Translation, Mode.Analysis, Mode.Generation, Mode.Sandbox]),
enabledModes: new Set([Mode.Translation, Mode.Analysis, Mode.Generation, Mode.Sandbox, Mode.SpellChecker]),
translationChaining: true,

subtitle: 'Beta',
Expand Down
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Generator from './components/Generator';
import LocaleSelector from './components/LocaleSelector';
import Navbar from './components/navbar';
import Sandbox from './components/Sandbox';
import SpellChecker from './components/spellchecker/SpellChecker';
import Translator from './components/translator/Translator';
import { Mode as TranslatorMode } from './components/translator';
import { Path as WebpageTranslationPath } from './components/translator/WebpageTranslationForm';
Expand All @@ -31,6 +32,7 @@ const Interfaces = {
[Mode.Analysis]: Analyzer,
[Mode.Generation]: Generator,
[Mode.Sandbox]: Sandbox,
[Mode.SpellChecker]: SpellChecker,
} as Record<Mode, React.ComponentType<unknown>>;

const App = ({ setLocale }: { setLocale: React.Dispatch<React.SetStateAction<string>> }): React.ReactElement => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/navbar/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('navigation options', () => {
const navbar = screen.getByTestId('navbar-mobile');
const links = getAllByRole(navbar, 'link', { name: (n) => n !== 'Toggle navigation' });

expect(links).toHaveLength(4);
expect(links).toHaveLength(5);
});

it('includes button', () => {
Expand Down
12 changes: 12 additions & 0 deletions src/components/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ const NavbarNav: React.ComponentType = (props: NavProps) => {
</LinkContainer>
</Nav.Item>
)}
{enabledModes.has(Mode.SpellChecker) && (
<Nav.Item as="li">
<LinkContainer
isActive={(_, { pathname }) =>
pathname === '/spellchecker' || (pathname === '/' && defaultMode === Mode.SpellChecker)
}
to={'/spellchecker'}
>
<Nav.Link>{t('Spell_Check')}</Nav.Link>
</LinkContainer>
</Nav.Item>
)}
</Nav>
);
};
Expand Down
Loading
Loading