feat: add syntax highlighting for JSON payload in web version#2004
feat: add syntax highlighting for JSON payload in web version#2004
Conversation
ysfscream
left a comment
There was a problem hiding this comment.
Hi @nktnet1,
Sorry for the late response. Thank you so much for your contribution to MQTTX!
I have a few suggestions and questions before we can merge this:
-
Light theme color issue: The syntax highlighting colors for the published message box (right side) don't look quite right in the light theme. Could you please adjust and optimize the colors for better readability?
As a suggestion, you might consider removing the highlighting from the publish message box entirely, since users can already see the syntax highlighting in the editor when composing messages. This is how the desktop version works - you can use it as a reference.
-
Code duplication: I noticed that
night-owl.scssanddark.scsshave identical code. Could you refactor these to share a single file and reduce code duplication? -
Performance concerns: Since MQTT can handle a very high volume of messages, I'm a bit concerned about the performance impact of adding this component to every message item. A few questions:
- How accurate is
autodetectin practice? - Have you tested with large message volumes?
I would suggest adding a toggle/switch in settings to enable/disable syntax highlighting. This way users can turn it off to improve performance when dealing with high message throughput.
- How accurate is
-
Language detection: When syntax highlighting is enabled and the received payload format is JSON, I'd recommend explicitly setting
language="json"instead of usingautodetect. This would improve both accuracy and performance.
Looking forward to your thoughts on these points. Thanks again for your work on this feature!
|
Hey @ysfscream, Thanks for the review :).
|
ysfscream
left a comment
There was a problem hiding this comment.
Looks good to me now. Thank you so much for your contribution and for addressing all the feedback! 🎉
PR Checklist
What is the current behavior?
No syntax highlighting for JSON payload in the web version of MQTTX.
Issue Number
Related to #1362, #1381 and #1390, but for Web.
What is the new behavior?
JSON payload now has syntax highlighting.
Light Theme:
Dark Theme:
Night Theme:
Does this PR introduce a breaking change?
Specific Instructions
The theme I use are:
Also, only the
JSONlanguage was registered.With highlight.js, I had to use
highlight.js@v10.7.3(instead of 11.x.x) and@highlightjs/vue-plugin@1.0.2(instead of 2.x.x) for compatibility with Vue 2.There were also typescript issues that required
./src/types/highlight.d.tsto be included, where typeanywas used. Haven't figured out why or how else to work around this.