krv5vignesh / Dictionary-extension

Firefox WebExtension - English Popup Dictionary
https://addons.mozilla.org/en-US/firefox/addon/english-popup-dictionary/
GNU General Public License v3.0
43 stars 11 forks source link

Add Support for Other Selection Methods #24

Open thepragg opened 6 years ago

thepragg commented 6 years ago

Hey there krv5vignesh... First off, loving the add-on more than my descriptive words can suffice. 👍 Mate, and thank you!!

But, as my title states, was wondering if we could have more methods of text-selection, coz well, sometimes the word you want to look_up (IS / is IN) a link, i.e: wrapped in an </a> tag. For such, we cant exactly double click for definition, which IMHO limits the add-on's effectiveness.

My suggestion is to maybe include text selected using the normal selection method (mouse[down+move+up]) but ONLY while using the shiftKey as a modifier. i.e;

$(document).on({
  dblclick: gtSlection,
  mouseup: function(e) {
    if (e.shiftKey) {
      gtSlection();
    } else return;
  }
});

The above code seems to work when I ran it through my browser console:

$(document).on({
  dblclick: gtSlection,
  mouseup: function(e) {
    if (e.shiftKey) {
      gtSlection();
    } else return;
  }
});

var selectedText;
function gtSlection(){
  var text;
  if (window.getSelection) {
      selectedText = window.getSelection();
  } else if (document.getSelection) {
      selectedText = document.getSelection();
  } else if (document.selection) {
      selectedText = document.selection.createRange().text;
  }
  text = selectedText.toString().trim();

  console.log('Selected Text = ' + text);
}

Anyway, thanks again for your work, cheers

elig0n commented 5 years ago

A clickable floater can also be nice :-)

g-berthiaume commented 5 years ago

My request seems to fit here, so I wont create a new issue.

[FEATURE REQUEST] Adding the option to activate the extension only when the crtl key is down.

Context

I do a lot of text editing on web based tools (as google doc). As you can guess, I don't want a dictionary popup every time I select text to format it.

Thanks again for your work. This dictionary is great to learn the language.

g-berthiaume commented 5 years ago

To give an example of implementation, see the google dictionnary chrome extension .

riquezjp commented 2 years ago

This feature suggestion may also help to select words like "vis-a-vis" or "face-saving" which is not currently possible due to the hyphen stopping the word from being double-clicked.

riquezjp commented 2 years ago

[FEATURE REQUEST] Adding the option to activate the extension only when the crtl key is down.

Great idea.

Instead of ctrl could the option to activate be added to the right-click menu?

This would follow the practice of other extensions & also may be more fluent since you can use the mouse to both select text & right-click 'define' with same hand.

Google Docs actually has its own version of word definition that they call "explore" when you right-click a word.