LuteOrg / lute-v3

LUTE = Learning Using Texts: learn languages through reading.
https://luteorg.github.io/lute-manual/
MIT License
486 stars 46 forks source link

Automatically open external dictionary on click #288

Closed patrickayoup closed 8 months ago

patrickayoup commented 8 months ago

Is your feature request related to a problem? Please describe.

My preferred dictionary is globe, however it blocks clients from embedding in an iframe, therefore we must define it as an external dictionary by prepending a "*" to the URL. I am finding it tiring to click on a word, and then have to click on the dictionary tab to get the new window to open up with the definition. I think users who have a preferred external dictionary site can benefit from having this process streamlined.

Describe the solution you'd like

Please note that this proposal is somewhat dependant on having a layout where lute occupied half of the screen and the dictionary site would occupy the other half in a different window, snapped side by side. See the image for reference. I haven't thought about how this would work if lute occupies the full screen, but I'm sure we could come up with something.

Pre-requisites: Your first dictionary site (leftmost tab) is marked external with a "*".

When I click on a word, I would like the following to happen:

  1. The pane where we enter a word definition opens, but expanded on to show the entry form, the dictionary portion is not expanded because we will be opening an external dictionary.
  2. The dictionary opens up in another window.

Perhaps, if the definition in my external dictionary is not satisfactory, I could click on another dictionary tab which would fully expand this panel and display the embedded secondary dictionary (if it is an embeddable one, otherwise keep the UI as is).

image

Describe alternatives you've considered

I have tried finding a different dictionary site to avoid all this pain, but Glosbe really is such a strong dictionary for the Greek language and I haven't found another that is suitable.

Additional context

N/A

jzohrab commented 8 months ago

Hi @patrickayoup - thanks very much for the detailed issue. I'll see if I can do a fast fix.

jzohrab commented 8 months ago

This change should be simple but currently it's not due to global state, ref #289. When that ticket's done, the change should be something as simple as

-  const first_embedded_button = LookupButton.all.find(button => !button.isExternal);
-  if (first_embedded_button)
-    first_embedded_button.activate();
- 
+  const first_button = LookupButton.all[0];
+  if (first_button)
+    first_button.do_lookup();
jzohrab commented 8 months ago

289 addressed by #290, so this might be simpler once that's in.

patrickayoup commented 8 months ago

Neat, I appreciate it

jzohrab commented 8 months ago

Fixed in develop -- now the popup is opened if that's the first thing.

jzohrab commented 8 months ago

Just need to do some final sanity checks, then it's done:

with langs with pop-up first, reading pane term click
with langs with pop-up first, new term created
with langs with pop-up first, term listing existing term clicked
repeat the 3 cases above for lang with embedded first
patrickayoup commented 8 months ago

This is great! Thanks for the quick turnaround!

jzohrab commented 8 months ago

@patrickayoup - tried it out and all looks ok, just make sure your browser doesn't block the popup windows. 👋

jzohrab commented 8 months ago

It'll be out in the next launch, maybe over the weekend.

jzohrab commented 8 months ago

Launched in 3.2.4.