From dd2b5df98d6353871b3ab9fbf47190675f0354a1 Mon Sep 17 00:00:00 2001 From: Spencer Date: Fri, 9 Jun 2023 15:42:46 -0400 Subject: [PATCH] Adds a command to open your personal dictionary --- extension/README.md | 1 + extension/package.json | 8 ++++++++ extension/src/GrammarlyClient.ts | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/extension/README.md b/extension/README.md index a9321c1c7..4416857b4 100755 --- a/extension/README.md +++ b/extension/README.md @@ -23,6 +23,7 @@ You may use `grammarly.files.exclude` to ignore specific files. Run `grammarly.login` or **Grammarly: Login / Connect your account** command to connect your Grammarly account. Run `grammarly.logout` or **Grammarly: Log out** to disconnect your account. +Run `grammarly.dictionary` or **Grammarly: Open Dictionary** to open grammarly.com to your personal dictionary. ## Configuration diff --git a/extension/package.json b/extension/package.json index d9711ed8e..750ff5812 100644 --- a/extension/package.json +++ b/extension/package.json @@ -29,6 +29,7 @@ "onCommand:grammarly.check", "onCommand:grammarly.login", "onCommand:grammarly.logout", + "onCommand:grammarly.dictionary", "onLanguage:plaintext", "onLanguage:markdown", "onLanguage:html" @@ -773,6 +774,13 @@ "icon": "$(log-out)", "enablement": "grammarly.isUserAccountConnected" }, + { + "title": "Open Dictionary", + "category": "Grammarly", + "command": "grammarly.dictionary", + "icon": "$(book)", + "enablement": "!grammarly.isRunning || !grammarly.isUserAccountConnected" + }, { "title": "Restart language server", "category": "Grammarly", diff --git a/extension/src/GrammarlyClient.ts b/extension/src/GrammarlyClient.ts index 3db058f5b..2edcf4dba 100644 --- a/extension/src/GrammarlyClient.ts +++ b/extension/src/GrammarlyClient.ts @@ -206,6 +206,13 @@ export class GrammarlyClient implements Registerable { await this.client.protocol.logout() await window.showInformationMessage('Logged out.') }), + commands.registerCommand('grammarly.dictionary', async () => { + const dictionaryExternalURL = 'https://account.grammarly.com/customize'; + + if (!(await env.openExternal(dictionaryExternalURL))) { + await window.showErrorMessage('Failed to open dictionary.') + } + }), { dispose: () => this.session?.dispose() }, ) }