This is a migrated thread and some comments may be shown as answers.

Change behavior of 'Add to dictionary' option

1 Answer 42 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Iron
Paul asked on 11 Mar 2014, 08:57 PM
The rad editors on a site have users able to add custom words to the dictionary. The client however, wants to change it. They see that the users add terms that are unnecessary or incorrect terms being used. What they want is for them to approve of the terms before adding them to the custom dictionary. Is there a way to modify the behavior of the 'Add to Dictionary' option of a misspelled word to not add it to the custom dictionary and instead submit that entry into a database to wait to be approved?

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 14 Mar 2014, 10:49 AM
Hi Paul,

Generally, this is not supported, because the spellchecking logic is quite complex and the suggestions dropdown is created for each new word, so it is very difficult to override it.

What I can offer is overriding the internal method that adds a word, so you can call your own custom logic instead of having the built-in spellcheck add to the dictionary. Note that blocking the thread execution would be quite hard in this case, so further user actions would be difficult to add.

Here is a the simplest way I could do this, which will give you a handle to submit the word for review with your own code (e.g., a webservice call. This blog post may give you ideas on the way to send this information to the server: http://blogs.telerik.com/aspnet-ajax/posts/13-03-21/different-ways-to-make-a-request-to-the-server):
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientCommandExecuted="knowIfSpellCheck">
</telerik:RadEditor>
<script type="text/javascript">
    function knowIfSpellCheck(sender, args)
    {
        if(args.get_commandName() == "AjaxSpellCheck")
        {
            setTimeout(function ()
            {
                Telerik.Web.UI.Editor.AjaxSpellCheck.prototype.addCustomWord = addCustomWordNew;
            }, 100);
        }
    }
 
    function customAddWord(word)
    {
        alert(word);
        //save the word to the DB as desired
    }
 
    function addCustomWordNew(oWord)
    {
        var spell = this.getSpellService();
        var oSpellEngine = this._spellEngine;
        var oSuccess = this._addWordSuccessMessage;
        customAddWord(oWord)
        oSpellEngine.clearWrongWords(oWord, oWord);
        var res = oSpellEngine.isHighlightedRemaining();
        if (!res)
        {
            oSpellEngine._suggestionDropdown.hide();
            return;
        }
        oSpellEngine.moveToNextWrongWord();
    }
</script>

I hope this helps. You can further customize this to match your needs if you like.

Regards,
Marin Bratanov
Telerik

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

Tags
Editor
Asked by
Paul
Top achievements
Rank 1
Iron
Answers by
Marin Bratanov
Telerik team
Share this question
or