Bug 1769887 - [wpt-sync] Update web-platform-tests to dd05a4454ef3e76677d1191823b3442...
[gecko.git] / editor / nsIEditorSpellCheck.idl
blob0849956c7abcb61b770f3761a01ebe161ad6c24b
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsISupports.idl"
8 interface nsIEditor;
9 interface nsIEditorSpellCheckCallback;
11 [scriptable, uuid(a171c25f-e4a8-4d08-adef-b797e6377bdc)]
12 interface nsIEditorSpellCheck : nsISupports
15 /**
16 * Returns true if we can enable spellchecking. If there are no available
17 * dictionaries, this will return false.
19 boolean canSpellCheck();
21 /**
22 * Turns on the spell checker for the given editor. enableSelectionChecking
23 * set means that we only want to check the current selection in the editor,
24 * (this controls the behavior of GetNextMisspelledWord). For spellchecking
25 * clients with no modal UI (such as inline spellcheckers), this flag doesn't
26 * matter. Initialization is asynchronous and is not complete until the given
27 * callback is called.
29 void InitSpellChecker(in nsIEditor editor, in boolean enableSelectionChecking,
30 [optional] in nsIEditorSpellCheckCallback callback);
32 /**
33 * When interactively spell checking the document, this will return the
34 * value of the next word that is misspelled. This also computes the
35 * suggestions which you can get by calling GetSuggestedWord.
37 * @see mozSpellChecker::GetNextMisspelledWord
39 [can_run_script]
40 AString GetNextMisspelledWord();
42 /**
43 * Used to get suggestions for the last word that was checked and found to
44 * be misspelled. The first call will give you the first (best) suggestion.
45 * Subsequent calls will iterate through all the suggestions, allowing you
46 * to build a list. When there are no more suggestions, an empty string
47 * (not a null pointer) will be returned.
49 * @see mozSpellChecker::GetSuggestedWord
51 AString GetSuggestedWord();
53 /**
54 * Check a given word. In spite of the name, this function checks the word
55 * you give it, returning true if the word is misspelled. If the word is
56 * misspelled, it will compute the suggestions which you can get from
57 * GetSuggestedWord().
59 * @see mozSpellChecker::CheckCurrentWord
61 boolean CheckCurrentWord(in AString suggestedWord);
63 /**
64 * Check a given word then returns suggestion words via Promise if a given
65 * word is misspelled. If not misspelled, returns empty string array.
67 [implicit_jscontext]
68 Promise suggest(in AString aCheckingWorkd, in unsigned long aMaxCount);
70 /**
71 * Use when modally checking the document to replace a word.
73 * @see mozSpellChecker::CheckCurrentWord
75 [can_run_script]
76 void ReplaceWord(in AString misspelledWord, in AString replaceWord, in boolean allOccurrences);
78 /**
79 * @see mozSpellChecker::IgnoreAll
81 void IgnoreWordAllOccurrences(in AString word);
83 /**
84 * Fills an internal list of words added to the personal dictionary. These
85 * words can be retrieved using GetPersonalDictionaryWord()
87 * @see mozSpellChecker::GetPersonalDictionary
88 * @see GetPersonalDictionaryWord
90 void GetPersonalDictionary();
92 /**
93 * Used after you call GetPersonalDictionary() to iterate through all the
94 * words added to the personal dictionary. Will return the empty string when
95 * there are no more words.
97 AString GetPersonalDictionaryWord();
99 /**
100 * Adds a word to the current personal dictionary.
102 * @see mozSpellChecker::AddWordToDictionary
104 void AddWordToDictionary(in AString word);
107 * Removes a word from the current personal dictionary.
109 * @see mozSpellChecker::RemoveWordFromPersonalDictionary
111 void RemoveWordFromDictionary(in AString word);
114 * Retrieves a list of the currently available dictionaries. The strings will
115 * typically be language IDs, like "en-US".
117 * @see mozISpellCheckingEngine::GetDictionaryList
119 Array<ACString> GetDictionaryList();
122 * @see mozSpellChecker::GetCurrentDictionaries
124 Array<ACString> getCurrentDictionaries();
127 * @see mozSpellChecker::SetCurrentDictionaries
129 [implicit_jscontext]
130 Promise setCurrentDictionaries(in Array<ACString> dictionaries);
133 * Call this to free up the spell checking object. It will also save the
134 * current selected language as the default for future use.
136 * If you have called CanSpellCheck but not InitSpellChecker, you can still
137 * call this function to clear the cached spell check object, and no
138 * preference saving will happen.
140 void UninitSpellChecker();
142 const unsigned long FILTERTYPE_NORMAL = 1;
143 const unsigned long FILTERTYPE_MAIL = 2;
146 * Used to filter the content (for example, to skip blockquotes in email from
147 * spellchecking. Call this before calling InitSpellChecker; calling it
148 * after initialization will have no effect.
150 void setFilterType(in unsigned long filterType);
153 * Update the dictionary in use to be sure it corresponds to what the editor
154 * needs. The update is asynchronous and is not complete until the given
155 * callback is called.
157 void UpdateCurrentDictionary([optional] in nsIEditorSpellCheckCallback callback);
161 [scriptable, function, uuid(5f0a4bab-8538-4074-89d3-2f0e866a1c0b)]
162 interface nsIEditorSpellCheckCallback : nsISupports
164 void editorSpellCheckDone();