Memento icon indicating copy to clipboard operation
Memento copied to clipboard

Further Optimization of {Selection}

Open campfirium opened this issue 10 months ago • 6 comments

The newly added {selection} feature is very useful—much appreciated! However, there are still some minor issues in its current implementation:

Cross-entry selection is not possible.

For example, in the screenshot below, if I select the definition from the previous entry and then try to add the pronunciation from the next entry, the actual {selection} value turns out to be empty.

Would it be possible to modify this behavior?

Image

Limited flexibility in {selection} usage.

Could {selection} support expressions like {selection} | {clipboard}? This way, if {selection} has a value, it will be used; otherwise, {clipboard} will be used instead.

campfirium avatar Feb 22 '25 05:02 campfirium

It is possible to have cross entry selection, but in terms of software architecture it isn't very elegant. I'll look into it.

For using {selection} and falling back to {clipboard}, I don't think Memento needs to implement this. You can achieve this using some HTML and CSS in your cards. Here's an article about hiding empty elements using CSS. I imagine one element contains {selection} and another has {clipboard} and using some CSS, the {clipboard} element is shown conditionally if {selection} is empty. Here's a codepen that implements conditionally hiding elements based on whether or not a condition in another element is met.

ripose-jp avatar Feb 23 '25 00:02 ripose-jp

Thank you very much for providing the fallback idea!

There is one issue, though—{clipboard} is only needed when {selection} is empty. If we implement this using CSS, every card will still include {clipboard}, even when it's not relevant. Since {clipboard} almost always has content, it will exist in the card data even if it's not visible on the card.

I just wanted to mention this. Having {selection} already makes things very useful. Thanks again!

campfirium avatar Feb 23 '25 02:02 campfirium

it will exist in the card data even if it's not visible on the card.

I can understand why this might be annoying. I can look into how difficult it would be to have a general conditional marker syntax where {selection | clipboard} would try to use {selection} first and if it's empty move onto {clipboard}. I can see this being useful in other cases, for example something like {sentence-2 | context-2}. Though I worry about making the marker syntax too complex since I have to find a place to explain all this stuff to people.

ripose-jp avatar Feb 23 '25 04:02 ripose-jp

Though I worry about making the marker syntax too complex since I have to find a place to explain all this stuff to people

Sentence mining is already a complex process—anyone who’s into it won’t be scared off by a little extra challenge. Plus, it’s just an optional feature—if someone finds it too much hassle, they can simply ignore it!

campfirium avatar Feb 23 '25 10:02 campfirium

I agree, selection is an amazing addition, thank you!!

Being able to select multiple, separate lines (perhaps with CTRL, like in text editors for example) would also be really useful :D

BigBoyBarney avatar Mar 16 '25 19:03 BigBoyBarney

I've implemented the conditional marker syntax as described previously. I've left it undocumented for now since it seems to be fairly niche.

ripose-jp avatar Apr 29 '25 06:04 ripose-jp