Changeset 1352 for trunk


Ignore:
Timestamp:
02/04/18 01:06:34 (14 months ago)
Author:
gogo
Message:

#1476 Improve ContextMenu? behaviour for misspelt words (detected by browser).

If a words is misspelt according to the browser (red squiggly line inserted by browser) and you select that word and only that word (in Chrome this will automatically happen when you right click it, in Firefox double click it) then right click the ContextMenu? plugin will fall back to the browser's context menu and allow you to choose spelling suggestions.

If you right click within a link, or on a selected image, or multiple words, or without highlighting the word (just caret, which for misspelt words on chrome may not be possible) then the ContextMenu? will open as normal.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/ContextMenu/ContextMenu.js

    r1196 r1352  
    234234        } 
    235235 
     236        // If there is a selection, and not a link, image, or multiple words 
     237        //  then this may be a misspelled word, cancel the context menu so that 
     238        //  the browser's default will appear and offer suggestions 
     239        if (selection && !link && !img && !editor.getSelectedHTML().replace(/<[^>]+>/, '').match(/\s/)) 
     240  { 
     241    return false; 
     242  } 
     243         
    236244        if (selection && !link) 
    237245                menu.push(null, [ Xinha._lc("Make lin_k...", "ContextMenu"), 
     
    378386 
    379387        var options = this.getContextMenu(target); 
     388  if(options === false) return false; // No context menu 
     389   
    380390        for (var i = 0; i < options.length; ++i) { 
    381391                var option = options[i]; 
Note: See TracChangeset for help on using the changeset viewer.