- From: Michał Wadas <notifications@github.com>
- Date: Mon, 18 Dec 2017 07:27:01 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/547@github.com>
**Purpose**: allow websites to check spelling according to browser rules by JavaScript API with results similar to [spellcheck](https://html.spec.whatwg.org/multipage/interaction.html#attr-spellcheck).
**Concerns**: user defined words allows fingerprinting, raising privacy issues.
**API**:
```typescript
navigator.spellchecker(language: DOMString) => Promise.<Spellchecker>;
```
Valid implementation can always return rejected promise (eg. no in-browser dictionary).
Valid implementation can (should?) ask user to allow access to user-defined dictionary.
```typescript
class Spellchecker {
isValidWord(word: DOMString) => Promise.<Boolean>;
isGramaticallyValid(text: DOMString) => Promise.<Boolean>;
validateText(text: DOMString) => Promise.<Array.<SpellcheckingRangeResult>>
}
class SpellcheckingRangeResult {
int start; // Codepoint or character number?
int end; // Codepoint or character number?
enum('ortography', 'grammar', 'other') type;
dictionary details; // Implementation-specific details.
}
```
`isValidWord` returns if word is valid. If user didn't allow to access user-defined dictionary, it should return promise resolving to `false`. It should return promise resolving to `null` if not-a-word is given (eg. emoji, whitespaces, whole sentence).
`isGramaticallyValid` checks text for presence of grammar errors. Implementations not supporting grammar-checking should return promise resolving to `true`.
`validateText` checks text for presence of all errors. It should return Promise resolving to array of `SpellcheckingRangeResult`s.
`SpellcheckingRangeResult` is a simple object with read-only properties `start` and `end`, coresponding to start and end of "suspicious" text fragment. `type` property describes issue with selected fragment. Implementation-specific issues (eg. hypothetical plugin checking for formal language) should set `type` to string `"other"`. `SpellcheckingRangeResult` should be used mainly to display feedback to user.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/547
Received on Monday, 18 December 2017 15:27:29 UTC