Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Copy Definition to Clipboard #50

Closed
moduloapparent opened this issue Aug 6, 2018 · 27 comments
Closed

Feature Request: Copy Definition to Clipboard #50

moduloapparent opened this issue Aug 6, 2018 · 27 comments
Milestone

Comments

@moduloapparent
Copy link

Love Rikaichamp. It's been a godsend since Rikaisama went defunct on the new FF.
One feature missing from it is the ability to copy a definition from the clipboard so I can paste it into an SRS or other program.

@birtles birtles added the feature label Aug 6, 2018
@birtles
Copy link
Member

birtles commented Aug 6, 2018

Thank you very much!
Yes, I had in mind to do that but no-one seemed to ask for it so I assumed it was low priority. Let me see if I can work on it soon.

@moduloapparent
Copy link
Author

Thanks Brian! That would be pretty amazing to have it :)

@nicolasmaia
Copy link

That's awesome! This is something I never knew I wanted to have, but now I see how it would make my life so much easier.

@birtles
Copy link
Member

birtles commented Aug 12, 2018

Yep, it's お盆休み here so while I still have work, I hope to get time in the evenings this week to work on it. I need to make keyboard keys customizable and do the "hold a key to activate" feature first, however.

@birtles
Copy link
Member

birtles commented Aug 29, 2018

The "hold a key to activate" feature has shipped and this is next on my list. I notice rikaikun lets you say how many entries you want to copy. However, I'm guessing that >95%? of the time you really just want the top entry and copying those other entries would just get in the way.

I try to keep Rikaichamp simple so I'd like to add as few configuration options as possible. I'm wondering if we should just make it copy the first entry? That would also obviate the need for rikaikun's "Line ending" setting.

The other setting in rikaikun is "Field separator". What are folks' specific requirements here?

One option is just to use a format similar to the data file, e.g.

上場 [じょうじょう] /(n,vs) (1) listing (on the stock exchange, etc.)/taking a company public/(2) presentation (e.g. of a play, opera)/performance/(P)/

Perhaps we could pretty it up a little:

上場【じょうじょう】(n,vs) listing (on the stock exchange, etc.), taking a company public; presentation (e.g. of a play, opera), performance

I wonder if a multi-key shortcut makes sense?

e.g.

Key Result
ce (copy entry) 上場【じょうじょう】(n,vs) listing (on the stock exchange, etc.), taking a company public; presentation (e.g. of a play, opera), performance
cw (copy word) 上場
cf (copy fields) 上場 → じょうじょう → (n,vs) → listing (on the stock exchange, etc.), taking a company public; presentation (e.g. of a play, opera), performance ( → here represents a Tab)

Then maybe we could even have 2ce to mean "Copy the second entry". You can see I'm a vim user.

Please let me know if you have any suggestions!

@birtles
Copy link
Member

birtles commented Aug 29, 2018

Another thought: I'm not sure how folks are using this, but if they're collecting a whole bunch of words at once we could make it so that some other shortcut key lets you append to the clipboard. e.g. you hover over one word, hit cf then hover over another and hit, e.g. 3Cf to append the third entry to the clipboard.

That's probably overkill though and it suffers the same problem as vim where if on one occasion you fail to use the append version of the command you lose all your previous work.

@nicolasmaia
Copy link

I'm wondering if we should just make it copy the first entry?

I don't think this is a good idea while bug #26 is haunting us.

@birtles
Copy link
Member

birtles commented Aug 30, 2018

I don't think this is a good idea while bug #26 is haunting us.

Good point. But I still find that the top entry is the one I want > 95% of the time (maybe I'm just looking up very specific words?), and if this feature adds the ability to select other entries then I don't think it will be problem.

(I do plan to fix #26 but it will take a while longer.)

@moduloapparent
Copy link
Author

Hey Brian!
Really good questions (which I hadn't thought of in any depth till you raised them).

Copy behaviour

  • How would supporting only two behaviours work e.g. 1) copy first definition in list or 2) copy all definitions in list.
    This would keep it simple for the 80%+ of times where the first entry is the one that's desired, while allowing the 20% odd to be supported (with minor edits by the user to cut out bits that are unnecessary).

Visual presentation
Personally I'd prefer the version that shows the numbers between different definitions as it makes it a touch easier to scan for where one definition ends and the other begins. Another way of course would be to create a line-break or a full paragraph break between the definitions. (This would probably be neater, but come at the livable downside of taking up more space in a card).

Multiple clipboard entries support

  • I personally wouldn't use this as I'd be nervous around needing to mentally track what I've copied without a visual means of telling what's in the clipboard.

Thank you so much for working on this, Brian!

@birtles
Copy link
Member

birtles commented Aug 30, 2018

I'm curious about the use case for copying all the different entries? When do you want to do that?

Just taking the 上場 example from above, copying all the entries would mean you get four different entries for 上 which you almost certainly don't want.

Leaving the numbers sounds fine. Adding line breaks sounds neater, but I suspect it would make the feature less versatile. Although again, I'm not really sure how folks are intending to use this.

Yeah, let's forget the append-to-clipboard behavior. It's complicated and requires extra permissions too (i.e. clipboard-read in addition to clipboard-write).

@moduloapparent
Copy link
Author

moduloapparent commented Aug 31, 2018

Hey Brian!
What I had in mind with the copy all entries key was to try simplify the options. I imagined that if you got a word where definition 3 was the correct definition then unless it was given its own hotkey there'd be no easy way to get it. These will hopefully always be edge cases, so if the default behaviour catches the most common then the secondary behaviour can afford to require a bit more work (ie the user deleting all the non-required definitions manually)

Yes, with you on all your other comments!

#########
Edits - one example might be as below
Lookup word = 条

Behaviour 1 will copy this definition
条 - 下り- passage/paragraph

Behaviour 2 will copy these definitions
条 - 下り- passage/paragraph
条 - じょう - article provision
条 - すじ - muscle/sinew

Behaviour 2 would allow me to capture muscle/sinew without the need for a specific keyboard shortcut to copy definition 3. It means I'm deleting definitions 1 and 2, but means I only need to know two keyboard shortcuts to copy either one or all my definitions.

@birtles
Copy link
Member

birtles commented Sep 1, 2018

Oh, that makes sense. The current approach I have in mind is as follows:

  1. Press c once and the first entry is highlighted.
  2. If you press c again the next entry is highlighted such that you can cycle through them one by one. (Not sure what happens in kanji view though).
  3. When an entry is highlighted, press e to copy it, or w to copy just the word, or f (r?) to copy the entry as a tab-delimited string.
  4. After that the highlight is cleared (but the pop-up remains showing so that you can copy another entry or keep viewing it).
  5. Pressing Esc also clears the highlight.

So in the common case where you just want to copy the first entry you just type c e in rapid succession.

In the case where the entry you want is the third one you'd type c c c e.

Ideally the pop-up itself would show a little guide after pressing c once saying, e.g. "Copy: e = entry, w = word, f = fields, Esc = cancel"). Also, those keys should probably be configurable for non-English speakers.

(That said, this feature is getting a little bit more involved than I originally anticipated so I'm not sure yet if I should come back to it after working on fixing the dictionary database. Initially I thought I'd knock over a few "easy" features then fix all the database issues but at this rate I'm not sure which will land first.)

@moduloapparent
Copy link
Author

Got you.
I can't speak for anyone else, but in my own use case (copying definitions into sentence cards in Anki) I'd only really use copy entry. Copy word feels potentially redundant as the user will in most cases be able to copy the word directly from the webpage. I'm not sure how/where I'd use the copy fields option.

(For selfish reasons) I'd rather see the simplest version possible.

@basil-gray
Copy link

Would like to show my interest in this feature too. I copy and paste definitions into Anki often--Chrome's rikaikun extension does have copy to clipboard and it's the only reason why I use the browser. Text hovering is choppy however and it feels much, much nicer in rikaichamp.

For my own selfish reasons: I would be happy with a single C keypress copying all definitions visible in the pop-up. I limit the number of definitions to 5 and typically delete the ones which I don't use manually.

Good luck!

@birtles
Copy link
Member

birtles commented Oct 7, 2018

Thanks for the feedback. As a result I started working on this yesterday. I'll see if I can get something done this week.

@moduloapparent
Copy link
Author

Thanks Brian! looking forward to it :)

@birtles birtles added this to the 0.0.26 milestone Oct 14, 2018
@birtles
Copy link
Member

birtles commented Oct 18, 2018

Just an update here. I've been working on this pretty steadily for the last 2 weeks. I've had to rewrite fairly large chunks of the add-on but I think most of the hard work is now done. Hopefully should be done in a few days' time.

@birtles
Copy link
Member

birtles commented Nov 8, 2018

Sorry for the delay, I've been unwell. This is basically done now. I just need to test that there is no perf regression from this.

@birtles
Copy link
Member

birtles commented Nov 8, 2018

Perf looks good. Marking this as done.

@birtles birtles closed this as completed Nov 8, 2018
@moduloapparent
Copy link
Author

Legend! Thank you so much, Brian!
I'll download the update once it propagates to Firefox (I'm not familiar with how to use the version you've got here on Github).

@birtles
Copy link
Member

birtles commented Nov 8, 2018

Thank you. I'll hopefully publish a new release tomorrow. Otherwise it will be next week.

@moduloapparent
Copy link
Author

Brian, thank you so much! I've tested the new version and it's great. Really like the way you implemented the definition selection interaction. It makes it super clear what's happening. Very well done on this!

@birtles
Copy link
Member

birtles commented Nov 9, 2018

Thanks so much! I'm really glad you like it. Sorry it took so long!

(I've noticed, however, that if you don't have the window focused Shift works but c does not. I'm not sure yet if there's anything I can do about that, however.)

@basil-gray
Copy link

Just tested this myself, really awesome work birtles! I absolutely love how the definition that's being copied is highlighted in the pop-up window.

Is there any chance you can get the clipboard feature to work with input fields? I primarily use the extension by transcribing Japanese text into a shrib.com page, and then hovering over words/copying over definitions when I need to.

@birtles
Copy link
Member

birtles commented Nov 9, 2018

Ah, good point. Yeah, Rikaichamp's handling of text fields (particularly multi-line <textarea>) is pretty horrible at the moment. I need to fairly thoroughly redo that.

Mind filing an issue to remind me?

@birtles
Copy link
Member

birtles commented Nov 9, 2018

Actually, never mind, issue #20 covers this.

@basil-gray
Copy link

Cool! I'll be keeping an eye on #20 then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants