lapo-luchini / asn1js

JavaScript generic ASN.1 parser
ISC License
576 stars 161 forks source link

New feature: Copy a part of the asn1 structure to the clipboard #82

Closed olibu closed 5 months ago

olibu commented 7 months ago

This is a pull request to add the functionality to copy a part of the asn1 structure to the clipboard.

The following issues are related to this PR:

Adding a further option to download the selection as a file would be easily possible based on this solution. However, it is not part of the current pull request.

lapo-luchini commented 5 months ago

I like this! It would probably have sense on the "tree" on the left too. Right now single-click is bind to "hide tree" but it happens more often by mistake than by on purpose I guess, so a contextual menu like that would be nice there too (maybe with the first element being "collapse/expand" node?)

lapo-luchini commented 5 months ago

I imported your commits (almost identically, some whitespace might be slightly different) in branch github-82. (I use monotone upstream and export to Git, so I can't directly merge your PR as is)

olibu commented 5 months ago

I like this! It would probably have sense on the "tree" on the left too. Right now single-click is bind to "hide tree" but it happens more often by mistake than by on purpose I guess, so a contextual menu like that would be nice there too (maybe with the first element being "collapse/expand" node?)

Not sure how to add a context menu to the tree. The tooltip is already taking the space where a context menu might show up. Shall I try to add the context menu from the hex view to the tree instead of collapsing the tree?

lapo-luchini commented 5 months ago

The tooltip is already taking the space where a context menu might show up.

Mhh, right. What if the click "fixed" the popup as a context menu, thus replacing it but with same functionality? (any suggestion welcome, I'm not really a UI guy myself)

lapo-luchini commented 5 months ago

Also, a small bug in current contextual menu: it disappears only when entering and exiting it, but is is possible to "just go away" from it and leaving it on screen until you get back and hover it. (this is small and I'm not even sure it's best to fix it or leave it as is)

lapo-luchini commented 5 months ago

I'm also thinking about merging the "esm" branch into "github-82" branch, as the website is fully using modules already anyways (trunk is still not using modules because that complicates usage as a library).

lapo-luchini commented 5 months ago

@olibu I changed the contextual menu to just hide string dump when not available, what do you think about it?

olibu commented 5 months ago

That's better than the alert. I would change the order of the menu entries. So only the last menu entry is optional.

olibu commented 5 months ago

I have a branch in my fork to try a menu at the tree view. https://github.com/olibu/asn1js/blob/feature/treemenu/dom.js

Is there a way to convert the asn1 to a text shown in the tree view?

lapo-luchini commented 5 months ago

Default content is created in the if at line 94 (span.preview) and is created statically for a faster hover… I wonder if it would be better to do it on-demand on menu creation, or by copying it with something like: node.getElementByClass('preview')[0].innerHTML

lapo-luchini commented 5 months ago

OK, I merged current state, but let's keep this open for improvements regarding the context menu, if you want.

olibu commented 5 months ago

I updated the context menu in my feature branch https://github.com/olibu/asn1js/tree/feature/treemenu Any suggestions?

The current context menu on your web site seems to be broken as it shows on top of the screen.

lapo-luchini commented 5 months ago

updated the context menu in my feature branch

Thanks! I couldn't import them directly because they didn't include my refactorings, but I tried importing their logic in e41f82608bb663aa97df11496f79d64386a0c960.

seems to be broken as it shows on top of the screen.

Strange. It works for me (on both Firefox and Chrome).

olibu commented 4 months ago

@lapo-luchini : I've uploaded the feature/treeview branch to my homepage. You can find it at https://olibu.github.io/asn1js/ Waiting for your feedback