nsIEditorSpellCheck.idl (5088B)
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/. */ 5 6 #include "nsISupports.idl" 7 8 interface nsIEditor; 9 interface nsIEditorSpellCheckCallback; 10 11 [scriptable, uuid(a171c25f-e4a8-4d08-adef-b797e6377bdc)] 12 interface nsIEditorSpellCheck : nsISupports 13 { 14 15 /** 16 * Returns true if we can enable spellchecking. If there are no available 17 * dictionaries, this will return false. 18 */ 19 boolean canSpellCheck(); 20 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. 28 */ 29 void InitSpellChecker(in nsIEditor editor, in boolean enableSelectionChecking, 30 [optional] in nsIEditorSpellCheckCallback callback); 31 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. 36 * 37 * @see mozSpellChecker::GetNextMisspelledWord 38 */ 39 [can_run_script] 40 AString GetNextMisspelledWord(); 41 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. 48 * 49 * @see mozSpellChecker::GetSuggestedWord 50 */ 51 AString GetSuggestedWord(); 52 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(). 58 * 59 * @see mozSpellChecker::CheckCurrentWord 60 */ 61 boolean CheckCurrentWord(in AString suggestedWord); 62 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. 66 */ 67 [implicit_jscontext] 68 Promise suggest(in AString aCheckingWorkd, in unsigned long aMaxCount); 69 70 /** 71 * Use when modally checking the document to replace a word. 72 * 73 * @see mozSpellChecker::CheckCurrentWord 74 */ 75 [can_run_script] 76 void ReplaceWord(in AString misspelledWord, in AString replaceWord, in boolean allOccurrences); 77 78 /** 79 * @see mozSpellChecker::IgnoreAll 80 */ 81 void IgnoreWordAllOccurrences(in AString word); 82 83 /** 84 * Adds a word to the current personal dictionary. 85 * 86 * @see mozSpellChecker::AddWordToDictionary 87 */ 88 void AddWordToDictionary(in AString word); 89 90 /** 91 * Removes a word from the current personal dictionary. 92 * 93 * @see mozSpellChecker::RemoveWordFromPersonalDictionary 94 */ 95 void RemoveWordFromDictionary(in AString word); 96 97 /** 98 * Retrieves a list of the currently available dictionaries. The strings will 99 * typically be language IDs, like "en-US". 100 * 101 * @see mozISpellCheckingEngine::GetDictionaryList 102 */ 103 Array<ACString> GetDictionaryList(); 104 105 /** 106 * @see mozSpellChecker::GetCurrentDictionaries 107 */ 108 Array<ACString> getCurrentDictionaries(); 109 110 /** 111 * @see mozSpellChecker::SetCurrentDictionaries 112 */ 113 [implicit_jscontext] 114 Promise setCurrentDictionaries(in Array<ACString> dictionaries); 115 116 /** 117 * Call this to free up the spell checking object. It will also save the 118 * current selected language as the default for future use. 119 * 120 * If you have called CanSpellCheck but not InitSpellChecker, you can still 121 * call this function to clear the cached spell check object, and no 122 * preference saving will happen. 123 */ 124 void UninitSpellChecker(); 125 126 const unsigned long FILTERTYPE_NORMAL = 1; 127 const unsigned long FILTERTYPE_MAIL = 2; 128 129 /** 130 * Used to filter the content (for example, to skip blockquotes in email from 131 * spellchecking. Call this before calling InitSpellChecker; calling it 132 * after initialization will have no effect. 133 */ 134 void setFilterType(in unsigned long filterType); 135 136 /** 137 * Update the dictionary in use to be sure it corresponds to what the editor 138 * needs. The update is asynchronous and is not complete until the given 139 * callback is called. 140 */ 141 void UpdateCurrentDictionary([optional] in nsIEditorSpellCheckCallback callback); 142 143 }; 144 145 [scriptable, function, uuid(5f0a4bab-8538-4074-89d3-2f0e866a1c0b)] 146 interface nsIEditorSpellCheckCallback : nsISupports 147 { 148 void editorSpellCheckDone(); 149 };