-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Add new contentview API #7623
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
Add new contentview API #7623
Conversation
9f6a4d1 to
1b82068
Compare
errorxyz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff 🚀
emanuele-em
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
c68c9cd to
0cea9c6
Compare
8dc7c71 to
0be29d3
Compare
|
This should be good to go! 🚀 I understand that it's incredibly hard to review, but I'd really appreciate a second look over docs/src/content/addons/contentviews.md and examples/. 😃 |
|
For my SAML use case, I wanted my prettify to do things like autoformatting XML text with indentation, which makes it significantly more readable. However, for editing, I actually wanted to operate on the maybe-deflated and base64-decoded data, because my prettify would break XML signatures.
Is this setup possible with this new feature? |
|
Yes. Here's an example for gRPC/Protobuf: https://asciinema.org/a/MivOWmlDxV3juRNvjhxFU7FH8 With the new API, you can implement:
Oh, and you specify |
|
Not just syntax highlighting. Adding whitespace and things, which is actually destructive with XML signatures. Any other similar destructive feature is actually nice to do in prettify for better visualization. But, I want an edit feature to run on un-prettifyed text, because prettify may have destroyed data. But I still do want to have decoding (deflate and base64) performed even for edit. Something like:
What you have is great for formats that roundtrip through prettify without losing data. Maybe it isn't meant to map exactly to my use case. I guess I could still use this new API by having two contentviews: one for editing that does non-destructive things, and a second that's better for visualization and does prettify aggressively. |
I think this sounds like a very specific use case that may not warrant complicating the API. As you mention, a simple workaround would be to have two separate contentviews here. But more fundamentally, the reencoder could also undo the whitespace changes. That probably not super easy to implement... but feels very much possible. 😃 Let's keep this complexity in the individual contentview, and not in the API that's shared by all contentviews. For context, while MsgPack reencoding is laughably simple (msgpack.rs#L35-L46), Protobuf is a convoluted dance. I think it's expected that some contentviews are a bit more complex than others. |
lups2000
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Really nice!
Description
This PR introduces a new contentview API that makes it possible for users to edit prettified views. This is particular useful for binary formats such as protobuf, which are otherwise hard to tinker with.
Feedback from everyone is welcome! For practical purposes it's useful to only look at the changes in CHANGELOG.md, docs/ and examples/.
Major changes
For example, the new Protobuf view pretty-prints to YAML, which the user
can edit and then re-serialize into binary representation.
supports both existing proto definitions and completely unknown protos.
Contentviews now return a plain
strwith the prettified data.Syntax highlighting is now signaled off-band (and based on [tree-sitter]).
the crates ecosystem.
Regressions:
Known gaps:
Related Issues
ConsoleAddon.edit_focus()extensible by addons #7195